What's the consensus about the Box-Müller transform? Is it a statistically and numerically sound way to get normally distributed numbers in Excel?
'Box-Müller transform
Dim z1 As Double, z2 As Double, x1 As Double, x2 As Double
x1 = Rnd
x2 = Rnd
z1 = Sqr(-2 * Log(x1)) * Cos(2 * 3.14159265 * x2)
z2 = Sqr(-2 * Log(x1)) * Sin(2 * 3.14159265 * x2)
It was about 500 times faster for me than using
z = Application.WorksheetFunction.NormInv(Rnd, 0, 1) 'or (Rnd, mean, stddev)
The result seemed to be bell-shaped. I plotted it in Matlab, Excel should add a histogram wizard.
Bookmarks