Re: random number generation
Posted by
Bruce Weaver on
URL: http://spssx-discussion.165.s1.nabble.com/random-number-generation-tp5719063p5740973.html
Here is the same approach but using David's MATRIX method:
MATRIX.
SAVE (TRUNC(UNIFORM(1e6,1)*32+1)/2)/OUTFILE */VAR X.
END MATRIX.
GRAPH HISTOGRAM X.
FREQUENCIES X.
Andy W wrote
One way to do it, truncate to integers over 1-32 [note exactly 33 should never happen in rv.uniform(1,33)], and then divide by 2. Upped the number of simulated draws to show it is approximately is uniform as expected.
*************************.
input program.
loop #i = 1 to 1e6.
- compute X =trunc(rv.univorm (1,33))/2.
- end case.
end loop.
end file.
end input program.
frequencies X.
*************************.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/"When all else fails, RTFM."
PLEASE NOTE THE FOLLOWING:
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (
https://listserv.uga.edu/).