<div dir="ltr"><div dir="ltr"><div dir="ltr">On Sat, Apr 27, 2019 at 6:10 AM Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The statistics module is soon to get a quantile function.<br>
<br>
For those of you who use statistics software (whether in Python, or <br>
using other languages) and specifically use quantiles, what sort of <br>
functionality would be useful to you?<br>
<br>
For example:<br>
<br>
- evenly-spaced quantiles (say, at 0.25, 0.5, 0.75)?<br>
- unevenly-spaced quantiles (0.25, 0.8, 0.9, 0.995)?<br></blockquote><div><br></div><div>If I'm interested in multiple quantiles, they are usually unevenly spaced. Something like [0.8, 0.9, 0.95, 0.99, 0.999] would be pretty typical if I'm not sure what the right threshold for an "outlier" is.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
- one quantile at a time?<br></blockquote><div><br></div><div>Yes, this is also quite common, once I know what threshold I care about.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
- any specific definition?<br></blockquote><div><br></div><div>NumPy's quantile function has an "interpolation" option for controlling the quantile definition. But in years of calculating quantiles for data analysis, I've never used it.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
- quantiles of a distribution?<br></blockquote><div><br></div><div>Yes, rarely -- though the only example that comes to mind is quantiles for a Normal distribution. (scipy.stats supports this use-case well.)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
- anything else?<br></blockquote><div><br></div><div>The flexibility of calculating either one or multiple quantiles with np.quantile() is pretty convenient. But this might make for a more dynamic type signature that you'd like for the standard library, e.g.,</div><div><br></div><div><div>T = TypeVar('T')</div><div><br></div><div>@overload</div><div>def quantile(data: Iterable[T], threshold: float) -> T: ...</div><div><br></div><div>@overload</div><div>def quantile(data: Iterable[T], threshold: Sequence[float]) -> List[T]: ...</div></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">Thanks in advance.<br>
<br>
<br>
-- <br>
Steven<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div></div></div>