Quantile type 2 (averaged-inverted-cdf) returns seemingly inconsistent results in both numpy and R

$\begingroup$

Can anyone explain averaged-inverted-cdf method in either numpy.quantiles or R's quantile ? Per either documentation, given a (sorted) container X[n], the quantile is calculated as: Q = (1-𝛄) X[j] + 𝛄 X[j+1], for a quantile input value q such that q*n falls between j and j+1. That is the generic formula.

Now, for averaged-inverted-cdf () or, equivalently, type=2 in R () the only possible values for 𝛄 are: 𝛄 ∈ {0.5, 1} (Also confirmed by the referenced paper: "R. J. Hyndman and Y. Fan, β€œSample quantiles in statistical packages,” The American Statistician, 50(4), pp. 361-365, 1996").

So, then, how is it possible that for the dataset (container): [0.13, 1.0, 1.9 , 2.11, 9.2 ], I get the averaged-inverted-cdf quantile at input q=0.0 as being Q = 0.13? The leftmost position X[0] should never be picked because, 𝛄 β‰  0 ("can never be 0"). So, it should either be the rightmost value (X[1] = 1.0); or the average (X[0] + X[1])/2 = 0.565

The Python code:

>>> arr1s
array([0.13, 1. , 1.9 , 2.11, 9.2 ])
>>> np.quantile(arr1s, 0.0, method = 'averaged_inverted_cdf')
0.13

...and the R code:

> quantile(c(0.13, 1.0, 1.9, 2.11, 9.2), 0.001, type=2)
0.1%
0.13

What am I missing?

$\endgroup$ Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking β€œPost Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like