The following .do file produces different results for xb each time run.
clear
set seed 4530754024
rndbin 10000 .363328 262
summ xb, d
Since the rndbin command invokes uniform() I thought that setting the seed
would make the program produce identical results.
What am I missing? Did seed not exist in version 3.1?
here is the relevant snipped of the binreg .ado file
program define rndbin
version 3.1
cap drop xb
qui {
local cases `1'
set obs `cases'
mac shift
local pp `1'
mac shift
local n `1'
if `pp' < 0.5 { local p = `pp' }
else { local p = 1.0 - `pp' }
local am = `n'*`p'
noi di in gr "( Generating " _c
....
....
....
tempvar ran1 ran2 ds ts sum1 e y em bn1
local en = `n'
local oldg = lngamma(`en'+1.0)
local pc=1.0-`p'
local plog = log(`p')
local pclog = log(`pc')
local sq = sqrt(2.0*`am'*`pc')
gen `em' = -1
gen `e' = -1
gen `ran1' = uniform()
gen `ran2' = uniform()
gen `ds' = 1
gen `ts' = 1
gen `y' = -1
egen `sum1' = sum(`ds')
while `sum1' > 0 {
replace `y' = sin(_pi*`ran1')/cos(_pi*`ran1')
replace `em' = `sq'*`y' + `am' if (`ds'==1)
replace `ts' =0 if (((0>`em') | (`em' >=(`en'+1.0))) & (`ds'==1))
#delimit ;
replace `e' = 1.2*`sq'*(1.0+(`y'*`y'))*exp(`oldg'-lngamma(`em'+1.0)
-lngamma(`en'-`em'+1.0) + (`em' *`plog')+(`en'-`em')*`pclog') if
(( `ds'==1) & (`ts'==1));
#delimit cr
replace `ds'=0 if ((`ran2'<`e') & (`ds'==1) & (`ts'==1))
replace `ran1' = uniform()
replace `ran2' = uniform()
replace `e'=-1
replace `ts' = 1
drop `sum1'
egen `sum1' = sum(`ds')
noi di in gr "." _c
}