[Top][All Lists]

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

Re: [Help-gsl] generating random numbers between two numbers

From: Will Farr
Subject: Re: [Help-gsl] generating random numbers between two numbers
Date: Tue, 6 May 2008 19:49:23 -0400

In general, this is the only way available. If you have a probability distribution for a variable x, (i.e. p(X)dX is the probably that x lies in [X, X + dX]), then the probability distribution for a function of that variable, y(x), is given by p(Y) = p(X) / dy/dx. If you want p(Y) = const, and you know that p(X) = const, then you must have dy/dx = const => y = c + d x for some c and d. That is, only linear functions take a uniform distribution to a uniform distribution. So, the only way to generate a uniform distribution on [a,b] given a uniform distribution on [0,1] is the way you outlined.


On May 6, 2008, at 8:00 AM, Awhan Patnaik wrote:

GSL allows random number generation between the unit interval [0,1]. However if one has to generate numbers between ANY two real numbers a and b then one
way is the following:
num = a + rand*(b-a) where rand is a random number in the unit interval. Is
this the only way available ? I mean are the statistical properties
preserved in such cases.
Help-gsl mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]