Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Generating random variables with logistic distribution


From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   st: RE: Generating random variables with logistic distribution
Date   Thu, 4 Aug 2005 16:12:54 +0100

If you can construct the inverse cumulative distribution function of a distribution, then it is dead easy to draw random samples.

E.g. for a logistic distribution with parameters m and b, the cumulative distribution function is:

F(x) = 1/(1+exp(-(x-m)/b))

so the inverse is

G(x) = m - b*log(1/y - 1)

A random sample can then be drawn with

gen y = `m' - `b'*log(1/uniform() - 1)

(where `m' and `b' are locals containing the parameters m and b)

Hope this helps

David

-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Richard
Williams
Sent: 04 August 2005 15:27
To: [email protected]
Subject: st: Generating random variables with logistic distribution


I know how to generate random variables with normal and uniform 
distributions.  How about other distributions - in particular, 
logistic?  Is there a program around that already does this, or can 
somebody tell me what the formula is?  I seem to vaguely remember seeing 
something like this but now I can't find it.  Thanks.


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX:    (574)288-4373
HOME:   (574)289-5227
EMAIL:  [email protected]
WWW (personal):    http://www.nd.edu/~rwilliam
WWW (department):    http://www.nd.edu/~soc

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index