Happy New Year - The Final Approximation

Published:

Updated:

Happy New Year Folks.

We have finished the study on our Approximation of Random Normal Distribution.

It will work for any range of standard deviation from 0 to ∞ and fractionally very small numbers (i.e. (1/100), (1/1000000), .0001, .00000001, or similar).

Also, those of you that may have noticed, if you use the regular random function in your programming language, you'll see that if the random number goes to zero you'll get an error.

This is because of the natural log in the first half addition, ln().

The function, tan(), goes to zero when y goes to zero and taking the natural log of zero leads to an error.

To fix this problem, your random function needs to fall in the range of greater than zero and less than one.

Below is an example of how to do this in Visual Basic code; this will work in Excel VB as well, modify it to fit your programming language.

______

Function Random() as Double

  Dim R as Double

  Do

     R = Rnd()

  Loop Until R <> 0

  Random = R

End Function

______

Entry #2,335

Comments

Avatar JADELottery -
#1
Also, if you're wondering how to get the z value inside the function itself, replace the z with: sgn(rnd()-0.5)

Even though the sign function, sgn(), goes to zero, it will have an insignificant effect on the outcome.
Avatar JADELottery -
#2
Here's an Excel VB code example

Function Random() As Double
    Dim R As Double
    Do
        R = Rnd()
    Loop Until R <> 0
    Random = R
End Function

_____

Function Sinh(a As Double) As Double
    Sinh = (Exp(a) - Exp(-1 * a)) / 2
End Function

_____

Function RandomNormal(S As Double) As Double
    Dim Pi, y As Double
    Pi = 3.14159265358979
    y = Random()
    RandomNormal = ((2 * S) / Pi) * Log(Tan((Pi * y) / 2)) + Sgn(Rnd() - 0.5) * (2 * Pi + 4 * (Atn(S - 1) - Atn(S + 1))) * Sin(4 * Atn(Sinh(y / 2))) * Exp(-1 * ((y ^ 2) + (Pi ^ 2)) / Pi)
End Function
Avatar time*treat -
#3
If this sort of thing keeps up, I may have to do an update of code and formulas links. :0)
Avatar JADELottery -
#4
Well, there may be one more up and coming.

We're working a Cubic Solution for a Random Sums Distribution.

We have a temporary working solution, but it needs more research, study, and analysis.
Avatar sully16 -
#5
Happy New Year Jade, many good wishes for you and your family.

Post a Comment

Please Log In

To use this feature you must be logged into your Lottery Post account.

Not a member yet?

If you don't yet have a Lottery Post account, it's simple and free to create one! Just tap the Register button and after a quick process you'll be part of our lottery community.

Register