5
41%
MIT
Statistics module written in Reason. Inspired by [simple-statistics](https://github.com/simple-statistics/simple-statistics). Help me add more functions :-)

Statistics module written in Reason. Inspired by simple-statistics. Help me add more functions :-)

Usage

yarn install stats.re
// in bsconfig.json
"bs-dependencies": ["stats"]
  • RE
  • ML
let array = [|1.2, 2.3, 3.4, 4.5|];
let result = ArrayStats.mean(array); /* 2.85 */
let array = [|1.2;2.3;3.4;4.5|]
let result = ArrayStats.mean array

The best docs are the tests. See ArrayStatsTests.re and ListStatsTests.re.

ArrayStats (mirrors ListStats)

  • RE
  • ML
/* basics */
ArrayStats.min(x: array(float)) => float;
ArrayStats.max(x: array(float)) => float;
ArrayStats.sum_simple(x: array(float)) => float;
ArrayStats.mode(x: array(float)) => float;
ArrayStats.quantile(quantile: float, x: array(float)) => float;
ArrayStats.product(x: array(float)) => float;

/* sorted */
ArrayStats.sort(x: array(float)) => array(float);
ArrayStats.min_sorted(x: array(float)) => float;
ArrayStats.mode_sorted(x: array(float)) => float;
ArrayStats.quantile_sorted(quantile: float, x: array(float)) => float;

/* measures of central tendency */
ArrayStats.mean(x: array(float)) => float;
ArrayStats.median(x: array(float)) => float;
ArrayStats.root_mean_squared(x: array(float)) => float;
ArrayStats.geometric_mean(x: array(float)) => float;
ArrayStats.harmonic_mean(x: array(float)) => float;
ArrayStats.sample_skewness(x: array(float)) => float;

/* measures of dispersion */
ArrayStats.variance(x: array(float)) => float;
ArrayStats.sample_variance(x: array(float)) => float;
ArrayStats.standard_deviation(x: array(float)) => float;
ArrayStats.sample_standard_deviation(x: array(float)) => float;
ArrayStats.interquartile_range(x: array(float)) => float;
ArrayStats.sum_nth_power_deviations(x: array(float), n: float) => float;
2310: syntax error, consider adding a `;' before

Utils

  • RE
  • ML
Stats.Utils.add_to_mean(mean: float, listLength: float, newValue: float) => float;
2310: syntax error, consider adding a `;' before

Dev

yarn start
# open http://localhost:1234
# edit src/Stats.re

See more here.

See also

  • owl - "numerical library: dense and sparse matrix, linear algebra, regressions, maths and stats functions"