Skip to content

Commit ecd784a

Browse files
committed
Extra tests for prctile
1 parent 6580d2f commit ecd784a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/statistics.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,19 @@ pub mod stats {
410410
/// If the percentile value is <= 0 or >= 100, returns the minimum and maximum values of the array respectively.
411411
/// ```typescript
412412
/// let data = [1, 2, 0, 3, 4];
413+
/// let p = prctile(data, 0);
414+
/// assert_eq(p, 0.0);
415+
/// ```
416+
/// ```typescript
417+
/// let data = [1, 2, 0, 3, 4];
413418
/// let p = prctile(data, 50);
414419
/// assert_eq(p, 2.0);
415420
/// ```
421+
/// ```typescript
422+
/// let data = [1, 2, 0, 3, 4];
423+
/// let p = prctile(data, 100);
424+
/// assert_eq(p, 4.0);
425+
/// ```
416426
#[rhai_fn(name = "prctile", return_raw, pure)]
417427
pub fn prctile(arr: &mut Array, p: Dynamic) -> Result<FLOAT, Box<EvalAltResult>> {
418428
if arr.is_empty() {

0 commit comments

Comments
 (0)