Skip to content

Unexpected results for multiple quantiles #704

@donmccurdy

Description

@donmccurdy

I'm seeing an issue very similar to #262 when using the latest release (v7.8.3). These methods give very different results for the p05 quantile —

import { quantile } from 'simple-statistics';

const a = quantile(data, [0.0, 0.05, 0.5, 0.95, 1.0]);
const b = quantile(data, [0.0, 0.05,      0.95, 1.0]);
const c = [
  quantile(data, 0.0),
  quantile(data, 0.05),
  quantile(data, 0.95),
  quantile(data, 1.0)
];

For my input data, A and C match, but B[1] is incorrect.

case p00 p05 p50 p95 p100
A 0 3,569,032 8,370,252 11,183,760 17,198,303
B 0 8,370,252 ❌ 11,183,760 17,198,303
C 0 3,569,032 11,183,760 17,198,303
input.json
[
    4534264.499853279,
    0,
    0,
    4441655.968117084,
    7982031.499157332,
    11183760.330270268,
    8374531.7466523405,
    7537166.851276029,
    6408451.109897822,
    4858231.646338846,
    6409803.519554875,
    4296216.572964368,
    5367514.3078208575,
    6364913.420875475,
    8621150.51996475,
    9236261.500350267,
    7850954.174512796,
    6026897.449805159,
    3569031.9331034794,
    5336662.162307054,
    6953168.388225255,
    6789669.207787706,
    6225885.17604323,
    5217135.654872652,
    6199349.484675659,
    5858452.126622974,
    7235692.6957654515,
    5129514.715977198,
    5161771.078309817,
    6488305.210989551,
    8371033.429666803,
    6753743.962686865,
    6595808.546434772,
    8505806.597449332,
    7272245.97545039,
    9785009.118050914,
    8023968.06734304,
    8370252.207796229,
    7616759.566780881,
    9758307.209897608,
    9549180.910991326,
    11536569.38123997,
    17198302.677047078
]

REPL:

https://svelte.dev/repl/47f4bf4cb3914fad9d8cd1d8bd13ada5?version=3.56.0

I'll look into this further when I can. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions