From: ts Date: 2000-08-23T01:55:32+09:00 Subject: [ruby-talk:4554] Re: RFC: Ruby extension for Random numbers >>>>> "R" == Robert Feldt writes: R> So it suffices to add load and dump methods? For an user point of view, he don't need to know that it exist #_load, #_dump (this is the internal of Math::Random). You can add (if you want) a method #dump or just say that he can use Marshal#dump if he want to save the states of the generator. R> I'm not sure I know exactly what you mean (even though it sounds as R> though I should!). Can you give short code (well, structure will R> do) example (for gaussian)? (I had planned to use something like R> Box-Mueller method for generating gaussian from uniform(0,1)) Have you looked at GSL ? http://sources.redhat.com/gsl/ref/gsl-ref_15.html#SEC207 You'll see that it exist a library randist, and for example for the gaussian, you have : ------------------------------------------------------------ Random: double gsl_ran_gaussian (const gsl_rng * r, double sigma) This function returns a Gaussian random number, with mean zero and standard deviation sigma. The probability distribution for Gaussian random numbers is, for x in the range -\infty to +\infty. Use the transformation z = \mu + x on the numbers returned by gsl_ran_gaussian to obtain a Gaussian distribution with mean \mu. Function: double gsl_ran_gaussian_pdf (double x, double sigma) This function computes the probability density p(x) at x for a Gaussian distribution with standard deviation sigma, using the formula given ---------------------------------------------------------------- and this is the same for the other distributions, you have a module function which return a probabilty density or a random number for this distribution. Guy Decoux