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

Re: st: simulating bernoulli random numbers


From   Roger Newson <[email protected]>
To   [email protected]
Subject   Re: st: simulating bernoulli random numbers
Date   Wed, 02 Jul 2003 21:01:06 +0100

At 21:02 02/07/02 +0200, Thomas M�hlmann wrote:
Dear all,

I have an urgent request. Does someone know of a way to draw zero's und
one's random numbers from a bernoulli variable? Can I use the "uniform
()" command for this task?
Yes, you can. If you want the probability of success to be 0.75, then you can simply type

gene byte bernie=uniform()<=0.75

and -bernie- will contain a Bernoulli pseudo-random variable with a probability 0.75 of success. You can do the same with other probabilities of success.

I hope this helps.

Roger


--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]
Website: http://www.kcl-phs.org.uk/rogernewson

Opinions expressed are those of the author, not the institution.


*
* 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