Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: RandomChoice does not accept null weights

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83404] Re: RandomChoice does not accept null weights
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Mon, 19 Nov 2007 06:21:47 -0500 (EST)

Szabolcs Horvát wrote:
> ... or Pick[]ing out those elements whose 
> weight is not 0 before passing them to RandomChoice[].

Pick[] caused a lot confusion here ... so some people may find the 
following information useful.

Consider the this example:

In[1]:= Pick[{a, b, c}, {0, 1, 2}, Except[0]]
Out[1]= {a, b, c}

I expected the result {b, c}.  So why is it {a, b, c}?  Here is the 
explanation:

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/b011242fd0f042a1/4930d9a0540d808f

IMO this example should be included under "possible issues" in Pick's 
documentation.

Szabolcs--
Szabolcs


  • Prev by Date: Re; Tally[ ] and Union[ ]
  • Next by Date: Plotting Points with Labels
  • Previous by thread: Re; Tally[ ] and Union[ ]
  • Next by thread: RandomChoice does not accept null weights