Re: Generating Random Numbers with Normal Distribution

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Dec 10, 2007 2:28 PM, AmirBehzad Eslami <behzad.eslami@xxxxxxxxx> wrote:
> Dear list,
>
> For some computer-based simulation, i need to
> generate random numbers that have a normal distribution.
>
> It seems that PHP's rand() and mt_rand() functions return
> uniformly distributed numbers which is not suitable for
> simulation purposes.

    Just for fun, I decided to write out an algorithm to randomize
with a never-known seed that would update constantly, with no human or
external script intervention required to initiate or maintain it.
What I came up with to count all CPU processing percentages of all
PIDs on the system, concatenate them into a single, long string, and
then add each number, in turn, to a running total; each number, in
succession, is added the sum of all numbers before it, until the end
of the number string has been reached.

    Then the function runs through some other routines to see if
certain conditions are matched, and eventually returns the randomized
number.

    Keep in mind that this is just something I put together in about
20 minutes, so it's far from perfect, but feel free to check it out.

    http://www.pilotpig.net/code-library/source.php?f=rand.php

-- 
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux