Newsgroups: sci.stat.math,comp.ai.alife,sci.nonlinear,sci.math.num-analysis
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!miner.usbm.gov!rsg1.er.usgs.gov!jobone!newsxfer.itd.umich.edu!europa.eng.gtefsd.com!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!swidir.switch.ch!newsfeed.ACO.net!Austria.EU.net!EU.net!uunet!hearst.acc.Virginia.EDU!murdoch!fermi.clas.Virginia.EDU!jvn
From: jvn@fermi.clas.Virginia.EDU (Julian V. Noble)
Subject: Re: Fast random number generator, binomial pdf
Message-ID: <Cx3vxK.GxD@murdoch.acc.Virginia.EDU>
Sender: usenet@murdoch.acc.Virginia.EDU
Organization: University of Virginia
References: <Cx25zM.J5C@news.tcd.ie>
Distribution: inet
Date: Mon, 3 Oct 1994 16:46:32 GMT
Lines: 25
Xref: glinda.oz.cs.cmu.edu sci.stat.math:2810 comp.ai.alife:1066 sci.nonlinear:1701 sci.math.num-analysis:16238

ddoff@tcd.ie  writes:
> I can't help noticing that none of the postings in this thread have
> answered the original question, which has now disappeared into archive
> space. but if I remember correctly was something like this:
> 
> Wanted - a RNG to produce 1 with a probability p and 0 with probability
> of 1-p. How to avoid a step like "if rnd<p then x=1 else x=0"?
>                ^^^^^
> I would be interested in the answer too!

You don't NEED the if...else... statement. In most languages, the logical
expression rnd < p evaluates to TRUE (+1 in come languages--C, I think--
and -1 in others like Forth, BASIC, etc.) if the latter, say

	x = abs( rnd < p )

otherwise just say 

	x = rnd < p 

(convert to a float if necessary, but I think you want an integer 
here).	--jvn
--
Julian V. Noble
jvn@virginia.edu
