Univariate truncated normal random variates can be generated using
so-called "integral transform theorem". For example, see the following
references:
Borsch-Supan and Hajivassiliou (1993): "Smooth Unbiased Multivariate
Probability Simulators for Maximum Likelihood Estimation of Limited
Dependent Variables Models", Journal of Econometrics, 58, 347-368.
Hajivassiliou, McFadden and Ruud (1996): "Simulation of Multivariate Normal
Rectangle Probabilities and Their Derivatives: Theoretical and Computational
Results", Journal of Econometrics, 72, 85-134.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
Jeffrey Wang Research Scientist
Insightful Corp. (206) 283-8802 x 269
-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of Prof Brian D
Ripley
Sent: Tuesday, April 03, 2001 10:54 PM
To: Joseph Beyene
Cc: splus list
Subject: Re: [S] Generating random real numbers
On Tue, 3 Apr 2001, Joseph Beyene wrote:
> If seems to me the objective of the original question
> is to generate random numbers from a distribution that
> is assumed to follow a normal distribution on the
> support (0.005, 0.035).
There is no such distribution, and the original question was not
well-posed (although I agree that was what was asked for).
The normal distribution has support the whole real line.
> Hence, the question boils down to determining the mean (mu)
> and standard deviation (sigma) of the distribution,
> since these two parameters fully specify the underlying
> normal distribution.
>
> Step-1: The Gaussian mean parameter should be located at the
> center of the support. Here the center is
> (0.005 + 0.035)/2 = 0.02 = mu;
>
> Step-2: Determine sigma using the following simple algebra:
>
> P(0.005 < X < 0.035) = 1
>
> => P((0.005-0.02)/sigma < (X-0.02)/sigma < (0.035-0.02)/sigma) =1
>
> => P(-0.015/sigma < Z < 0.015/sigma) = 1, where Z is N(0,1).
>
> But we also know that P(-4 < Z < 4) is ALMOST 1, so can set
Why 4, not 3 or 6 or ...? I suspect 3 would be a better choice.
> 4 = 0.015/sigma, which implies sigma = 0.00375.
>
>
> Step-3: We can now generate random samples from a N(0.02, 0.00375)
> distribution in the usual way.
>
> e.g.
>
> > rnorm(n=10,mean=0.02,sd=0.00375)
> [1] 0.01880891 0.01918489 0.02010347 0.01819819
> [5] 0.01437798 0.01553930 0.01847044 0.02031811
> [9] 0.02246164 0.02356001
You need to do rejection sampling to remove out-of-range values (which can
occur, about 1 in 10^4 with your cutoff).
> Am I missing the point of the question? I would
> like to hear about alternative (easier) approaches and/or
> whether the above approach suffers from a major
> technical problem.
>
> Regards,
>
>
> Joseph Beyene
> (joseph@utstat.torornto.edu)
>
> Previously, Mike C. Sawada wrote:
> >
> > Try:
> >
> > runif(100,min=0.005,max=0.035)
> >
> > will produce 100 real numbers (real as far as rational and irrational
> > numbers may ocurr) between the ranges of 0.005 and 0.035.
> >
>
> --------------------------------------------------------------------------
-----
> > Mike C. Sawada |Tel: 613-562-5800 x1734
> > Laboratory of Paleoclimatology and Climatology |Fax: 613-562-5145
> > Department of Geography |msawada@aix1.uottawa.ca
> > University of Ottawa
> > 165 Waller Street
> > Ottawa, ON K1N 6N5
> > ----------------- -----------------
> > ************************************************************
> > WWW: http://www.uottawa.ca/academic/arts/geographie/lpcweb/
> > ************************************************************
>
> --------------------------------------------------------------------------
-----
> >
> > 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
> ---------------------------------------------------------------------
> 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
>
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
---------------------------------------------------------------------
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
|