On 9/14/21 9:22 AM, Abel AOUN wrote:> Hello,
>
> I'm currently working on Python numpy package to develop linear
interpolation methods for quantiles.
> Currently, numpy only support the type 7 of Hyndman & Fan and I did the
implementation for the 8 other methods to do as much as R ::quantile.
>
> As you may guess, I was inspired by R implementation as well as other
sources, which lead to my questions:
>
> About fuzz (see first reference below for the source code),
> fuzz <- 4 * .Machine $ double.eps
> I think I understand why the machine epsilon is used to correct some edge
cases where the float comparisons would fail.
> However I don't get why epsilon is multiplied by 4 instead of simply
using epsilon.
> Is there someone who can explain this 4 ?
No, but doing a bit of archaeology
https://github.com/wch/r-source/blame/trunk/src/library/stats/R/quantile.R
give the commit message for these lines as "add (modified) version of
quantile.default from Rob Hyndman (17 years ago)". This commit was made
by Brian Ripley.
However, the code from Rob Hyndman here:
https://stat.ethz.ch/pipermail/r-devel/2004-July/030204.html
does **not** have the lines with the fuzz. So my guess would be that
Brian Ripley is the author of that particular bit of code.
I can't say, myself, what the logic behind 4 * .Machine$double.eps is ...
>
> About licence,
> Numpy is under license BSD and R is on GPL.
> The only thing I really cherry picked and rewrote for numpy is the fuzz
part.
> I'm quite new to open source development. We are wondering if doing
this breaks the license GPL and if I can credit the original authors.
> Plus, I'm not quite sure this is the right place to ask this, if not,
sorry for the noise.
> The relevant discussion on numpy PR is here: [
https://github.com/numpy/numpy/pull/19857#discussion_r706019184 |
https://github.com/numpy/numpy/pull/19857#discussion_r706019184 ]
>
>
> Thank you for your time.
>
> Regards,
> Abel Aoun
>
>
> References:
> The source code for R::quantile (fuzz is at line 82) [
https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/library/stats/R/quantile.R
|
https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/library/stats/R/quantile.R
] [ https://github.com/numpy/numpy/pull/19857 ]
> R doc for quantile : [
https://www.rdocumentation.org/packages/stats/versions/3.5.0/topics/quantile |
https://www.rdocumentation.org/packages/stats/versions/3.5.0/topics/quantile ]
> The ongoing PR on numpy: [ https://github.com/numpy/numpy/pull/19857 |
https://github.com/numpy/numpy/pull/19857 ]
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
Graduate chair, Mathematics & Statistics