<div dir="auto">Thanks for putting together this clean implementation!</div><div dir="auto"><br></div><div dir="auto">My concern is that Polya-Gamma is not popular enough to warrant inclusion in NumPy, which tries very hard to limit scope these days. For example, Polya-Gamma isn’t implemented in scioy.stats and doesn’t have a Wikipedia page, both of which are generally much more inclusive than NumPy.</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 27, 2020 at 3:29 AM Tom Swirly <<a href="mailto:tom@swirly.com">tom@swirly.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr"><div dir="ltr">I'm just a lurker, but I spent a minute or two to look at that commit, which looks to be high quality. While I personally have not used this distribution, people I know use it all the time (for ML).<div></div><div><br></div><div><br></div><div>A quibble:</div><div><br></div><div><span style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(230,255,237);color:rgb(36,41,46)">#</span><span style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(230,255,237)">define</span><span style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(230,255,237);color:rgb(36,41,46)"></span><span style="box-sizing:border-box;line-height:1em;white-space:break-spaces;background-clip:border-box;background-size:1ch 1.25em;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;background-color:rgb(230,255,237);color:rgb(36,41,46);background-position:0% 50%;background-repeat:repeat no-repeat"> </span><span style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(230,255,237)">NPY_PI</span><span style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(230,255,237);color:rgb(36,41,46)"></span><span style="box-sizing:border-box;line-height:1em;white-space:break-spaces;background-clip:border-box;background-size:1ch 1.25em;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;background-color:rgb(230,255,237);color:rgb(36,41,46);background-position:0% 50%;background-repeat:repeat no-repeat"> </span><span style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(230,255,237)">3.141592653589793238462643383279502884</span><span style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(230,255,237);color:rgb(36,41,46)"></span><span style="box-sizing:border-box;line-height:1em;white-space:break-spaces;background-clip:border-box;background-size:1ch 1.25em;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;background-color:rgb(230,255,237);color:rgb(36,41,46);background-position:0% 50%;background-repeat:repeat no-repeat"> </span><span style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(230,255,237)"><span style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">/*</span><span style="box-sizing:border-box;line-height:1em;white-space:break-spaces;background-clip:border-box;background-size:1ch 1.25em;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;background-position:0% 50%;background-repeat:repeat no-repeat"> </span>pi<span style="box-sizing:border-box;line-height:1em;white-space:break-spaces;background-clip:border-box;background-size:1ch 1.25em;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;background-position:0% 50%;background-repeat:repeat no-repeat"> </span><span style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace">*/</span></span><br></div></div><div><br></div><div>and the following defines which appear in numpy/random/src/distributions/random_polyagamma.c are already defined in numpy/core/include/numpy/npy_math.h</div><div><br></div><div>Probably it would be better to include that file instead, if it isn't already included.</div><div><br></div><div><br></div><div>DISCLAIMER: I checked none of the math other than passing my eyes over it.</div></div><div dir="ltr"><div><br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 27, 2020 at 12:05 PM Zolisa Bleki <<a href="mailto:BLKZOL001@myuct.ac.za" target="_blank">BLKZOL001@myuct.ac.za</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi All,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I would like to know if Numpy accepts addition of new distributions since the implementation of the Generator interface. If so, what is the criteria for a particular distribution to be accepted? The reason why i'm asking is because I would like to propose adding
the Polya-gamma distribution to numpy, for the following reasons:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
1) Polya-gamma random variables are commonly used as auxiliary variables during data augmentation in Bayesian sampling algorithms, which have wide-spread usage in Statistics and recently, Machine learning.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
2) Since this distribution is mostly useful for random sampling, it since appropriate to have it in numpy and not projects like scipy [1].</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
3) The only python/C++ implementation of the sampler available is licensed under GPLv3 which I believe limits copying into packages that choose to use a different license [2].<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
4) Numpy's random API makes adding the distribution painless.<br>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif">I have done preliminary work on this by implementing the distribution sampler as decribed in [3]; see:
<a href="https://github.com/numpy/numpy/compare/master...zoj613:polyagamma" id="m_-1695592951456397529gmail-m_3174358686342541856LPlnk" target="_blank" style="font-family:Calibri,Arial,Helvetica,sans-serif">
https://github.com/numpy/numpy/compare/master...zoj613:polyagamma</a> .</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif">There is a more efficient sampling algorithm described in a later paper [4], but I chose not to start with that one unless I know it is worth investing time in.<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"></div>
<br>
I would appreciate your thoughts on this proposal.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Regards,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Zolisa<br>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif">Refs:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif">[1] <a href="https://github.com/scipy/scipy/issues/11009" id="m_-1695592951456397529gmail-m_3174358686342541856LPlnk160222" target="_blank" style="font-family:Calibri,Arial,Helvetica,sans-serif">https://github.com/scipy/scipy/issues/11009</a></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif">[2] <a href="https://github.com/slinderman/pypolyagamma" id="m_-1695592951456397529gmail-m_3174358686342541856LPlnk" target="_blank" style="font-family:Calibri,Arial,Helvetica,sans-serif">https://github.com/slinderman/pypolyagamma</a><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"></div>
[3] <a href="https://arxiv.org/pdf/1205.0310v1.pdf" id="m_-1695592951456397529gmail-m_3174358686342541856LPlnk" target="_blank" style="font-family:Calibri,Arial,Helvetica,sans-serif">https://arxiv.org/pdf/1205.0310v1.pdf</a><br>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"></div>
[4] <a href="https://arxiv.org/pdf/1405.0506.pdf" id="m_-1695592951456397529gmail-m_3174358686342541856LPlnk" target="_blank" style="font-family:Calibri,Arial,Helvetica,sans-serif">https://arxiv.org/pdf/1405.0506.pdf</a><br>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif"></div>
<br>
<br>
<br>
</div>
Disclaimer - University of Cape Town This email is subject to UCT policies and email disclaimer published on our website at <a href="http://www.uct.ac.za/main/email-disclaimer" target="_blank">http://www.uct.ac.za/main/email-disclaimer</a> or obtainable from +27 21 650 9111. If this email is not related to the business of UCT, it
is sent by the sender in an individual capacity. Please report security incidents or abuse via <a href="https://csirt.uct.ac.za/page/report-an-incident.php" target="_blank">https://csirt.uct.ac.za/page/report-an-incident.php</a>.
</div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div> /t<br><br>PGP Key: <a href="https://flowcrypt.com/pub/tom.ritchford@gmail.com" target="_blank">https://flowcrypt.com/pub/tom.ritchford@gmail.com</a><br><font style="color:rgb(0,0,238)"><u><a href="https://tom.ritchford.com" target="_blank">https://tom.ritchford.com</a></u></font></div><div><font style="color:rgb(0,0,238)"><u><a href="https://tom.swirly.com" target="_blank">https://tom.swirly.com</a></u></font><br></div><div><font style="color:rgb(0,0,238)"><br></font></div><div><font style="color:rgb(0,0,238)"><br></font></div></div></div></div></div></div></div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div></div>