Re: Re: bug in RandomChoice if weight is zero?
- To: mathgroup at smc.vnet.net
- Subject: [mg106073] Re: [mg106025] Re: bug in RandomChoice if weight is zero?
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Thu, 31 Dec 2009 03:20:56 -0500 (EST)
- References: <hhc72h$2k5$1@smc.vnet.net> <200912300916.EAA17459@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
Yes, but even so. zero-probability events shouldn't occur in samples. Hence, the documentation simply contradicts itself. Bobby On Wed, 30 Dec 2009 03:16:58 -0600, dh <dh at metrohm.com> wrote: > Hi Mathias, > from the manual: > "RandomSample[{Subscript[e, 1],Subscript[e, 2],\[Ellipsis]},n] never > samples any of the Subscript[e, i] more than once." > Daniel > > On 29 Dez., 07:20, Matthias Greiff <gre... at mac.com> wrote: >> 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 > > -- DrMajorBob at yahoo.com
- References:
- Re: bug in RandomChoice if weight is zero?
- From: dh <dh@metrohm.com>
- Re: bug in RandomChoice if weight is zero?