MathGroup Archive 2000

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

Search the Archive

RE: need little help

  • To: mathgroup at
  • Subject: [mg23557] RE: [mg23530] need little help
  • From: "Ersek, Ted R" <ErsekTR at>
  • Date: Sat, 20 May 2000 03:10:32 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Wagner Truppel wrote:
I have a list of probabilities (whose sum is 1.0), each associated with an
index. I'd like to randomly choose an index based on those probabilities.
For example, suppose m = {0.2, 0.4, 0.1, 0.3} 

The following will work nicely.

     Which[x<0.2,1,  x<0.6,2,  x<0.7,3,  True,4]



Ted Ersek

Mathematica tips, tricks are at

  • Prev by Date: Re: [Question] How to load(get) Packages
  • Next by Date: Question of function for hexahedron
  • Previous by thread: Re: need little help
  • Next by thread: Re: need little help