Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Biased Random[Integer]?

  • To: mathgroup at
  • Subject: [mg19050] Re: Biased Random[Integer]?
  • From: "Stephen P Luttrell" <luttrell at>
  • Date: Thu, 5 Aug 1999 01:34:43 -0400
  • Organization: Defence Evaluation and Research Agency
  • References: <7o5gbi$>
  • Sender: owner-wri-mathgroup at

AES <siegman at> wrote in message news:7o5gbi$rim at
> "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?

Here's my attempt:

If[Random[Real, {0, 1}] < p, 0, 1]

Dr Stephen P Luttrell
Room EX21, Defence Evaluation and Research Agency
Malvern, Worcs, WR14 3PS, U.K.
luttrell at
01684-894046 (phone), 01684-894384 (fax)

  • Prev by Date: Re: Solving difficult integral
  • Next by Date: Re: How to prevent a window from being resized?
  • Previous by thread: Re: Biased Random[Integer]?
  • Next by thread: Curious weakness in Simplify with Assumptions