comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » LINFIT CHISQ and SIGMA values are correct??
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
LINFIT CHISQ and SIGMA values are correct?? [message #91593] Tue, 04 August 2015 12:54 Go to next message
Krishnakumar M.A is currently offline  Krishnakumar M.A
Messages: 19
Registered: March 2013
Junior Member
Hi,

I was trying to do a linfit in the following data (I'm using IDL 6.3).

---------------------------------------------------

x = [150.0, 235.0, 325.0, 410.0, 610.0]
y = [200.0, 35.0, 8.4, 3.0, 0.6]
err = [25.0, 5.0, 2.1, 0.8, 0.2]

result = linfit(alog10(x),alog10(y),MEASURE_ERRORS=alog10(err), CHISQ=chi, COVAR=covmatrix, SIGMA=error, YFIT=fit)

---------------------------------------------------

It gave me surprisingly odd values for CHISQ and SIGMA. The values are given below.

---------------------------------------------------

result
11.6899 -4.29070
chisq
0.00799291
sigma
4.32894 1.66352

---------------------------------------------------

Fit result looked good, but the values of sigma and chisq are way off. I believe that the chisq it gives is reduced chisq. Is there anything went wrong in the fitting procedure, or are there any issues with the linfit algorithm?

Please let me know whether I'm doing it right or not.

Thanks,
Krishnakumar
Re: LINFIT CHISQ and SIGMA values are correct?? [message #91598 is a reply to message #91593] Tue, 04 August 2015 19:19 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
You are giving linfit negative errors -- alog10(0.2) = -0.69897

If you use the absolute value of alog10(err) you will get consistent results.

But probably it is better to do your logarithmic transformation correctly

if z = alog10(y) then dz = 0.434*dy/y (I think)

where dy is your original err and dz is your transformed err .

On Tuesday, August 4, 2015 at 3:54:39 PM UTC-4, Krishnakumar M.A wrote:
> Hi,
>
> I was trying to do a linfit in the following data (I'm using IDL 6.3).
>
> ---------------------------------------------------
>
> x = [150.0, 235.0, 325.0, 410.0, 610.0]
> y = [200.0, 35.0, 8.4, 3.0, 0.6]
> err = [25.0, 5.0, 2.1, 0.8, 0.2]
>
> result = linfit(alog10(x),alog10(y),MEASURE_ERRORS=alog10(err), CHISQ=chi, COVAR=covmatrix, SIGMA=error, YFIT=fit)
Re: LINFIT CHISQ and SIGMA values are correct?? [message #91603 is a reply to message #91598] Wed, 05 August 2015 00:07 Go to previous messageGo to next message
Krishnakumar M.A is currently offline  Krishnakumar M.A
Messages: 19
Registered: March 2013
Junior Member
On Wednesday, August 5, 2015 at 7:49:24 AM UTC+5:30, wlandsman wrote:
> You are giving linfit negative errors -- alog10(0.2) = -0.69897
>
> If you use the absolute value of alog10(err) you will get consistent results.
>
> But probably it is better to do your logarithmic transformation correctly
>
> if z = alog10(y) then dz = 0.434*dy/y (I think)
>
> where dy is your original err and dz is your transformed err .
>
> On Tuesday, August 4, 2015 at 3:54:39 PM UTC-4, Krishnakumar M.A wrote:
>> Hi,
>>
>> I was trying to do a linfit in the following data (I'm using IDL 6.3).
>>
>> ---------------------------------------------------
>>
>> x = [150.0, 235.0, 325.0, 410.0, 610.0]
>> y = [200.0, 35.0, 8.4, 3.0, 0.6]
>> err = [25.0, 5.0, 2.1, 0.8, 0.2]
>>
>> result = linfit(alog10(x),alog10(y),MEASURE_ERRORS=alog10(err), CHISQ=chi, COVAR=covmatrix, SIGMA=error, YFIT=fit)


Thanks for the reply. I did not get any difference by giving abs(alog10(err)).

But I got better values for chisq and sigma when I used dz = 0.434*dy/y. Could you please tell me why a factor of 0.434?
Re: LINFIT CHISQ and SIGMA values are correct?? [message #91604 is a reply to message #91603] Wed, 05 August 2015 00:23 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
I think that what he's saying is:

if f(x) = log_b(x) then f'(x) = 1/(x ln(b)) where b is the base of the logarithm. In your case, you're using IDL's alog10(). So the derivative of the function f(x) = alog10(x) is f'(x) = 1/(x*alog(10)) and can be rewritten as:
f'(x) = 0.434/x

So 0.434 = 1/alog(10)

I hope it helps.

Cheers,
Helder

PS: In case you're unsure what or why the step from z=alog10(y) to dz=0.434*dy/y was taken, then you should look at error propagation and differentials. Here are some google result I found: http://tutorial.math.lamar.edu/Classes/CalcI/Differentials.a spx
http://www.rit.edu/cos/uphysics/uncertainties/Uncertaintiesp art2.html


On Wednesday, August 5, 2015 at 9:08:05 AM UTC+2, Krishnakumar M.A wrote:
> On Wednesday, August 5, 2015 at 7:49:24 AM UTC+5:30, wlandsman wrote:
>> You are giving linfit negative errors -- alog10(0.2) = -0.69897
>>
>> If you use the absolute value of alog10(err) you will get consistent results.
>>
>> But probably it is better to do your logarithmic transformation correctly
>>
>> if z = alog10(y) then dz = 0.434*dy/y (I think)
>>
>> where dy is your original err and dz is your transformed err .
>>
>> On Tuesday, August 4, 2015 at 3:54:39 PM UTC-4, Krishnakumar M.A wrote:
>>> Hi,
>>>
>>> I was trying to do a linfit in the following data (I'm using IDL 6.3).
>>>
>>> ---------------------------------------------------
>>>
>>> x = [150.0, 235.0, 325.0, 410.0, 610.0]
>>> y = [200.0, 35.0, 8.4, 3.0, 0.6]
>>> err = [25.0, 5.0, 2.1, 0.8, 0.2]
>>>
>>> result = linfit(alog10(x),alog10(y),MEASURE_ERRORS=alog10(err), CHISQ=chi, COVAR=covmatrix, SIGMA=error, YFIT=fit)
>
>
> Thanks for the reply. I did not get any difference by giving abs(alog10(err)).
>
> But I got better values for chisq and sigma when I used dz = 0.434*dy/y. Could you please tell me why a factor of 0.434?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: cgscatter2d.pro 'keyword parameters not allowed to call' error
Next Topic: IDL crashing on call of TV

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:21:42 PDT 2025

Total time taken to generate the page: 0.00463 seconds