Estimating the error per point

advertisement
1/8
Estimating the error per point
fi 1  f  xi    m f '  xi  
fi  f  xi    i
 2m
f ''  xi    i 1
2
(1)
fi 1  f  xi    p f '  xi  

2
p
f ''  xi    i 1
2
Use the equation for fi to eliminate f(xi) from the other two
 2m
fi 1  fi   m f '  xi  
f ''  xi    i 1   i
2
(2)
 2p
fi 1  fi   p f '  xi  
f ''  xi    i 1   i
2
Multiply the top equation by p and the bottom by m and add the two equations
 m  2p   p  m2
 m  fi 1  fi    p  fi 1  fi  
f ''  xi    m  i 1   i    p  i 1   i  (3)
2
Assume that 2 f ''  xi    so that this term can be dropped. So that
m  fi 1  f i   p  fi 1  fi   m  i 1   i    p  i 1   i 
Square equation (4)
P  fi ,  m ,  p     m  fi 1  f i   p  fi 1  fi  
(4)
2
  2m   i21  2 i 1 i   i2   2 m  p   i 1 i 1   i  i 1   i 1    i2    2p  i21  2 i 1 i   i2 
(5)
Over an ensemble average with a Gaussian distribution with width , Integral of a
Gaussian.doc, the odd terms integrate to zero and 2  2 so that
  mi  fi 1  fi    pi  f i 1  f i  
2
  mi 2 i 2   mi 2 i 12  2 mi  pi i 2   pi 2 i 12   pi 2 i 2
(6)
The error in the expectation value of (5) is given by [for example see
Random.doc#Standard_Deviation]
 P2  P2  P
2
2/8
Expectation value of P2
2
2
  mi  fi 1  fi    pi  fi 1  f i      mi 2   i 1   i   2 mi  pi   i 1   i   i 1   i    pi 2   i 1   i  


4
4
  mi   i 1   i 



 4 mi 2  pi 2   i 1   i 2   i 1   i 2



  pi 4   i 1   i 4



 4 mi 2  mi  pi   i 1   i 2   i 1 i 1   i 1 i   i  i 1   i 2  


 2 2     2  2     2

mi
i 1
i
pi
i 1
i


 4 2               2

pi
mi pi
i 1
i
i 1
i
i 1
i


4
Holding only the even terms
  mi  fi 1  fi    pi  fi 1  fi    oddterms 
  mi 4   i 14  6 i 12  i 2   i 4 



 4 mi 2  pi 2   i 12  i 12   i 12  i 2   i 4 



  pi 4   i 14  6 i 12  i 2   i 4 



 4 mi 2  mi  pi   i 12  i 2  2 i 12  i 2   i 4 



 2 mi 2  pi 2   i 12  i 12   i 2  i 12   i 2  i 12   i 4  


 4 pi 2  mi  pi   i 12  i 2  2 i 12  i 2   i 4 



4
The squared terms average over a Gaussian distribution to 2 while the fourth powers
average to 24 Integral of a Gaussian.doc so that the ensemble average is
  mi  fi 1  fi    pi  fi 1  f i  
4
  mi 4  2  6  2   4 mi 2  pi 2 1  1  2 



  i 4   pi 4  2  6  2   4 mi 3  pi 1  2  2 



2
2
3
 2 mi  pi 1  1  1  2   4 pi  mi 1  2  2  
(7)
The distinction between i-1, i, and i+1 has been ignored in (7)
The error term is thus
  mi  fi 1  fi    pi  fi 1  fi  
4
   mi  fi 1  fi    pi  fi 1  f i  
 10   mi 4   pi 4   30 mi 2  pi 2 

2
  4   mi 2   mi  pi   pi 2  
 i  
  20   3    3  


mi
pi
pi
mi



4

  i 4 6   mi 4   pi 4   18 mi 2  pi 2  12   mi 3  pi   pi 3  mi 
2
2
(8)

With all delta’s equal to 1 this is 544. This says that 2 is calculated with an error of
(54/6) for each point. Or equivalently, each point predicts 2  3 2
The data for fitting the error is a table of values
The function
P from Equation m
Error estimate from
p
2
3/8
value
(5)
Equation (8)
2
2
fi
xi-xi-1
xi+1-xi
<Pi>6 I
(<P2>-<P>2)1.225<Pi>
The term used to approximate this is Poly(f, m, p;a,b,c )
The quantity minimized is
N 1  P  Poly ( f ,  ,  ; a, b, c 
i
m
p

 2  a, b, c    
2

P
i 2 
i


At the end of the fit, a, b and c will have been determined. These can be used to replace
the estimated i2 in the 5th column by a more accurate value for a second fit.
Details on simulating artificial data files are in SimErr.doc. The code
SIMEGRC.FOR was used to construct artificial data.
Figure 1 Artificial data with a Gaussian distribution with =0.04 about each data point.
Once this file has been constructed, this is just another curve fit problem.
The code to construct the error data is ERRDAT.FOR, the error data is in the file
test.EST
4/8
Figure 2 The error estimate2 i2 as a function of the size of the data fi
Minimization
Assume that
 i2  a  b fi  cfi 2 (9)
The constants a, b and c can be determined by minimizing
  f  f     f  f  2
pi
i 1
i 
i
  mi i 1
2
2
2

N 1 
 mi 2a  b  fi 1  fi   c  fi 1  fi 
2
  a, b, c    
2
i  2  2   a  b f  cf 
mi pi
i
i

 2p 2a  b  fi 1  fi   c  fi 21  fi 2 





2



 (10)





With respect to a, b, and c
Sort out the a, b, and c dependences
  f  f     f  f  2  a 2   2      2 
pi
i 1
i 
mi
pi mi
pi
i
  mi i 1

N 1


2
2
2
2
2
  a, b, c    b fi 1  mi  fi   mi  2 mi  pi   pi   fi 1  pi

i 2 

2
2
c fi 21  mi

 fi 2   mi
 2 mi  pi   2pi   fi 21 2pi




Define


2
(11)
5/8
Fdi    mi  fi 1  f i   pi  fi 1  fi  
2
ACi  2   mi
  pi  mi   2pi 
2
(12)
(13)
BCi  fi 1  2mi  fi   2mi  2 mi  pi   2pi   fi 1  2pi
(14)
2
2
CCi  fi 21  mi
 fi 2   mi
  mi  pi   2pi   fi 21 2pi
(15)
So that
N 1
2
 2  a, b, c     FC 2i  aACi  bBCi  cCCi  (16)
i 2
The partials with respect to a, b, and c are
 2  a, b, c  N 1
   Fdi  aACi  bBCi  cCCi ACi
a

2
i 2
 a, b, c 
b
N 1
   Fdi  aACi  bBCi  cCCi BCi
i 2
 2  a, b, c 
c
N 1
   Fdi  aACi  bBCi  cCCi CCi
i 2
Then define
N 1
FdA   Fdi ACi
i2
N 1
FdB   Fdi BCi
i 2
N 1
FdC   Fdi CCi
i 2
And also define
(18)
(17)
6/8
N 1
AAS   ACi  ACi
i 2
N 1
ABS   ACi  BCi
i 2
N 1
ACS   ACi CCi
i 2
N 1
BAS   BCi  ACi  ABS
i2
N 1
BBS   BCi  BCi
i2
N 1
BCS   BCi  CCi
i 2
N 1
CAS   CCi ACi  ACS
i2
N 1
CBS   CCi BCi  BCS
i2
N 1
CCS   CCi CCi
(19)
i 2
So that setting the derivatives in (17) to zero the equations for a, b and c become
FdA  a  AAS  b  ABS  c  ACS
FdB  a  ABS  b  BBS  c  BCS
FdC  a  ACS  b  BCS  c  CCS
(20)
The code sminv from CHOLESKY.doc htm – or in nlfit\formp\robmin.for could be used
to solve (20), but it is also easily to manually do the eliminations. First note that since f’s
are traditionally between 0 and 100, the last terms dominate and can easily be rmoved
first. Thus begin by using the first line to eliminate c.
BCS
BCS 
BCS 


 a   ABS  AAS 
  b   BBS  ABS 

ACS
ACS 
ACS 


CCS
CCS 
CCS 


FdC  FdA 
 a   ACS  AAS 
  b   BCS  ABS 

ACS
ACS 
ACS 


FdB  FdA 
Define
BCS
ACS
CCS
FdChat  FdC  FdA 
ACS
And
FdBhat  FdB  FdA 
(22)
(21)
7/8
BCS
ACS
CCS
ACShat  ACS  AAS 
ACS
And
BCS
BBShat  BBS  ABS 
ACS
CCS
BCShat  BCS  ABS 
ACS
So that (21) becomes
ABShat  ABS  AAS 
(23)
(24)
FdBhat  a  ABShat  b  BBShat
FdChat  a  ACShat  b  BCShat
Now eliminate b
FdBhat  a  ABShat  b  BBShat
BCShat
FdChat  FdBhat 
BBShat
a
BCShat
ACShat  ABShat 
BBShat
(25)
Then
FdChat  a  ACShat
BCShat
FdC  a  ACS  b  BCS
c
CCS
b
(26)
(27)
And a test equation
0  FdA  a  AAS  b  ABS  c  ACS
(28)
Simplification
The constant term only
Note that if only a is used to minimize 2 (11), that the solution is a=FdA/AAS
Linear only
If there is no c, the equations for minimizing 2 (20) become
FdA  a  AAS  b  ABS
(29)
FdB  a  ABS  b  BBS
FdB  FdA  BBS / ABS  a   ABS  AAS  BBS / ABS 
FdB  FdA  BBS / ABS
(31)
a
ABS  AAS  BBS / ABS
FdB  a  ABS
(32)
b
BBS
(30)
8/8
B only
If there is only b - Poisson statistics err = (bfi) - , the equations for minimizing
 (11) become
2
FdB  b  BBS
b  FdB / BBS
c only
If there is only c - err = fi c ) - , the equations for minimizing 2 (11) become
FdC  c  CCS
c  FdC / CCS
Download