Jump to content
Sign in to follow this  

Random Normal Number generator

Recommended Posts

To generate numbers on a bell curve, call this function with the mean and the standard deviation of the desired output. (This code was found elsewhere and adapted for AutoIt - use it if you find an application!)

Func randNorm($mean, $stddev)

    While ($w >= 1.0)
        $x1 = 2.0 * Random() - 1.0
        $x2 = 2.0 * Random() - 1.0
        $w = $x1 * $x1 + $x2 * $x2

    $w = Sqrt((-2.0 * Log($w)) / $w)
    $y1 = $x1 * $w
    $y2 = $x2 * $w
    Return $y1 * $stddev + $mean

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...