<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 18, 2017 at 4:52 AM, Nadav Har'El <span dir="ltr"><<a href="mailto:nyh@scylladb.com" target="_blank">nyh@scylladb.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-">On Wed, Jan 18, 2017 at 11:00 AM, <a href="mailto:alebarde@gmail.com" target="_blank">alebarde@gmail.com</a> <span dir="ltr"><<a href="mailto:alebarde@gmail.com" target="_blank">alebarde@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Let's look at what the user asked this function, and what it returns:<br><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>User asks: please give me random pairs of the three items, where item 1 has probability 0.2, item 2 has 0.4, and 3 has 0.4.<br><br></div><div>Function returns: random pairs, where if you make many random returned results (as in the law of large numbers) and look at the items they contain, item 1 is 0.2333 of the items, item 2 is 0.38333, and item 3 is 0.38333.<br></div><div>These are not (quite) the probabilities the user asked for... <br></div><div><br></div><div>Can you explain a sense where the user's requested probabilities (0.2, 0.4, 0.4) are actually adhered in the results which random.choice returns?<br></div></div></div></div></blockquote><div><br></div></span><div>I think that the question the user is asking by specifying p is a slightly different one: <br></div><div>     "please give me random pairs of the three items extracted from a population of 3 items where item 1 has probability of being extracted of 0.2, item 2 has 0.4, and 3 has 0.4. Also please remove extract items once extracted."<br></div></div></div></div></blockquote><div> <br></div></span><div>You are right, if that is what the user wants, numpy.random.choice does the right thing.<br><br></div><div>I'm just wondering whether this is actually what users want, and whether they understand this is what they are getting.<br></div><div><br>As I said, I expected it to generate pairs with, empirically, the desired distribution of individual items. The documentation of numpy.random.choice seemed to me (wrongly) that it implis that that's what it does. So I was surprised to realize that it does not.<span class="gmail-HOEnZb"><font color="#888888"><br></font></span></div></div></div></div></blockquote><div><br>As Alessandro and you showed, the function returns something that makes sense. If the user wants something different, then they need to look for a different function, which is however difficult if it doesn't have a solution in general.<br><br></div><div>Sounds to me a bit like a Monty Hall problem. Whether we like it or not, or find it counter intuitive, it is what it is given the sampling scheme.<br><br></div><div>Having more sampling schemes would be useful, but it's not possible to implement sampling schemes with impossible properties<br></div><div><br></div><div>Josef<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><span class="gmail-HOEnZb"><font color="#888888"></font></span></div><span class="gmail-HOEnZb"><font color="#888888"><div><br></div><div>Nadav.<br></div></font></span></div></div></div>
<br>______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/<wbr>mailman/listinfo/numpy-<wbr>discussion</a><br>
<br></blockquote></div><br></div></div>