summaryrefslogtreecommitdiff
path: root/numpy/array_api/tests/test_asarray.py
diff options
context:
space:
mode:
authordeego <deego3@gmail.com>2022-07-02 11:29:12 -0400
committerGitHub <noreply@github.com>2022-07-02 11:29:12 -0400
commita63587eadc5934158a97aca3fec8a3bb8ca255e1 (patch)
treec626c2d4c53d159d9e4fd6af0b14c979a2da0605 /numpy/array_api/tests/test_asarray.py
parent3d9cacc100e1b9382a543f000d0df44180cff122 (diff)
downloadnumpy-a63587eadc5934158a97aca3fec8a3bb8ca255e1.tar.gz
Fix the interpolation formulae which led to absurd results. For quantile() and percentile().
Fix the interpolation formulae in the docs which led to absurd results. For quantile() and percentile(). Example, for median of a = [1,2,10,11], you expect to obtain i+g=2.5 for method = linear (or weibull, or hazen, or median_unbiased or normal_unbiased). Instead, you obtain a /negative/ index. The correted formula is: i + g = q * (n - alpha - beta + 1 ) + alpha Notice among other things that n belongs in the numerator, not the denominator! As a check, the corrected formula does lead to the correct index 2.5 for each of the cases above. MYSTERY: Surely the original formula was the result of a small typo/thinko? Then, why does the correction look so completely different? RESOLUTION OF MYSTERY: Take our formula, massage it, and swap q with (i+g), and you end up with the original formula. In other words, the original author of the doc. simply confused their percentile with their index halfway through the creation of the doc. Then, they massaged it to isolate (i+g) on the left.
Diffstat (limited to 'numpy/array_api/tests/test_asarray.py')
0 files changed, 0 insertions, 0 deletions