MathGroup Archive 1999

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

Search the Archive

Re: Biased Random[Integer]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19084] Re: [mg19004] Biased Random[Integer]?
  • From: Andrew Watson <abwatson at mail.arc.nasa.gov>
  • Date: Thu, 5 Aug 1999 01:35:05 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

At 10:44 AM -0700 8/3/99, AES wrote:
>"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?

Of course you can do it other ways, but "officially",

\!\(TraditionalForm\`BernoulliDistribution\)

In[9]:=
<<Statistics`DiscreteDistributions`

In[10]:=
Random[BernoulliDistribution[.6]]

Out[10]=
1

Andrew B. Watson
MS 262-2
NASA Ames Research Center
Moffett Field, CA 94035-1000
(650) 604-5419	(650) 604-0255 fax
abwatson at mail.arc.nasa.gov	http://vision.arc.nasa.gov/


  • Prev by Date: Re: Biased Random[Integer]?
  • Next by Date: RE: Lists to mask other lists
  • Previous by thread: Re: Biased Random[Integer]?
  • Next by thread: Re: Biased Random[Integer]?