From e7d52bcbe206b1d9cb0ea00c98cbc08cd00cefd8 Mon Sep 17 00:00:00 2001 From: angus croll Date: Sat, 19 Nov 2022 13:55:53 -0800 Subject: [PATCH] Fix just-percentile docs to reflect that percentile is between 0 and 1 (#515) --- README.md | 14 +++++++------- md-variables.json | 12 ++++++------ packages/array-percentile/README.md | 12 ++++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 92eccd9f0..f8412679f 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ A [REPL](https://anguscroll.com/just) for every utility (powered by [RunKit](htt ## ES and CJS modules available for every utility All packages support ES module or Common JS syntax without requiring transpilation -```js +``` // esm (node / bundler) import clone from 'just-clone'; @@ -1652,14 +1652,14 @@ Return the value at the given percentile (using linear interpolation) import percentile from 'just-percentile'; percentile([1, 2, 3], 0); // 1 -percentile([1, 2, 3], 50); // 2 -percentile([1, 2, 3], 100); // 3 +percentile([1, 2, 3], 0.5); // 2 +percentile([1, 2, 3], 1); // 3 // See https://en.wikipedia.org/wiki/Percentile (linear interpolation method) -percentile([15, 20, 35, 40, 50], 5); // 15 -percentile([15, 20, 35, 40, 50], 30); // 20 -percentile([15, 20, 35, 40, 50], 40); // 27.5 -percentile([15, 20, 35, 40, 50], 95); // 50 +percentile([15, 20, 35, 40, 50], 0.05); // 15 +percentile([15, 20, 35, 40, 50], 0.3); // 20 +percentile([15, 20, 35, 40, 50], 0.4); // 27.5 +percentile([15, 20, 35, 40, 50], 0.95); // 50 percentile(1, 2, 3, 50); // throws percentile(['1', 2, 3], 50); // throws diff --git a/md-variables.json b/md-variables.json index 9153ae298..c982e593c 100644 --- a/md-variables.json +++ b/md-variables.json @@ -174,14 +174,14 @@ "import percentile from 'just-percentile';", "", "percentile([1, 2, 3], 0); // 1", - "percentile([1, 2, 3], 50); // 2", - "percentile([1, 2, 3], 100); // 3", + "percentile([1, 2, 3], 0.5); // 2", + "percentile([1, 2, 3], 1); // 3", "", "// See https://en.wikipedia.org/wiki/Percentile (linear interpolation method)", - "percentile([15, 20, 35, 40, 50], 5); // 15", - "percentile([15, 20, 35, 40, 50], 30); // 20", - "percentile([15, 20, 35, 40, 50], 40); // 27.5", - "percentile([15, 20, 35, 40, 50], 95); // 50", + "percentile([15, 20, 35, 40, 50], 0.05); // 15", + "percentile([15, 20, 35, 40, 50], 0.3); // 20", + "percentile([15, 20, 35, 40, 50], 0.4); // 27.5", + "percentile([15, 20, 35, 40, 50], 0.95); // 50", "", "percentile(1, 2, 3, 50); // throws", "percentile(['1', 2, 3], 50); // throws", diff --git a/packages/array-percentile/README.md b/packages/array-percentile/README.md index a97c68912..feeb14a8c 100644 --- a/packages/array-percentile/README.md +++ b/packages/array-percentile/README.md @@ -21,14 +21,14 @@ Return the value at the given percentile (using linear interpolation) import percentile from 'just-percentile'; percentile([1, 2, 3], 0); // 1 -percentile([1, 2, 3], 50); // 2 -percentile([1, 2, 3], 100); // 3 +percentile([1, 2, 3], 0.5); // 2 +percentile([1, 2, 3], 1); // 3 // See https://en.wikipedia.org/wiki/Percentile (linear interpolation method) -percentile([15, 20, 35, 40, 50], 5); // 15 -percentile([15, 20, 35, 40, 50], 30); // 20 -percentile([15, 20, 35, 40, 50], 40); // 27.5 -percentile([15, 20, 35, 40, 50], 95); // 50 +percentile([15, 20, 35, 40, 50], 0.05); // 15 +percentile([15, 20, 35, 40, 50], 0.3); // 20 +percentile([15, 20, 35, 40, 50], 0.4); // 27.5 +percentile([15, 20, 35, 40, 50], 0.95); // 50 percentile(1, 2, 3, 50); // throws percentile(['1', 2, 3], 50); // throws