Re: question about frandom(N) and random(N) ?

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Tue 12 Mar 2002 11:14:29 AM GMT
Message-ID: <3C8DE315.897F4C06@icparc.ic.ac.uk>
> Zhao Deze wrote:
> 
> Hello,
> 
> I am a student of Helsinki University of Technology. About eclipse (version 5.3 #47), I have the
> questions as below
> 
> the frandom(N), which pdf(probability density function) is it? is it uniform distribution?


frandom/1 uses the following implementation:

/*
 * Floating point random generator. This is taken from random2.c
 * by John Burton, available from the net. Part of original comment:
 *
 * PMMMLCG - Prime Modulus M Multiplicative Linear Congruential Generator   *
 *  Modified version of the Random number generator proposed by             *
 *  Park & Miller in "Random Number Generators: Good Ones Are Hard to Find" *
 *  CACM October 1988, Vol 31, No. 10                                       *
 *   - Modifications proposed by Park to provide better statistical         *
 *     properties (i.e. more "random" - less correlation between sets of    *
 *     generated numbers                                                    *
 *   - generator is of the form                                             *
 *         x = ( x * A) % M                                                 *
 *   - Choice of A & M can radically modify the properties of the generator *
 *     the current values were chosen after followup work to the original   *
 *     paper mentioned above.                                               *
 *   - The generator has a period of 2^31 - 1 with numbers generated in the *
 *     range of 0 < x < M                                                   *
 *   - The generator can run on any machine with a 32-bit integer, without  *
 *     overflow.                                                            *
 */

#define RND_A	48271
#define RND_M	2147483647
#define RND_Q	(RND_M / RND_A)
#define RND_R	(RND_M % RND_A)

static double
frandom()
{
    int32 lo,hi,test;
    static double temp = 1.0 / (double)RND_M;

    hi = seed / RND_Q;
    lo = seed % RND_Q;
    test = RND_A * lo - RND_R * hi;
    seed = (test > 0) ? (test) : (test + RND_M);
    return( (double)seed * temp);
}




> 
> about the random(N), is it normal distribution?

random/1 is just an interface to the C library's random()
function and inherits all its properties (man random).


-- 
 Joachim Schimpf              /             phone: +44 20 7594 8187
 IC-Parc, Imperial College   /            mailto:J.Schimpf@ic.ac.uk
 London SW7 2AZ, UK         /    http://www.icparc.ic.ac.uk/eclipse
Received on Tue Mar 12 11:14:31 2002

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:08:14 PM GMT GMT