MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Biased Random[Integer]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19087] Re: [mg19004] Biased Random[Integer]?
  • From: BobHanlon at aol.com
  • Date: Thu, 5 Aug 1999 01:35:07 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

May not be the cleanest or tersest; however, it works.

random[p_] /; 0 <= p <= 1 := If[Random[] <= p, 0, 1];

nbrTests = 10000;

Count[Table[random[.8], {nbrTests}], 0]/nbrTests // N

0.8013

Count[Table[random[1/5], {nbrTests}], 0]/nbrTests // N

0.2015


Bob Hanlon

In a message dated 8/3/99 9:23:07 PM, siegman at stanford.edu writes:

>"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?
>


  • Prev by Date: Re: Conversion of output
  • Next by Date: Re: equaltity of lists
  • Previous by thread: Biased Random[Integer]?
  • Next by thread: Re: Biased Random[Integer]?