CodePlexProject Hosting for Open Source Software

If you wish, you can install

- Currently this is using a very crude form of area-under-a-curve integration to calculate the probability. This is bad, and not accurate! I will upgrade to a real math library now that I sort-of know what I'm doing with Silverlight.
- There is a random number generator and trials involved in this calculation (see below). As a result, you can expect repeated answers to not be exact. The trials are only thrown if you alter the # of expected background events or the expected background's width.
- If you put in a very large wdith (say 1e5) it will appear the program has hung. This isn't what has happened, however, it will take a very long time to do the calculation, and it is being done on the main thread and that causes a hang - so just wait, or kill it and try again. :-)
- Very small guassian widths on the expected background are not well delt with - so the answer will either come out almost right or it will come out zero... depending on how the randome number generator works. When I use a real math library this will get fixed.

- A gaussian with mean and width of the specified expected background value and width is created. It is normalized to one (it could be truncated at zero - no negative probability is allowed here).
- A crude calculation is performed to determine the xmin and xmax of the plot.
- The length of the axis is sampled uniformly 1000 times, and the guassian function gives an exact weight for each sample.
- The Poisson distribution for the expected background is created and weighted by the gaussian weight.
- The ~2000 Poisson distributions are then added up (and re-normalized in order to deal with the truncated plot).

The actual number of trials is about 20 times the number of bins. The code does its best to make sure there are atleast 50 bins under the main part of the Gaussian, but for performance reasons limits itself to a total of 2000 bins for the full axis.

This is how the two curves are generated. Calculating the probability is done with simple interpolation. The Poisson distribution is really not continuous, so I use a sample interpolation (assuming P(1) is the same value from 1.0 -> 2.0).

Last edited Dec 29, 2009 at 10:01 PM by gwatts, version 7