bug in RandomChoice if weight is zero?
- To: mathgroup at smc.vnet.net
- Subject: [mg105976] bug in RandomChoice if weight is zero?
- From: Matthias Greiff <greiff at mac.com>
- Date: Tue, 29 Dec 2009 01:17:27 -0500 (EST)
If I use RandomChoice with weights of zero the corresponding elements will never be selected. In[62]:= RandomChoice[{0, 0, 3} -> {3, 2, 1}, 5] Out[62]= {1, 1, 1, 1, 1} Why is it not the same if I use RandomSample? The following command RandomSample[{1, 2, 0} -> Range[3], 2] returns either {1,2} or {2,1}. But when I change the command to sample size 3 I get the following. In[60]:= RandomSample[{1, 2, 0} -> Range[3], 3] Out[60]= {2, 1, 3} Why is the third element selected? Shouldn't Mathematica return an error message because the sample size is larger than the population size? Appreciate your answers. Merry Christmas! Matthias
- Follow-Ups:
- Re: Re: bug in RandomChoice if weight is zero?
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: Re: bug in RandomChoice if weight is zero?
- From: Leonid Shifrin <lshifr@gmail.com>
- Re: Re: bug in RandomChoice if weight is zero?
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: bug in RandomChoice if weight is zero?
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: bug in RandomChoice if weight is zero?
- From: Leonid Shifrin <lshifr@gmail.com>
- Re: Re: bug in RandomChoice if weight is zero?