[[ Check out my Wordpress blog Context/Earth for environmental and energy topics tied together in a semantic web framework ]]

## Monday, November 12, 2007

### Monte Carlo Algorithm for Dispersive Discoveries

You can derive the dispersive discovery curve quite easily, but I find it instructive as well to verify it via a Monte Carlo simulation.

The pseudo-code for the random number generation looks like the following (which uses the standard trick for inverting an exponential distribution):
`for Depth in 1..Probing_Depth loop Amt_Discovered := 0.0; for I in 1..N loop -- reduces sampling noise   Draw := Random (0.0 .. 1.0);   Random_Depth := -Depth * Natural_Log (Draw);   if Value > L0 then     Amt_Discovered := L0 + Amt_Discovered;   else     Amt_Discovered := Random_Depth + Amt_Discovered;   end if; end loop; -- Print Depth + Amt_Discovered/Nend loop;`

The basic idea says that if you draw a depth deeper than L0 (the maximum depth for finding something), then cumulatively you can only pro-rate to L0. Otherwise, you will find discoveries proportional to the depth of the random variable probe, Random_Depth (or lambda below). This gives you an idea of how to do a stochastic integration. Remember, we only have an average idea of what probe depth we have, which gives us the dispersion on the amount discovered.