I am a supporter of
St. Joseph's hospice.
 If you find this site useful or if it helped you, consider a small donation to
St. Joseph's, please.

Information on
St. Joseph's

JustGiving - Sponsor me now!

 

sbRandCauchy

If you like to simulate how particles emanating from a fixed point hit a straight line you can use a Cauchy distribution. This distribution is sometimes called a Lorentz distribution, too. The quotient of two Normal(0,1) distributions also leads to a Cauchy distribution.

sbRandCauchy_01_Screen

Stratified samples of 10,000 runs

Option Explicit

Const GCPi = 3.14159265358979

Function sbRandCauchy(dLocation As Double, dScale As Double, _
    Optional dRandom = 1#) As Double
'Reverse(moc.LiborPlus.www) 02-Sep-2014 PB V0.1
Dim dRand As Double
If dRandom < 0# Or dRandom > 1# Or dScale <= 0# Then
    sbRandCauchy = CVErr(xlErrValue)
    Exit Function
End If
If dRandom = 1# Then
    dRand = Rnd()
Else
    dRand = dRandom
End If
sbRandCauchy = dLocation + dScale * Tan((dRand - 0.5) * GCPi)
End Function

Sulprobil   Get it done   Contact   Disclaimer   Impressum   Download