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

Home » Public Forums » archive » Getting the errors on the fitted parameters using mpfit2dpeak
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
Getting the errors on the fitted parameters using mpfit2dpeak [message #36187] Tue, 12 August 2003 18:32
dbarkats is currently offline  dbarkats
Messages: 3
Registered: August 2003
Junior Member
Hi everyone,

I have been trying to understand the returned errors on parameters
using Craig's mpfit2dpeak function. Because things just did not make
sense, I decided to make some simualtions:

I generated 1000 simualtions of a 2d gaussian Z_i,j where in each
realization all the parameters are fixed exept for one ( the fwhm_x)
which I draw from a gaussian distribution of known mean and sigma.
For each realization, I thus feed mpfit2dpeak the Z_i,j points as well
as the errors on Z_i,j obtained from simple error propagation. I do
this 1000 times and save the return parameters as well as their errors
(perror). At the end, I compare the original distibution of the fwhm_x
and the recoved distribution of FWHM_X and its error.
With numbers , this is what I get

-Original distribution of FWHM_X, mean=0.08 and sigma=0.01
-Mean and sigma of recovered distribution of FWHM_X, mean=0.079 and
sigma=0.0097 which is fine,
BUT!!!!!
- Mean of recovered distribution of error of FWHM_X , mean=0.000103.
In other words, the recoved error on FWHM_X is 100 times smaller than
the inputted error. This is exactly why I decided to do some
simulation in the 1st place. I was getting much too small recovered
parameter errors.

Now I know that getting the right errors on fitted parameters is an
art, but if anyone has a clue as to why this gives me such a
discrepacy, I would love to hear it.
I have not yet checked to see if there is a dependance on the exact
original values I entered. I have not tried to see if this effect
happens with a simpler 1d gaussfit.

I include here the code used to run these simualtions.

-Denis

;###############################
PRO simulated_gauss, out

amp=7 ; input amplitude
sigmasx=0.01
sx=randomn(seed,1000)*sigmasx+0.08 ; input FHWM_X
sy=0.1 ; input FWHM_Y
x=0.5*findgen(100)/100-.25 ; input x grid
y=0.5*findgen(100)/100-.25 ; input y grid
out=fltarr(2,1000) ; to save the output fwhm_x and
err
g1=fltarr(100,100) ; 2d_gaussian
g1err=fltarr(100,100) ; error on 2d_gaussian
for k=0,1000 do begin ; loop over 1000 realizations
print,k, sx(k)
for i=0,99 do begin
for j=0,99 do begin
e=exp(-0.5*((x(i)/sx(k))^2+(y(j)/sy)^2))
g1(i,j)=amp*e
g1err(i,j)=sigmasx*(x(i)^2/sx(k)^3)*g1(i,j)
endfor
endfor

;contour, g1, x, y, /fill, nlevels=40
fit=mpfit2dpeak(g1,a,x,y, error=g1err, perror=aerr) ; do the 2d_fit
print,a, aerr
;contour, fit, x, y, /overplot, color=white
; ploterror,g1(50,*), g1err(50,*), psym=2
; oplot, fit(50,*), color=200 &pause
; ploterror,g1(*,50), g1err(*,50), psym=2
; oplot, fit(*,50), color=2000 &pause
out(*,k)=[a(2),aerr(2)]
endfor
END
;####################################################
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Astronomys` Sixth Neighbour Needs Help
Next Topic: Re: Help: multiple linear regression fit

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

Current Time: Wed Oct 08 13:07:22 PDT 2025

Total time taken to generate the page: 0.00401 seconds