s-news
[Top] [All Lists]

Re: Generating random real numbers

To: s-news@lists.biostat.wustl.edu
Subject: Re: Generating random real numbers
From: David Scollnik <scollnik@math.ucalgary.ca>
Date: Tue, 03 Apr 2001 12:26:20 -0600
Organization: University of Calgary
References: <Pine.A41.3.96.1010403133310.44036A-100000@aix1.uottawa.ca>
The (fairly) general solution is as follows.

If F denotes the cdf and FI the inverse cdf of the distribution of interest,
you can generate draws X from F, restricted between A and B, using the
following algorithm:

X = FI( F(A) + U * ( F(B) - F(A) ) )

Here, U is a vector of independent uniform random variates.

For a reference, see Devroye's textbook (Non-Uniform Random Variate
Generation).
 

On Tue, 3 Apr 2001, Alastair Dempster wrote:

> I'm posting this for an Splus user who is not part of this
> discussion group:
>
> She writes:
> "I am interested in generating a set of 100 random real numbers
> between 0.005 and 0.035, where the probability of drawing a specific
> value is
> defined by the normal distribution.  rnorm() will not let me define
> the limits of
> my dataset, yet my model parameter values cannot physically exceed
> 0.035 by
> definition.  Is anyone aware of how to specify range limits when
> generating random
> numbers with a non-uniform distribution? I have explored sample(),
> runif(), rnorm(), and rmvnorm(), all of
> which nicely generate random numbers.  However, either they are not
> real (as in the case of sample()), or I cannot figure out how to
> define a range of values for the random sample."
>
> She is using Splus 2000 under NT4.
>
> I have had a look at the discussions about random number generation
> in the archives but did not find anything suitable.
>
> Can anyone tell us how to code this or provide a reference?  I will
> post a summary on behalf of my colleague.
>
> Thank you,
>
> Alastair Dempster
> Wilfrid Laurier University
> Waterloo, Canada
>
>
>
> ---------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu.  To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message:  unsubscribe s-news
>

---------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news

-- 

David P.M. Scollnik , Ph.D. , A.S.A.            (403) 220 7677 
Dept of Math and Stats , Univ of Calgary     or (403) 220 5203 
scollnik@ucalgary.ca    ++    http://balducci.math.ucalgary.ca
 
<Prev in Thread] Current Thread [Next in Thread>