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

st: Poisson random number


From   Benoit Dulong <[email protected]>
To   statalist <[email protected]>
Subject   st: Poisson random number
Date   Wed, 13 Aug 2003 15:12:33 -0400

How can I generate (within a program)
a random number from a Poisson distribution ?
This should be straightforward,
but I can't find the answer to my problem.

I looked at:
Stata 7 user's guide [U] 16.3, page 114
net search random number
net search poisson 
STB-41 sg44.1, STB-28 sg44 (rndpoi)

----------------------------------------------------------------------

More precisely, 
I would like to put a random Poisson number in -- local n1 --.

program define myprog
version 7.0
args lambda nrep idsim

postfile mysim n1 f1 using `idsim', replace

forvalues i=1(1)`nrep'{
local n1 = random number from Poisson distribution with parameter lambda
local f1 = function of n1
post mysim (`n1') (`f1')
}

postclose mysim

end

----------------------------------------------------------------------

Thank you.

Ben Dulong

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