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

st: Poisson random number

From   Benoit Dulong <>
To   statalist <>
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



Thank you.

Ben Dulong

*   For searches and help try:

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