On 2013-09-16 08:16, Mats Löfdahl wrote:
> On 2013-09-16 07:11, sid wrote:
>> Hello everyone,
>> I am trying to understand what is the chisq keyword
>> means in the routine,
>> poly_fit,
>> svdfit
>> linfit
>>
>> So I took a simple example, x=[1,2,3,4],y=[1,2,3,4]
>> when I give
>> p=poly_fit(x,y,1,chisq=c)
>> c= 1.14631e-30
>> p=svdfit(x,y,2,chisq=c)
>> c= 2.86139e-13
>> p=linfit(x,y,chisqr=c)
>> c=0.00000
>>
>> for poly_fit and linfit the definition of chisq is the same
>> "Set this keyword to a named variable that will contain the value of
>> the unreduced chi-square goodness-of-fit statistic"
>>
>> But the chisq values are different in both these cases even though the
>> inputvalues given are same.
>
> You example data makes a "prefect" fit, so the chisq values are mostly
> numerical precision errors. If you choose data that do not fit perfectly
> to a straight line, the results make more sense:
>
> IDL> x=[1,2,3,4]
> IDL> y=[1.1,2.0,3.3,3.9]
> IDL> p=poly_fit(x,y,1,chisq=c)
> IDL> print,c
> 0.0830000
> IDL> p=svdfit(x,y,2,chisq=c)
> IDL> print,c
> 0.0830001
> IDL> p=linfit(x,y,chisqr=c)
> IDL> print,c
> 0.0829998
>
>
>> Could anyone please let me know what this chisq fit actually means.
>
> Try this:
>
> IDL> p=linfit(x,y,chisqr=c,yfit=yfit)
> IDL> print,yfit
> 1.12000 2.09000 3.06000 4.03000
> IDL> print,total((y-yfit)^2)
> 0.0829998
And by "prefect", I mean "perfect". :o)
|