Lecture 4 - PDFs instead of Error Propagation (mathematics beyond course scope)

advertisement
Products, Sum, and Functions: Generation of PDFs
S. Durkin
With the central limit theorem an experimentalist, by taking multiple measurements, can
be assured of Gaussian errors. When we take products, sums, and divisions what we
would really like to know is the subsequent PDF. At best propagation of errors is a
palatable estimate. Mathematically the resultant PDF we want can be expressed
mathematically quite simply. Suppose we have two independent random variables x and
y, with PDFs f(x) and f(y). The new PDF of f(z) where z=g(x,y) is given by the integral:
 
f ( z) 
  f ( x) f ( y) ( z  g ( x, y))dxdy
  
For the case of the sum of two variables (z=x+y) this leads to the convolution of x and y:
f (z ) 
 

  

  f ( x) f ( y) ( z  x  y)dxdy   f ( x) f ( z  x)dx
Convolutions are better handled in frequency space if you know Fourier Integrals.
Fourier Integrals lead to an elegant five equation proof of the Central Limit theorem one
can find on Wikipedia.
The problem is that for nonlinear g(x,y) the integrations become incredibly difficult
(tedious) When using integral tables with numerical integration the resulting f(z)’s were
well beyond what any physicist had the desire or time to do.
Maple and Mathematica have revolutionized statistical science. One can now perform the
integrals numerically and study the PDFs. I provide the solutions using Maple for the
product of two Gaussian variables (pdf, maple) and the ratio of two Gaussian variables
(pdf ,maple). A beautiful plot of the ratio PDF compared with 100,000 Monte Carlo
samples of the ratio of two Gaussian variables each with mean of 4.0 and sigma of 1.0 is
shown below:
The points are the toy Monte Caro. The red curve is the unnormalized PDF. As an
experimentalist the agreement of the Toy Monte Carlo and the actual PDF is deeply
satisfying. I wish I had this when I was analyzing a neutrino experiment in 1984…
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double gauss(double mean,double xsigma);
int main(){
int i,j;
int ix[100];
double x,tx;
double y,ty;
double r=0.0;
double p=0.0;
double rmean=0.0;
double pmean=0.0;
double r2=0.0;
double p2=0.0;
double rn=0.0;
double pn=0.0;
for(i=0;i<100;i++)ix[i]=0;
srand(123);
for(i=0;i<1000000;i++){
x=0.0;
y=0.0;
x=gauss(4.0,0.5);
y=x;
for(j=0;j<100;j++)if(4.0/y<(j+1)*0.05&&4.0/y>=j*0.05)ix[j]=ix[j]+1;
if(4.0/y<3.0&&4.0/y>0.0)pmean=pmean+4.0/y;
if(4.0/y<3.0&&4.0/y>0.0)pn=pn+1.0;
rmean=rmean+x;
rn=rn+1.0;
if(4.0/y<3.0&&4.0/y>0.0)p2=p2+(4./y-pmean/pn)*(4.0/y-pmean/pn);
r2=r2+(x-4.0)*(x-4.0);
}
printf(" 4/x mean %f \n",pmean/pn);
printf(" gauss mean %f \n",rmean/rn);
printf(" 4/x sigma %f \n",sqrt(p2/pn));
printf(" gauss sigma %f \n",sqrt(r2/rn));
for(j=0;j<100;j++)printf(" %f %d \n",j*0.05+0.025,ix[j]);
return 0;
}
double gauss(double xmean,double xsigma){
int i;
double gauss;
gauss=0.0; for(i=0;i<12;i++)gauss=gauss+rand()/(1.0*RAND_MAX)-0.5;
gauss=gauss*xsigma+xmean;
return gauss;
}
4/x mean 1.016440
gauss mean 3.998756
4/x sigma 0.133785
gauss sigma 0.500142
Download