VBA Monte Carlo Simulation - Repair Time Generator (Lognormally Distributed)
-
14-11-2019 - |
Question
my name is Rik and I'm a 6-sigma green belt, and I've created a Monte-Carlo Simulation of an Aircraft Engine repair facility. I'm currently doing a 6-sigma project on in Excel VBA.
I simply scaled a random number while I was developing the program, but now that it's developed I'd like to use the inverse lognormal CDF http://engineer.jpl.nasa.gov/practices/at2.pdf to create the random repair times, but I couldn't find the function online.
I did find the below code on http://www.anthony-vba.kefra.com/vba/vba12.htm but it is for the normal distribution and I'm not certain of it's accuracy. I couldn't find an equation for the inverse lognormal CDF. I'd like similar code for the inverse lognormal CDF function.
Any help is greatly appreciated.
'****************************************************************************
'* Return random numbers from Standard Normal Distribution *
'****************************************************************************
Function gauss()
Dim fac As Double, r As Double, V1 As Double, V2 As Double
10 V1 = 2 * Rnd - 1
V2 = 2 * Rnd - 1
r = V1 ^ 2 + V2 ^ 2
If (r >= 1) Then GoTo 10
fac = Sqr(-2 * Log(r) / r)
gauss = V2 * fac
End Function
Solution
If you are using Excel VBA the Excel function Loginv together with a random number between 0 and 1 can be used to generate a random Log-normally distributed number.