Feedback

Please leave feedback and comments. I am always interested to hear how people get on using these LScripts!

Sunday, 17 February 2013

Library - Random

The Library is where code samples, building blocks of scripts will be shared.

_randomseed = 0; // n Seed

randomseed: seed
{
    _randomseed = seed;
}

random // n
{
    n = (_randomseed * 214013 + 2531011) % 2^^24;
    _randomseed = n;
    n /= 2^^24; // 0..1
    return(n);
}

gaussianrandom // n
{
    n1 = random();
    n2 = random();
    if(n1 == 0.0){n1 = 0.01;}
    return(sqrt(-2.0 * log(n1)) * cos(2.0 * 3.1415926535 * n2));
}

No comments:

Post a Comment