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

From |
"Vincent, David" <david.vincent@hp.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Random number generation |

Date |
Fri, 5 Jun 2009 13:38:57 +0000 |

Hi Lars, You can easily generate random draws from a variety of distributions using STATA's built in commands. For example, to generate 100 obs from the standard normal (mean 0 variance 1) you would type 1.clear 2.set obs 100 3.gen x=rnormal(0,1) The following is from the STATA help runiform(r, c) returns an r x c real matrix containing uniformly distributed random variates on [0,1). runiform() is the same function as Stata's runiform() function. rbeta(r, c, a, b) returns an ir x jc real matrix containing beta random variates. The real-valued matrices a and b contain the beta shape parameters. The matrices a and b must be r-conformable, where i = max(rows(a),rows(b)) and j = max(cols(a),cols(b)). rbinomial(r, c, n, p) returns an ir x jc real matrix containing binomial random variates. The real-valued matrices n and p contain the number of trials and the probability parameters. The matrices n and p must be r-conformable, where i = max(rows(n),rows(p)) and j = max(cols(n),cols(p)). rchi2(r, c, df) returns an ir x jc real matrix containing chi-squared rnormal(r, c, m, s) returns an ir x jc real matrix containing normal (Gaussian) random variates. The real-valued matrices m and s contain the mean and standard deviation parameters, respectively. The matrices m and s must be r-conformable, where i = max(rows(m),rows(s)) and j = max(cols(m),cols(s)). rpoisson(r, c, m) returns an ri x ci real matrix containing Poisson random variates. The real-valued matrix m contains the Poisson mean parameters, where i = rows(m) and j = cols(m). I hope this helps. Best, David Vincent Econometrician Advanced Analytics Practice Hewlett-Packard Limited Mobile: +44 (0)7939 200 747 Internet: mailto:david.vincent@hp.com Hewlett-Packard Limited Registered Office: Cain Road, Bracknell, Berks RG12 1HN Registered No: 690597 England The contents of this message and any attachments to it are confidential and may be legally privileged. If you have received this message in error, you should delete it from your system immediately and advise the sender. To any recipient of this message within HP, unless otherwise stated you should consider this message and attachments as "HP CONFIDENTIAL". -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Lars Holstenkamp Sent: 05 June 2009 14:02 To: statalist@hsphsun2.harvard.edu Subject: st: Random number generation Dear all, is there somewhere a list of how to generate random numbers with various distributions (esp. triangular, beta, pert; for use in Monte Carlo simulations)? Regards, Lars * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Random number generation***From:*Lars Holstenkamp <lars.holstenkamp@gmx.de>

- Prev by Date:
**Re: st: Random number generation** - Next by Date:
**RE: st: Rename variables to reflect values?** - Previous by thread:
**Re: st: Random number generation** - Next by thread:
**st: STATA command for reporting the estimate of the variance of the time-invariant fixed effect.** - Index(es):

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