diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-09-22 06:19:36 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-09-22 06:19:36 -0700 |
commit | bbd2e86fa76d4afb0ca39a28682f5a0da62aa1a0 (patch) | |
tree | 6f81cef60ea2adc431af7458dd5b1548970e1ef0 /tests/016/arith.tl | |
parent | 2c977768ba68fa50f091dd7dbb3f335f06e835a1 (diff) | |
download | txr-bbd2e86fa76d4afb0ca39a28682f5a0da62aa1a0.tar.gz txr-bbd2e86fa76d4afb0ca39a28682f5a0da62aa1a0.tar.bz2 txr-bbd2e86fa76d4afb0ca39a28682f5a0da62aa1a0.zip |
math: quantile estimator using P-Squared algorithm.
* Makefile (psquare.o): New object file.
* arith.c (psq_ops): New static structure.
(quant_fun): New static function.
(quantile): New function.
(arith_init): Register quantile intrinsic.
* arith.h (quantile): Declared.
* psquare.c, psquare.h: New files.
* tests/016/arith.tl: New tests.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'tests/016/arith.tl')
-rw-r--r-- | tests/016/arith.tl | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/016/arith.tl b/tests/016/arith.tl index be0d512b..34a82c7f 100644 --- a/tests/016/arith.tl +++ b/tests/016/arith.tl @@ -222,3 +222,34 @@ (< '(1 2 3) #(1 2 3.0)) nil (< '(1 2 3) #(1 2 3 4)) t (< '(1 2 3) #(1 2 4)) t) + +(test + (let ((q (quantile 0.5))) + [q 0.02 0.5 0.74 3.39 0.83] + [mapcar q '(22.37 10.15 15.43 38.62 15.92 + 34.60 10.28 1.47 0.40 0.05 11.39 + 0.27 0.42 0.09 11.37)]) + (0.73999999999999999 0.73999999999999999 2.0616666666666665 + 4.5517592592592591 4.5517592592592591 9.1519618055555547 + 9.1519618055555547 9.1519618055555547 9.1519618055555547 + 6.1797614914021164 6.1797614914021164 6.1797614914021164 + 6.1797614914021164 4.2462394088036444 4.2462394088036444)) + +(test + (let ((q (quantile 0))) + (cons [q] [mapcar q '(1 2 3 4 5)])) + (0.0 1.0 1.5 2.0 2.5 3.0)) + +(test + (let ((q (quantile 0 5 0.5))) + [mapcar q '(1.0 2.0 3.0 4.0 5.0 + 0.0 0.0 0.0 0.0 0.0)]) + (1.0 1.5 2.0 2.5 3.0 + 1.5 0.75 0.375 0.1875 0.09375)) + +(test + (let ((q (quantile 0 5 0.5))) + [mapcar q '(0.0 0.0 0.0 0.0 0.0 + 3.0 3.0 3.0 3.0 3.0)]) + (0.0 0.0 0.0 0.0 0.0 + 1.5 2.25 2.625 2.8125 2.90625)) |