Re: Biased Random[Integer]?
- To: mathgroup at smc.vnet.net
- Subject: [mg19061] Re: Biased Random[Integer]?
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Thu, 5 Aug 1999 01:34:51 -0400
- References: <7o5gbi$rim@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
One way: BRI[p_] := If[Random[] < p, 0, 1]; Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 AES <siegman at stanford.edu> wrote in message news:7o5gbi$rim at smc.vnet.net... > "Random[Integer]" gives 0 or 1 with .probability 1/2. > > What's the simplest expression that will yield 0 or 1 with probabilities > p and 1-p ? > > (p itself might be a rational fraction, p = p1/p2.) > > I can write various expressions that do this, but what's the cleanest or > tersest way? >