Statistics | Science @ Science @ MentDB Weak

Statistics
• Descriptive statistics and probability distributions (Apache Commons Math).
• The values are sent as a JSON array of numbers: "[2, 4, 4, 4, 5, 5, 7, 9]".
• Percentiles, quartiles and median use the R7 method (Excel PERCENTILE.INC, numpy, R).
• The linear, polynomial and multiple regressions are in the 'Predictive analysis' page (pa rl, pa rm, pa polynomial_curve_fit_*).
stat correlation <json_array_x> <json_array_y>stat covariance <json_array_x> <json_array_y>stat dist_cdf <law> <json_params> <x>stat dist_inv <law> <json_params> <probability>stat dist_pdf <law> <json_params> <x>stat max <json_array>stat mean <json_array>stat median <json_array>stat min <json_array>stat mode <json_array>stat percentile <json_array> <p>stat pstddev <json_array>stat pvariance <json_array>stat quartiles <json_array>stat range <json_array>stat stddev <json_array>stat sum <json_array>stat sum_sq <json_array>stat summary <json_array>stat variance <json_array>stat chi2_independence <json_matrix>stat chi2_test <json_observed> <json_expected>stat conf_interval_mean <json_array> <level>stat dist_random <law> <json_params> <n>stat fit <json_x> <json_y> <model>stat fit_model <expression> <variable> <json_x> <json_y> <json_init>stat fit_model <expression> <variable> <json_x> <json_y> <json_init> <json_sigma>stat anova <json_groups>stat kruskal <json_groups>stat mann_whitney <json_x> <json_y>stat wilcoxon <json_x> <json_y>stat spearman <json_x> <json_y>stat kendall <json_x> <json_y>stat ks_2 <json_x> <json_y>stat ks_test <json_array> <law> <json_params>stat shapiro <json_array>stat fisher_exact <json_table>stat frequency <json_array>stat geo_mean <json_array>stat harm_mean <json_array>stat histogram <json_array> <nb_classes>stat kurtosis <json_array>stat skewness <json_array>stat ttest_1 <json_array> <mu>stat ttest_2 <json_array_x> <json_array_y>stat ttest_paired <json_array_x> <json_array_y>stat weighted_mean <json_values> <json_weights>stat zscore <json_array>stat ztest <json_array> <mu> <sigma>

stat correlation <json_array_x> <json_array_y>


Description

Get the Pearson correlation coefficient of two series (same size, at least 2 values)

Parameters

json_array_x: A JSON array of numbers - String - required
json_array_y: A JSON array of numbers - String - required

Examples (6)
admin
stat correlation "[1, 2, 3, 4, 5]" "[2, 4, 5, 4, 5]"
mentdb
0.7745966692414834
Pearson correlation of height and weight
admin
stat correlation "[150, 160, 170, 180, 190]" "[50, 58, 69, 77, 89]"
mentdb
0.9977227562128256
Perfect negative correlation
admin
stat correlation "[1, 2, 3]" "[6, 4, 2]"
mentdb
-1
Perfect positive correlation
admin
stat correlation "[1, 2, 3, 4]" "[10, 20, 30, 40]"
mentdb
1
No linear correlation (a parabola)
admin
stat correlation "[-2, -1, 0, 1, 2]" "[4, 1, 0, 1, 4]"
mentdb
0
Temperature and ice cream sales
admin
stat correlation "[18, 21, 24, 27, 30, 33]" "[120, 135, 160, 190, 210, 250]"
mentdb
0.9920973605955749

stat covariance <json_array_x> <json_array_y>


Description

Get the sample covariance of two series (same size, at least 2 values)

Parameters

json_array_x: A JSON array of numbers - String - required
json_array_y: A JSON array of numbers - String - required

Examples (5)
admin
stat covariance "[1, 2, 3, 4, 5]" "[2, 4, 5, 4, 5]"
mentdb
1.5
Sample covariance
admin
stat covariance "[150, 160, 170, 180, 190]" "[50, 58, 69, 77, 89]"
mentdb
242.49999999999997
Negative covariance
admin
stat covariance "[1, 2, 3, 4]" "[8, 6, 4, 2]"
mentdb
-3.333333333333333
Covariance of a series with itself = its variance
admin
stat covariance "[2, 4, 4, 4, 5, 5, 7, 9]" "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
4.571428571428571
Different sizes: error
admin
stat covariance "[1, 2, 3]" "[1, 2]"
mentdb
Sorry, an error appears (the two arrays must have the same size (3 != 2)).

stat dist_cdf <law> <json_params> <x>


Description

Get the cumulative probability P(X &lt;= x) of a law.
Laws and parameters (JSON array):
- normal [mean, stddev]
- student [degrees_of_freedom]
- chi2 [degrees_of_freedom]
- fisher [numerator_df, denominator_df]
- exponential [lambda] (mean = 1/lambda)
- uniform [lower, upper]
- gamma [shape, scale]
- beta [alpha, beta]
- lognormal [mu, sigma] (mean and standard deviation of the logarithm)
- weibull [shape, scale]
- cauchy [location, scale]
- laplace [location, scale]
- logistic [location, scale]
- pareto [scale, shape] (x &gt;= scale)
- triangular [lower, mode, upper]
- binomial [trials, probability]
- poisson [lambda]
- geometric [probability] (x = number of failures before the first success)
- hypergeometric [population, successes, draws]
- pascal [successes, probability] (negative binomial: x = number of failures before the r-th success)
- uniform_int [lower, upper]

Parameters

law: The law (normal, student, chi2, fisher, exponential, uniform, gamma, beta, lognormal, weibull, cauchy, laplace, logistic, pareto, triangular, binomial, poisson, geometric, hypergeometric, pascal, uniform_int) - String - required
json_params: The parameters of the law (JSON array) - String - required
x: The value - Number - required

Examples (14)
admin
stat dist_cdf "normal" "[0, 1]" 1.96
mentdb
0.9750021048517796
admin
stat dist_cdf "binomial" "[10, 0.5]" 5
mentdb
0.6230468749999996
P(X <= 1) for a standard normal law
admin
stat dist_cdf "normal" "[0, 1]" 1
mentdb
0.841344746068543
Student t with 10 degrees of freedom
admin
stat dist_cdf "student" "[10]" 2.228
mentdb
0.9749941140914443
Chi-square with 3 degrees of freedom
admin
stat dist_cdf "chi2" "[3]" 7.815
mentdb
0.950006097025116
Normal law of mean 100 and standard deviation 15: P(X <= 130)
admin
stat dist_cdf "normal" "[100, 15]" 130
mentdb
0.9772498680518208
Probability between two values: P(85 < X <= 115)
admin
-> "[a]" (stat dist_cdf "normal" "[100, 15]" 115); -> "[b]" (stat dist_cdf "normal" "[100, 15]" 85); math calc "[a]-[b]"
mentdb
0.6826894921370861
Exponential law (rate 0.1 per hour): failure before 5 h
admin
stat dist_cdf "exponential" "[0.1]" 5
mentdb
0.3934693402873666
Uniform law on [0, 10]
admin
stat dist_cdf "uniform" "[0, 10]" 2.5
mentdb
0.25
Poisson law (mean 4): at most 2 events
admin
stat dist_cdf "poisson" "[4]" 2
mentdb
0.23810330555354428
Fisher law F(3, 20)
admin
stat dist_cdf "fisher" "[3, 20]" 3.1
mentdb
0.9500754669543211
Weibull law (shape 2, scale 1000 h)
admin
stat dist_cdf "weibull" "[2, 1000]" 500
mentdb
0.22119921692859512
Lognormal law
admin
stat dist_cdf "lognormal" "[0, 0.5]" 1.5
mentdb
0.7912971266155286
Unknown law: error
admin
stat dist_cdf "foo" "[1]" 1
mentdb
Sorry, an error appears (unknown law 'foo' (normal, student, chi2, fisher, exponential, uniform, gamma, beta, lognormal, weibull, cauchy, laplace, logistic, pareto, triangular, binomial, poisson, geometric, hypergeometric, pascal, uniform_int)).

stat dist_inv <law> <json_params> <probability>


Description

Get the quantile of a law: the value x such as P(X &lt;= x) = probability.
Same laws and parameters as 'stat dist_cdf'. For a discrete law, returns the smallest integer x such as P(X &lt;= x) &gt;= probability.

Parameters

law: The law (normal, student, chi2, fisher, exponential, uniform, gamma, beta, lognormal, weibull, cauchy, laplace, logistic, pareto, triangular, binomial, poisson, geometric, hypergeometric, pascal, uniform_int) - String - required
json_params: The parameters of the law (JSON array) - String - required
probability: A probability in [0, 1] - Number - required

Examples (10)
admin
stat dist_inv "normal" "[0, 1]" 0.975
mentdb
1.959963984540054
admin
stat dist_inv "student" "[10]" 0.975
mentdb
2.228138851986303
Critical value of Student (95 %, 9 degrees of freedom)
admin
stat dist_inv "student" "[9]" 0.975
mentdb
2.262157162798239
Quantile 99 % of chi-square (2 degrees of freedom)
admin
stat dist_inv "chi2" "[2]" 0.99
mentdb
9.210340371976296
Median of the exponential law (mean 10)
admin
stat dist_inv "exponential" "[10]" 0.5
mentdb
0.06931471805599453
Median of the exponential law of rate 0.5
admin
stat dist_inv "exponential" "[0.5]" 0.5
mentdb
1.3862943611198906
95th percentile of a normal law N(100, 15)
admin
stat dist_inv "normal" "[100, 15]" 0.95
mentdb
124.67280440427209
Critical value of Fisher F(2, 12) at 5 %
admin
stat dist_inv "fisher" "[2, 12]" 0.95
mentdb
3.8852938346526167
Quantile of a gamma law
admin
stat dist_inv "gamma" "[2, 3]" 0.5
mentdb
5.035040970049985
Probability outside [0, 1]: error
admin
stat dist_inv "normal" "[0, 1]" 1.5
mentdb
Sorry, an error appears (the probability must be in [0, 1]).

stat dist_pdf <law> <json_params> <x>


Description

Get the probability density of a law at x (or the probability P(X = x) for a discrete law).
Same laws and parameters as 'stat dist_cdf'.

Parameters

law: The law (normal, student, chi2, fisher, exponential, uniform, gamma, beta, lognormal, weibull, cauchy, laplace, logistic, pareto, triangular, binomial, poisson, geometric, hypergeometric, pascal, uniform_int) - String - required
json_params: The parameters of the law (JSON array) - String - required
x: The value - Number - required

Examples (11)
admin
stat dist_pdf "normal" "[0, 1]" 0
mentdb
0.3989422804014327
admin
stat dist_pdf "poisson" "[3]" 2
mentdb
0.22404180765538775
Density of the exponential law (rate 2) at 0.5
admin
stat dist_pdf "exponential" "[0.5]" 0.5
mentdb
0.38940039153570244
Probability P(X = 3) for a binomial law B(10, 0.3)
admin
stat dist_pdf "binomial" "[10, 0.3]" 3
mentdb
0.26682793199999993
Poisson law (mean 4): P(X = 2)
admin
stat dist_pdf "poisson" "[4]" 2
mentdb
0.14652511110987348
Uniform law on [0, 4]: density 1/4
admin
stat dist_pdf "uniform" "[0, 4]" 1
mentdb
0.25
Student law: heavier tails than the normal law
admin
stat dist_pdf "student" "[3]" 3
mentdb
0.02297203730924134
Binomial: exactly 5 heads in 10 throws
admin
stat dist_pdf "binomial" "[10, 0.5]" 5
mentdb
0.24609375000000003
Geometric: 2 failures before the first success (p = 0.2)
admin
stat dist_pdf "geometric" "[0.2]" 2
mentdb
0.128
Hypergeometric: 2 aces in 5 cards (52 cards, 4 aces)
admin
stat dist_pdf "hypergeometric" "[52, 4, 5]" 2
mentdb
0.039929818081078615
Beta law
admin
stat dist_pdf "beta" "[2, 5]" 0.2
mentdb
2.4576000000000002

stat max <json_array>


Description

Get the maximum of a series

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat max "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
9
Largest value
admin
stat max "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
13.2
Negative values
admin
stat max "[-5, -2, -9]"
mentdb
-2
Maximum of a computed series
admin
stat max (stat zscore "[1, 2, 3, 4, 10]")
mentdb
1.697056274847714

stat mean <json_array>


Description

Get the arithmetic mean of a series

Parameters

json_array: A JSON array of numbers - String - required

Examples (5)
admin
stat mean "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
5
Mean of 10 measurements
admin
stat mean "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
12.17
Mean of negative and positive values
admin
stat mean "[-3, -1, 0, 1, 3]"
mentdb
0
Repeated measures of g
admin
stat mean "[9.78, 9.82, 9.80, 9.81, 9.79]"
mentdb
9.8
Empty array: error
admin
stat mean "[]"
mentdb
Sorry, an error appears (the JSON array is empty).

stat median <json_array>


Description

Get the median of a series

Parameters

json_array: A JSON array of numbers - String - required

Examples (5)
admin
stat median "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
4.5
Odd number of values
admin
stat median "[7, 1, 3, 9, 5]"
mentdb
5
With an outlier: the median is robust
admin
stat median "[10, 11, 12, 13, 250]"
mentdb
12
Even number of values: average of the two middle values
admin
stat median "[1, 2, 3, 4]"
mentdb
2.5
Unsorted values
admin
stat median "[9, 2, 7, 4, 5]"
mentdb
5

stat min <json_array>


Description

Get the minimum of a series

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat min "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
2
Smallest value
admin
stat min "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
10.9
Negative values
admin
stat min "[-5, -2, -9]"
mentdb
-9
One value
admin
stat min "[3.5]"
mentdb
3.5

stat mode <json_array>


Description

Get the most frequent value(s) of a series, as a JSON array (several values if equal frequencies)

Parameters

json_array: A JSON array of numbers - String - required

Examples (5)
admin
stat mode "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
[4]
admin
stat mode "[1, 2, 2, 3, 3]"
mentdb
[2,3]
Most frequent value
admin
stat mode "[1, 3, 3, 7, 7, 7, 9]"
mentdb
[7]
All the values are different
admin
stat mode "[1, 2, 3]"
mentdb
[1,2,3]
Decimal values
admin
stat mode "[1.5, 2.5, 1.5]"
mentdb
[1.5]

stat percentile <json_array> <p>


Description

Get the percentile p of a series (R7 method)

Parameters

json_array: A JSON array of numbers - String - required
p: The percentile in ]0, 100] - Number - required

Examples (6)
admin
stat percentile "[2, 4, 4, 4, 5, 5, 7, 9]" 90
mentdb
7.6
5th percentile
admin
stat percentile "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]" 5
mentdb
11.125
Median as the 50th percentile
admin
stat percentile "[1, 2, 3, 4, 5]" 50
mentdb
3
First quartile (25th percentile)
admin
stat percentile "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]" 25
mentdb
11.75
Maximum: 100th percentile
admin
stat percentile "[3, 1, 2]" 100
mentdb
3
95th percentile of response times (ms)
admin
stat percentile "[120, 135, 128, 410, 140, 132, 125, 980, 138, 131]" 95
mentdb
723.4999999999993

stat pstddev <json_array>


Description

Get the population standard deviation of a series (divided by n)

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat pstddev "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
2
Population standard deviation (n)
admin
stat pstddev "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
0.69
All the population of the values
admin
stat pstddev "[1, 2, 3, 4, 5]"
mentdb
1.4142135623730951
Constant values: 0
admin
stat pstddev "[7, 7, 7]"
mentdb
0

stat pvariance <json_array>


Description

Get the population variance of a series (divided by n)

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat pvariance "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
4
Population variance (n)
admin
stat pvariance "[1, 2, 3, 4]"
mentdb
1.25
Population variance of the measures
admin
stat pvariance "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
0.47609999999999986
Constant values: 0
admin
stat pvariance "[3, 3, 3]"
mentdb
0

stat quartiles <json_array>


Description

Get the quartiles [Q1, median, Q3] of a series (R7 method)

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat quartiles "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
[4,4.5,5.5]
Quartiles of 10 measurements
admin
stat quartiles "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
[11.75,12.149999999999999,12.725000000000001]
Odd number of values
admin
stat quartiles "[1, 2, 3, 4, 5, 6, 7]"
mentdb
[2.5,4,5.5]
With an outlier
admin
stat quartiles "[10, 11, 12, 13, 14, 15, 100]"
mentdb
[11.5,13,14.5]

stat range <json_array>


Description

Get the range (max - min) of a series

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat range "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
7
max - min
admin
stat range "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
2.299999999999999
Negative values
admin
stat range "[-3, 5, 2]"
mentdb
8
Constant values: 0
admin
stat range "[4, 4]"
mentdb
0

stat stddev <json_array>


Description

Get the sample standard deviation of a series (divided by n-1)

Parameters

json_array: A JSON array of numbers - String - required

Examples (5)
admin
stat stddev "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
2.138089935299395
Sample standard deviation (n - 1) of measurements
admin
stat stddev "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
0.7273238618387271
Sample standard deviation (n - 1)
admin
stat stddev "[1, 2, 3, 4, 5]"
mentdb
1.5811388300841898
Repeated measures of g
admin
stat stddev "[9.78, 9.82, 9.80, 9.81, 9.79]"
mentdb
0.015811388300842402
Standard error of the mean: s / sqrt(n)
admin
-> "[s]" (stat stddev "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"); math calc "[s]/sqrt(10)"
mentdb
0.22999999999999995

stat sum <json_array>


Description

Get the sum of a series

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat sum "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
40
Sum of decimals (compensated)
admin
stat sum "[0.1, 0.2, 0.3]"
mentdb
0.6000000000000001
Negative values
admin
stat sum "[10, -4, -6]"
mentdb
0
Sum of a computed series
admin
stat sum (stat zscore "[1, 2, 3]")
mentdb
0

stat sum_sq <json_array>


Description

Get the sum of the squares of a series

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat sum_sq "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
232
Sum of the squares
admin
stat sum_sq "[1, 2, 3]"
mentdb
14
Sum of the squares of the residuals
admin
stat sum_sq "[0.1, -0.2, 0.15, -0.05]"
mentdb
0.07500000000000001
Energy of a signal
admin
stat sum_sq "[0, 1, 0, -1]"
mentdb
2

stat summary <json_array>


Description

Get the one-variable statistics of a series as a JSON object:
n, sum, sum_sq, mean, min, q1, median, q3, max, range, variance, stddev (sample, n-1), pvariance, pstddev (population, n)

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat summary "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
{ "n": 8, "sum": 40, "sum_sq": 232, "mean": 5, "min": 2, "q1": 4, "median": 4.5, "q3": 5.5, "max": 9, "range": 7, "variance": 4.571428571428571, "stddev": 2.138089935299395, "pvariance": 4, "pstddev": 2 }
All the usual statistics at once
admin
stat summary "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
{ "n": 10, "sum": 121.70000000000002, "sum_sq": 1485.85, "mean": 12.17, "min": 10.9, "q1": 11.75, "median": 12.149999999999999, "q3": 12.725000000000001, "max": 13.2, "range": 2.299999999999999, "variance": 0.5289999999999998, "stddev": 0.7273238618387271, "pvariance": 0.47609999999999986, "pstddev": 0.69 }
Repeated measures of g
admin
stat summary "[9.78, 9.82, 9.80, 9.81, 9.79]"
mentdb
{ "n": 5, "sum": 49, "sum_sq": 480.201, "mean": 9.8, "min": 9.78, "q1": 9.79, "median": 9.8, "q3": 9.81, "max": 9.82, "range": 0.040000000000000924, "variance": 2.50000000000016E-4, "stddev": 0.015811388300842402, "pvariance": 2.000000000000128E-4, "pstddev": 0.014142135623731403 }
With an outlier
admin
stat summary "[10, 11, 12, 13, 14, 15, 100]"
mentdb
{ "n": 7, "sum": 175, "sum_sq": 10955, "mean": 25, "min": 10, "q1": 11.5, "median": 13, "q3": 14.5, "max": 100, "range": 90, "variance": 1096.6666666666667, "stddev": 33.115957885386116, "pvariance": 940, "pstddev": 30.659419433511783 }

stat variance <json_array>


Description

Get the sample variance of a series (divided by n-1)

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat variance "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
4.571428571428571
Sample variance (n - 1)
admin
stat variance "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
0.5289999999999998
Sample variance (n - 1)
admin
stat variance "[1, 2, 3, 4, 5]"
mentdb
2.5
Two values
admin
stat variance "[10, 12]"
mentdb
2

stat chi2_independence <json_matrix>


Description

Chi-square test of independence on a contingency table (integer counts, at least 2x2, no continuity correction).
Returns {chi2, df, p_value}.

Parameters

json_matrix: The contingency table: JSON array of rows of counts - String - required

Examples (4)
admin
stat chi2_independence "[[10, 20, 30], [20, 25, 15]]"
mentdb
{"chi2": 8.88888888888889, "df": 2, "p_value": 0.011743628457021371}
Treatment / outcome table
admin
stat chi2_independence "[[30, 10], [20, 25]]"
mentdb
{"chi2": 8.16269841269841, "df": 1, "p_value": 0.0042760703036015535}
Treatment and recovery: is there a link?
admin
stat chi2_independence "[[45, 15], [30, 30]]"
mentdb
{"chi2": 8, "df": 1, "p_value": 0.004677734981047288}
Table 3 x 3
admin
stat chi2_independence "[[20, 15, 25], [30, 20, 10], [10, 25, 20]]"
mentdb
{"chi2": 18.61082415059688, "df": 4, "p_value": 9.370790878890922E-4}

stat chi2_test <json_observed> <json_expected>


Description

Chi-square goodness of fit test: observed counts against expected values (the expected values are rescaled to the observed total).
Returns {chi2, df, p_value}.

Parameters

json_observed: The observed counts (integers) - String - required
json_expected: The expected values (or proportions) - String - required

Examples (4)
admin
stat chi2_test "[18, 22, 20, 25, 15]" "[20, 20, 20, 20, 20]"
mentdb
{"chi2": 2.9, "df": 4, "p_value": 0.5746972058298043}
Is a die fair? (60 throws)
admin
stat chi2_test "[8, 12, 9, 11, 14, 6]" "[10, 10, 10, 10, 10, 10]"
mentdb
{"chi2": 4.2, "df": 5, "p_value": 0.5209949534314053}
Is a dice fair? 120 throws
admin
stat chi2_test "[25, 17, 15, 23, 24, 16]" "[20, 20, 20, 20, 20, 20]"
mentdb
{"chi2": 5, "df": 5, "p_value": 0.415880186995508}
Mendel: 315, 108, 101, 32 for the ratio 9:3:3:1
admin
stat chi2_test "[315, 108, 101, 32]" "[312.75, 104.25, 104.25, 34.75]"
mentdb
{"chi2": 0.4700239808153477, "df": 3, "p_value": 0.925425895103616}

stat conf_interval_mean <json_array> <level>


Description

Confidence interval of the mean (Student law, unknown standard deviation).
Returns {mean, lower, upper, margin, level, df}.

Parameters

json_array: A JSON array of numbers - String - required
level: The confidence level in ]0, 1[ (0.95) or a percentage in [50, 100[ (95) - Number - required

Examples (4)
admin
stat conf_interval_mean "[5.1, 4.9, 5.6, 5.8, 6.0, 5.4, 5.2, 5.7]" 0.95
mentdb
{"mean": 5.4625, "lower": 5.146711346065609, "upper": 5.778288653934392, "margin": 0.3157886539343913, "level": 0.95, "df": 7}
95 % interval of the mean of 10 measurements
admin
stat conf_interval_mean "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]" 0.95
mentdb
{"mean": 12.17, "lower": 11.649703852556405, "upper": 12.690296147443595, "margin": 0.5202961474435949, "level": 0.95, "df": 9}
99 % level: a wider interval
admin
stat conf_interval_mean "[5.1, 4.9, 5.6, 5.8, 6.0, 5.4, 5.2, 5.7]" 0.99
mentdb
{"mean": 5.4625, "lower": 4.995154239167843, "upper": 5.9298457608321575, "margin": 0.46734576083215706, "level": 0.99, "df": 7}
90 % level
admin
stat conf_interval_mean "[9.78, 9.82, 9.80, 9.81, 9.79]" 0.90
mentdb
{"mean": 9.8, "lower": 9.784925566812033, "upper": 9.815074433187968, "margin": 0.01507443318796769, "level": 0.9, "df": 4}

stat dist_random <law> <json_params> <n>


Description

Draw n random values of a law (JSON array). Same laws and parameters as 'stat dist_cdf'.

Parameters

law: The law (normal, student, chi2, fisher, exponential, uniform, gamma, beta, lognormal, weibull, cauchy, laplace, logistic, pareto, triangular, binomial, poisson, geometric, hypergeometric, pascal, uniform_int) - String - required
json_params: The parameters of the law (JSON array) - String - required
n: The number of values (1 to 1000000) - Number - required

Examples (6)
admin
stat dist_random "normal" "[0, 1]" 3
mentdb
[0.43389517929714977,-0.3968890255643995,-1.1688601152517328]
admin
stat dist_random "poisson" "[3]" 5
mentdb
[2,1,3,0,2]
5 values of a uniform law on [0, 1] (random)
admin
stat dist_random "uniform" "[0, 1]" 5
mentdb
[0.1609007472368711,0.6428352269312101,0.5003659854166909,0.16015177261545666,0.40468077796262114]
Throws of a dice (uniform integers 1 to 6)
admin
stat dist_random "uniform_int" "[1, 6]" 10
mentdb
[5,4,1,2,6,1,4,2,3,5]
Exponential waiting times of mean 2 (rate 0.5)
admin
stat dist_random "exponential" "[0.5]" 4
mentdb
[1.145528851983407,4.248327477189295,0.26257310722959826,0.7642046207439437]
Mean of 10000 normal values: close to 50
admin
stat mean (stat dist_random "normal" "[50, 10]" 10000)
mentdb
49.965155724018054

stat fit <json_x> <json_y> <model>


Description

Fit a model y = f(x) by least squares, like the regression models of scientific calculators.
Models: linear (y = a+b*x), exp (y = a*exp(b*x)), log (y = a+b*ln(x)), power (y = a*x^b), logistic (y = c/(1+a*exp(-b*x))).
exp, log and power are fitted on the linearized values; logistic uses the Levenberg-Marquardt method.
Returns {model, formula, a, b, (c), r2, expression}: 'expression' can be used directly with 'math eval' and the 'num' functions (variable x).
The polynomial regressions are in 'pa polynomial_curve_fit_get_coeff'.

Parameters

json_x: The x values - String - required
json_y: The y values - String - required
model: linear, exp, log, power or logistic - String - required

Examples (6)
admin
stat fit "[1, 2, 3, 4, 5, 6]" "[3, 12, 27, 48, 75, 108]" "power"
mentdb
{"model": "power", "formula": "y = a*x^b", "a": 3.0000000000000004, "b": 2, "r2": 1, "expression": "3.0000000000000004*x^2.0"}
Linear model y = a + b x
admin
stat fit "[1, 2, 3, 4, 5]" "[2.1, 3.9, 6.2, 7.8, 10.1]" "linear"
mentdb
{"model": "linear", "formula": "y = a+b*x", "a": 0.05000000000000071, "b": 1.9899999999999998, "r2": 0.9973053289009771, "expression": "0.05000000000000071+1.9899999999999998*x"}
Exponential model
admin
stat fit "[0, 1, 2, 3, 4]" "[1.0, 2.7, 7.4, 20.1, 54.6]" "exp"
mentdb
{"model": "exp", "formula": "y = a*exp(b*x)", "a": 0.9975928345764608, "b": 1.0007535807556465, "r2": 0.9999990984904544, "expression": "0.9975928345764608*exp(1.0007535807556465*x)"}
Logarithmic model y = a + b ln(x)
admin
stat fit "[1, 2, 4, 8, 16]" "[1.0, 1.7, 2.4, 3.1, 3.8]" "log"
mentdb
{"model": "log", "formula": "y = a+b*ln(x)", "a": 1, "b": 1.0098865286222745, "r2": 1, "expression": "1.0+1.0098865286222745*ln(x)"}
Logistic growth (Levenberg-Marquardt)
admin
stat fit "[0, 1, 2, 3, 4, 5, 6, 7, 8]" "[2, 4, 8, 15, 27, 42, 56, 65, 70]" "logistic"
mentdb
{"model": "logistic", "formula": "y = c/(1+a*exp(-b*x))", "a": 43.907659405298716, "b": 0.8046394876205588, "c": 75.15219441627082, "r2": 0.9998831679236858, "expression": "75.15219441627082/(1+43.907659405298716*exp(-0.8046394876205588*x))"}
Unknown model: error
admin
stat fit "[1, 2, 3]" "[1, 2, 3]" "cubic"
mentdb
Sorry, an error appears (unknown model 'cubic' (linear, exp, log, power, logistic)).

stat fit_model <expression> <variable> <json_x> <json_y> <json_init>


Description

Fit any model y = f(x, parameters) by non-linear least squares (Levenberg-Marquardt, exact derivatives), like curve_fit in Python or nlinfit in MATLAB.
- the model is an expression (see 'math eval'); the parameters are the keys of the initial values: {"a": 1, "tau": 2}
- the initial values must be close enough to the solution (as with every non-linear fit)
- without uncertainties, the errors of the parameters are scaled by chi2_red (same as curve_fit, absolute_sigma=False)
- with the uncertainties of the y values (next signature), the points are weighted by 1/sigma^2 and the errors are absolute
Returns {parameters, errors (standard deviations), chi2, dof, chi2_red, r2, residual_std, weighted, iterations, covariance, residuals, expression}: 'expression' is the fitted model, usable with 'math eval' and the 'num' functions.
The fixed models (linear, exp, log, power, logistic) are also in 'stat fit'.

Parameters

expression: The model, ex: a*exp(-x/tau)+c - String - required
variable: The name of the variable, ex: x - String - required
json_x: The x values - String - required
json_y: The y values - String - required
json_init: The parameters and their initial values (JSON object) - String - required

Examples (6)
admin
stat fit_model "a+b*t" "t" "[1, 2, 3, 4, 5]" "[2.1, 3.9, 6.2, 7.8, 10.1]" "{\"a\": 0, \"b\": 1}"
mentdb
{"parameters": {"a": 0.05000000000000051, "b": 1.99}, "errors": {"a": 0.19807406022327453, "b": 0.05972157622389643}, "chi2": 0.10699999999999986, "dof": 3, "chi2_red": 0.03566666666666662, "r2": 0.9973053289009771, "residual_std": 0.18885620632287045, "weighted": false, "iterations": 2, "covariance": [[0.03923333333333339, -0.010700000000000022], [-0.010700000000000013, 0.0035666666666666707]], "residuals": [0.05999999999999961, -0.13000000000000034, 0.17999999999999972, -0.20999999999999996, 0.09999999999999964], "expression": "(0.05000000000000051)+(1.99)*t"}
Damped oscillation
admin
stat fit_model "A*exp(-k*t)*cos(w*t)" "t" "[0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4]" "[2.00, 0.27, -1.33, -0.57, 0.83, 0.62, -0.46, -0.55, 0.21]" "{\"A\": 2, \"k\": 0.3, \"w\": 3}"
mentdb
{"parameters": {"A": 1.9873735008227056, "k": 0.3277697765554875, "w": 2.83303189321234}, "errors": {"A": 0.022757288479793334, "k": 0.008612851656811629, "w": 0.006278237666887509}, "chi2": 0.003726531973565361, "dof": 6, "chi2_red": 6.210886622608935E-4, "r2": 0.999514938696071, "residual_std": 0.02492165047224789, "weighted": false, "iterations": 6, "covariance": [[5.178941789525344E-4, 1.2275665793313724E-4, 2.5147046759584254E-6], [1.2275665793313724E-4, 7.418121366224283E-5, 2.2059028106694717E-6], [2.514704675958396E-6, 2.205902810669463E-6, 3.941626820192511E-5]], "residuals": [0.012626499177294415, 0.010766188245131314, 0.03433088042852539, -0.02728679573119308, -0.01145634128232731 ...
Michaelis-Menten kinetics
admin
stat fit_model "Vmax*S/(Km+S)" "S" "[0.5, 1, 2, 4, 8, 16]" "[0.9, 1.5, 2.3, 3.0, 3.5, 3.8]" "{\"Vmax\": 4, \"Km\": 1}"
mentdb
{"parameters": {"Vmax": 4.260682411302756, "Km": 1.7648909000345514}, "errors": {"Vmax": 0.05110228389191506, "Km": 0.07029301159124195}, "chi2": 0.008066192490507823, "dof": 4, "chi2_red": 0.002016548122626956, "r2": 0.9987666372338673, "residual_std": 0.044905992057040184, "weighted": false, "iterations": 6, "covariance": [[0.0026114434189698815, 0.0029657189005172797], [0.0029657189005172805, 0.004941107478566475]], "residuals": [-0.04059329993284866, -0.040994768093566725, 0.03662370335158682, 0.043703004837631454, 0.009386572839083396, -0.037395848049453395], "expression": "(4.260682411302756)*S/((1.7648909000345514)+S)"}
Gaussian peak: position, width and height
admin
stat fit_model "A*exp(-(x-m)^2/(2*s^2))" "x" "[0, 1, 2, 3, 4, 5, 6]" "[0.1, 0.6, 2.1, 3.9, 2.0, 0.7, 0.1]" "{\"A\": 4, \"m\": 3, \"s\": 1}"
mentdb
{"parameters": {"A": 3.75102120633222, "m": 2.989260523864297, "s": 0.9750509057311556}, "errors": {"A": 0.1907866386780686, "m": 0.05763393681525877, "s": 0.056886426683305104}, "chi2": 0.16940849087554466, "dof": 4, "chi2_red": 0.042352122718886165, "r2": 0.9853922217771764, "residual_std": 0.2057963136669026, "weighted": false, "iterations": 8, "covariance": [[0.03639954149807591, -4.06555389502824E-6, -0.00620495674191032], [-4.06555389502824E-6, 0.00332167067282524, 1.8886307735322947E-6], [-0.006204956741910323, 1.888630773532295E-6, 0.003236065540795047]], "residuals": [0.06586314809990608, 0.13191233674513592, -0.14195606696289342, 0.14920631282314067, -0.191873219454624, 0.252591881 ...
Charge of a capacitor U(t) = U0 (1 - exp(-t/tau))
admin
stat fit_model "U0*(1-exp(-t/tau))" "t" "[0, 1, 2, 3, 4, 5]" "[0, 3.9, 6.3, 7.8, 8.6, 9.2]" "{\"U0\": 10, \"tau\": 2}"
mentdb
{"parameters": {"U0": 10.032932815978299, "tau": 2.022109113935762}, "errors": {"U0": 0.052660262114298674, "tau": 0.025893288439643856}, "chi2": 0.004247737477232793, "dof": 4, "chi2_red": 0.0010619343693081982, "r2": 0.9999300592072904, "residual_std": 0.03258733449222563, "weighted": false, "iterations": 3, "covariance": [[0.0027731032059466402, 0.0012641273245561039], [0.0012641273245561021, 6.704623862185942E-4]], "residuals": [0, -0.01429306717989176, -0.0014464139211618487, 0.042734871675928154, -0.04510424938387558, 0.013442136175164876], "expression": "(10.032932815978299)*(1-exp(-t/(2.022109113935762)))"}
Polynomial of degree 2
admin
stat fit_model "a+b*x+c*x^2" "x" "[0, 1, 2, 3, 4]" "[1.1, 2.9, 7.2, 13.1, 20.8]" "{\"a\": 0, \"b\": 0, \"c\": 1}"
mentdb
{"parameters": {"a": 1.014285714285715, "b": 1.1314285714285703, "c": 0.9571428571428575}, "errors": {"a": 0.17133330686359996, "b": 0.20295772154489275, "c": 0.04865538961693271}, "chi2": 0.06628571428571402, "dof": 2, "chi2_red": 0.03314285714285701, "r2": 0.9997439796596254, "residual_std": 0.18205179796655954, "weighted": false, "iterations": 2, "covariance": [[0.029355102040816507, -0.025567346938776006, 0.00473469387755114], [-0.025567346938775666, 0.04119183673469422, -0.00946938775510212], [0.00473469387755105, -0.009469387755102098, 0.0023673469387755232]], "residuals": [0.08571428571428519, -0.2028571428571424, 0.0942857142857143, 0.07714285714285651, -0.05428571428571516], "expres ...

stat fit_model <expression> <variable> <json_x> <json_y> <json_init> <json_sigma>


Description

Fit a model with the uncertainties of the y values (weighted least squares). See 'stat fit_model expression variable json_x json_y json_init'.

Parameters

expression: The model, ex: a*exp(-x/tau)+c - String - required
variable: The name of the variable, ex: x - String - required
json_x: The x values - String - required
json_y: The y values - String - required
json_init: The parameters and their initial values (JSON object) - String - required
json_sigma: The uncertainties of the y values (strictly positive) - String - required

Examples (2)
admin
stat fit_model "a*exp(-x/tau)" "x" "[0, 1, 2, 3, 4]" "[10.2, 6.1, 3.6, 2.3, 1.3]" "{\"a\": 10, \"tau\": 2}" "[0.5, 0.3, 0.2, 0.2, 0.1]"
mentdb
{"parameters": {"a": 10.173783383051592, "tau": 1.954460970547442}, "errors": {"a": 0.4017742126275511, "tau": 0.07691466936939888}, "chi2": 0.39376488700905327, "dof": 3, "chi2_red": 0.1312549623363511, "r2": 0.9996900884878195, "residual_std": 0.07239914854020964, "weighted": true, "iterations": 4, "covariance": [[0.16142251793248863, -0.0231074614325999], [-0.023107461432599893, 0.005915866364203946]], "residuals": [0.026216616948406823, 7.602502767598551E-4, -0.056528168918589916, 0.10789101613822893, -0.01418153372209785], "expression": "(10.173783383051592)*exp(-x/(1.954460970547442))"}
Linear model with the uncertainties of each point
admin
stat fit_model "a+b*x" "x" "[1, 2, 3, 4]" "[2.0, 4.1, 5.9, 8.2]" "{\"a\": 0, \"b\": 2}" "[0.1, 0.1, 0.2, 0.3]"
mentdb
{"parameters": {"a": -0.0052238805970147946, "b": 2.0261194029850746}, "errors": {"a": 0.1557360951843971, "b": 0.07964473354898964}, "chi2": 1.1865671641790998, "dof": 2, "chi2_red": 0.5932835820895499, "r2": 0.9979199353816123, "residual_std": 0.1472571684051131, "weighted": true, "iterations": 2, "covariance": [[0.024253731343283597, -0.011268656716417918], [-0.011268656716417915, 0.006343283582089555]], "residuals": [-0.020895522388059806, 0.05298507462686519, -0.1731343283582092, 0.10074626865671554], "expression": "((-0.0052238805970147946))+(2.0261194029850746)*x"}

stat anova <json_groups>


Description

One-way analysis of variance (H0: all the groups have the same mean).
Returns {f, p_value, df_between, df_within, ss_between, ss_within, ms_between, ms_within, eta2}: eta2 is the part of the variance explained by the groups.

Parameters

json_groups: The groups: JSON array of JSON arrays of numbers - String - required

Examples (4)
admin
stat anova "[[6.1, 5.8, 6.4, 6.0], [6.9, 7.2, 6.7, 7.0], [5.5, 5.9, 5.6, 5.4]]"
mentdb
{"f": 36.9016393442623, "p_value": 4.6012665412740255E-5, "df_between": 2, "df_within": 9, "ss_between": 3.7516666666666696, "ss_within": 0.45750000000000035, "ms_between": 1.8758333333333348, "ms_within": 0.05083333333333337, "eta2": 0.8913086517521283}
Three fertilizers, yield per plot
admin
stat anova "[[20, 21, 23, 22], [25, 27, 26, 28], [21, 22, 20, 23]]"
mentdb
{"f": 20, "p_value": 4.877630889352724E-4, "df_between": 2, "df_within": 9, "ss_between": 66.66666666666667, "ss_within": 15, "ms_between": 33.333333333333336, "ms_within": 1.6666666666666667, "eta2": 0.8163265306122449}
Two groups (same as a t test with equal variances)
admin
stat anova "[[5.1, 4.9, 5.6, 5.8], [4.8, 4.7, 5.0, 5.3]]"
mentdb
{"f": 2.5945945945945907, "p_value": 0.15835480726135226, "df_between": 1, "df_within": 6, "ss_between": 0.3199999999999992, "ss_within": 0.7399999999999992, "ms_between": 0.3199999999999992, "ms_within": 0.1233333333333332, "eta2": 0.3018867924528299}
Groups with the same mean: large p
admin
stat anova "[[1, 2, 3], [2, 1, 3], [3, 2, 1]]"
mentdb
{"f": 0, "p_value": 1, "df_between": 2, "df_within": 6, "ss_between": 0, "ss_within": 6, "ms_between": 0, "ms_within": 1, "eta2": 0}

stat kruskal <json_groups>


Description

Kruskal-Wallis test (non-parametric ANOVA on the ranks, H0: the groups come from the same distribution), with the correction for ties.
Returns {h, df, p_value} (chi2 approximation).

Parameters

json_groups: The groups: JSON array of JSON arrays of numbers - String - required

Examples (4)
admin
stat kruskal "[[6.1, 5.8, 6.4, 6.0], [6.9, 7.2, 6.7, 7.0], [5.5, 5.9, 5.6, 5.4]]"
mentdb
{"h": 9.269230769230774, "df": 2, "p_value": 0.009709840874440621}
Non parametric version of the ANOVA
admin
stat kruskal "[[20, 21, 23, 22], [25, 27, 26, 28], [21, 22, 20, 23]]"
mentdb
{"h": 7.4893617021276615, "df": 2, "p_value": 0.0236431735373886}
Two groups
admin
stat kruskal "[[1.1, 2.3, 1.9, 3.2], [3.9, 4.1, 2.9, 5.0]]"
mentdb
{"h": 4.083333333333332, "df": 1, "p_value": 0.043308142810791574}
With an outlier (robust test)
admin
stat kruskal "[[10, 11, 12, 100], [13, 14, 15, 16], [17, 18, 19, 20]]"
mentdb
{"h": 4.307692307692307, "df": 2, "p_value": 0.11603700224776017}

stat mann_whitney <json_x> <json_y>


Description

Mann-Whitney U test (Wilcoxon rank-sum, non-parametric comparison of two independent samples, two-sided).
Exact distribution when one sample has at most 8 values and there is no tie, else normal approximation with the tie and continuity corrections. The p-value is computed as in SciPy (same exact or asymptotic method).
Returns {u (statistic of the first sample), p_value, method}.

Parameters

json_x: The first sample - String - required
json_y: The second sample - String - required

Examples (4)
admin
stat mann_whitney "[1.1, 2.3, 1.9, 3.2, 2.8]" "[3.9, 4.1, 2.9, 5.0, 4.4, 3.8]"
mentdb
{"u": 1, "p_value": 0.008658008658008658, "method": "exact"}
Two independent groups, non parametric
admin
stat mann_whitney "[20.1, 21.3, 19.8, 22.0, 20.7]" "[22.4, 23.1, 21.9, 24.0, 22.8]"
mentdb
{"u": 1, "p_value": 0.015873015873015872, "method": "exact"}
Same distributions: large p
admin
stat mann_whitney "[1, 3, 5, 7]" "[2, 4, 6, 8]"
mentdb
{"u": 6, "p_value": 0.6857142857142857, "method": "exact"}
Scores of two classes
admin
stat mann_whitney "[12, 15, 14, 10, 13]" "[18, 17, 16, 19, 20]"
mentdb
{"u": 0, "p_value": 0.007936507936507936, "method": "exact"}

stat wilcoxon <json_x> <json_y>


Description

Wilcoxon signed-rank test on paired values (non-parametric version of the paired t-test, two-sided). The zero differences are removed.
Exact distribution (at most 50 pairs, no tie, no zero), exact permutations (at most 13 pairs) or normal approximation. The p-value is computed as in SciPy (same exact or asymptotic method).
Returns {w (smallest rank sum), p_value, n (non-zero differences), method}.

Parameters

json_x: The first sample - String - required
json_y: The second sample - String - required

Examples (4)
admin
stat wilcoxon "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0]" "[11.2, 11.0, 12.1, 10.5, 12.0, 11.9, 11.6, 12.2]"
mentdb
{"w": 1, "p_value": 0.015625, "n": 8, "method": "permutation"}
Paired data, non parametric
admin
stat wilcoxon "[140, 152, 138, 145, 160, 149, 151]" "[135, 147, 136, 140, 151, 146, 150]"
mentdb
{"w": 0, "p_value": 0.015625, "n": 7, "method": "permutation"}
Weight before and after a diet
admin
stat wilcoxon "[82, 90, 75, 101, 88, 79, 95]" "[80, 87, 76, 97, 85, 78, 92]"
mentdb
{"w": 1.5, "p_value": 0.046875, "n": 7, "method": "permutation"}
Different sizes: error
admin
stat wilcoxon "[1, 2, 3]" "[1, 2]"
mentdb
Sorry, an error appears (the two arrays must have the same size (3 != 2)).

stat spearman <json_x> <json_y>


Description

Spearman rank correlation (monotonic relation, robust to the outliers) and its p-value (Student approximation, as SciPy).
Returns {rho, p_value}.

Parameters

json_x: The first sample - String - required
json_y: The second sample - String - required

Examples (4)
admin
stat spearman "[1, 2, 3, 4, 5, 6, 7, 8]" "[2.1, 3.9, 3.1, 5.2, 4.8, 6.9, 7.4, 6.8]"
mentdb
{"rho": 0.8809523809523809, "p_value": 0.003850320463732414}
Monotone but not linear relation: rho = 1
admin
stat spearman "[1, 2, 3, 4, 5]" "[1, 4, 9, 16, 25]"
mentdb
{"rho": 1, "p_value": 0}
Opposite ranks: -1
admin
stat spearman "[1, 2, 3, 4]" "[40, 30, 20, 10]"
mentdb
{"rho": -1, "p_value": 0}
Ranks of two judges
admin
stat spearman "[1, 2, 3, 4, 5, 6]" "[2, 1, 4, 3, 6, 5]"
mentdb
{"rho": 0.8285714285714286, "p_value": 0.041562682215743364}

stat kendall <json_x> <json_y>


Description

Kendall tau-b rank correlation (handles the ties) and its p-value: exact without tie for at most 33 pairs, else normal approximation. The p-value is computed as in SciPy (same exact or asymptotic method).
Returns {tau, p_value, method}.

Parameters

json_x: The first sample - String - required
json_y: The second sample - String - required

Examples (4)
admin
stat kendall "[1, 2, 3, 4, 5, 6, 7, 8]" "[2.1, 3.9, 3.1, 5.2, 4.8, 6.9, 7.4, 6.8]"
mentdb
{"tau": 0.7142857142857143, "p_value": 0.014136904761904764, "method": "exact"}
Rank agreement of two judges
admin
stat kendall "[1, 2, 3, 4, 5, 6]" "[2, 1, 4, 3, 6, 5]"
mentdb
{"tau": 0.6, "p_value": 0.13611111111111113, "method": "exact"}
Same order: 1
admin
stat kendall "[1, 2, 3, 4]" "[10, 20, 30, 40]"
mentdb
{"tau": 1, "p_value": 0.08333333333333333, "method": "exact"}
Opposite order: -1
admin
stat kendall "[1, 2, 3, 4]" "[4, 3, 2, 1]"
mentdb
{"tau": -1, "p_value": 0.08333333333333333, "method": "exact"}

stat ks_2 <json_x> <json_y>


Description

Two-sample Kolmogorov-Smirnov test (H0: the two samples come from the same distribution, two-sided).
Exact p-value up to 10000 values per sample, else Kolmogorov distribution. The p-value is computed as in SciPy (same exact or asymptotic method).
Returns {d, p_value, method}.

Parameters

json_x: The first sample - String - required
json_y: The second sample - String - required

Examples (4)
admin
stat ks_2 "[0.61, 0.29, 0.06, 0.59, -1.73, -0.74, 0.51, -0.56, 0.39, 1.64]" "[1.37, 2.14, 1.28, 0.98, 1.92, 0.71, 1.55, 2.38, 1.13, 0.89]"
mentdb
{"d": 0.9, "p_value": 2.1650176448928526E-4, "method": "exact"}
Two samples from the same law?
admin
stat ks_2 "[1.2, 3.4, 2.2, 5.1, 4.4, 3.3]" "[2.1, 6.2, 5.5, 7.0, 6.1, 5.9]"
mentdb
{"d": 0.8333333333333334, "p_value": 0.02597402597402587, "method": "exact"}
Same values: D = 0
admin
stat ks_2 "[1, 2, 3, 4, 5]" "[1, 2, 3, 4, 5]"
mentdb
{"d": 0, "p_value": 1, "method": "exact"}
Different scales
admin
stat ks_2 "[0.1, 0.2, 0.3, 0.4, 0.5, 0.6]" "[1, 2, 3, 4, 5, 6]"
mentdb
{"d": 1, "p_value": 0.0021645021645021467, "method": "exact"}

stat ks_test <json_array> <law> <json_params>


Description

One-sample Kolmogorov-Smirnov test (H0: the values follow the continuous law, two-sided). Same laws and parameters as 'stat dist_cdf' (continuous laws only).
The p-value is exact (Marsaglia-Tsang-Wang), as SciPy.
Returns {d, p_value}.

Parameters

json_array: The values - String - required
law: The law (normal, exponential, gamma...) - String - required
json_params: The parameters of the law (JSON array) - String - required

Examples (4)
admin
stat ks_test "[0.61, 0.29, 0.06, 0.59, -1.73, -0.74, 0.51, -0.56, 0.39, 1.64]" "normal" "[0, 1]"
mentdb
{"d": 0.22392218265410685, "p_value": 0.6213477926899835}
Are the values uniform on [0, 1]?
admin
stat ks_test "[0.12, 0.45, 0.67, 0.23, 0.89, 0.34, 0.56, 0.78, 0.91, 0.05]" "uniform" "[0, 1]"
mentdb
{"d": 0.08999999999999997, "p_value": 0.9999610360566907}
Do the waiting times follow an exponential law of rate 0.5?
admin
stat ks_test "[0.3, 1.2, 2.5, 0.8, 4.1, 1.9, 0.5, 3.3, 1.1, 2.2]" "exponential" "[0.5]"
mentdb
{"d": 0.1392920235749422, "p_value": 0.9755058034266685}
Normal law with a mean and a standard deviation
admin
stat ks_test "[98, 105, 101, 95, 110, 99, 103, 97, 102, 100]" "normal" "[100, 5]"
mentdb
{"d": 0.17425311775007354, "p_value": 0.8725437815128095}

stat shapiro <json_array>


Description

Shapiro-Wilk normality test (H0: the values follow a normal law), Royston algorithm (AS R94) as SciPy and R. From 3 to 5000 values.
Returns {w, p_value}: a small p-value (&lt; 0.05) means that the values are not normal.

Parameters

json_array: The values - String - required

Examples (4)
admin
stat shapiro "[2.1, 2.5, 2.2, 2.8, 3.1, 2.4, 2.6, 2.9, 2.3, 2.7]"
mentdb
{"w": 0.9808779657774109, "p_value": 0.9696925844265921}
Normality of 10 measurements
admin
stat shapiro "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
{"w": 0.9793843413590454, "p_value": 0.9617881410768994}
Strongly skewed values: small p
admin
stat shapiro "[1, 1, 1, 2, 2, 3, 5, 9, 15, 30]"
mentdb
{"w": 0.7046020394649697, "p_value": 0.001001641336256148}
Uniform values
admin
stat shapiro "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
mentdb
{"w": 0.9701646112306656, "p_value": 0.8923673075239196}

stat fisher_exact <json_table>


Description

Fisher exact test on a 2x2 table of counts [[a, b], [c, d]] (two-sided), used instead of the chi2 test when the counts are small.
Returns {odds_ratio (a*d/(b*c)), p_value}.

Parameters

json_table: The 2x2 table of counts - String - required

Examples (4)
admin
stat fisher_exact "[[8, 2], [1, 5]]"
mentdb
{"odds_ratio": 20, "p_value": 0.034965034965034954}
Small table: exact test
admin
stat fisher_exact "[[3, 1], [1, 3]]"
mentdb
{"odds_ratio": 9, "p_value": 0.48571428571428593}
Tea tasting (Fisher): 4 cups of each kind
admin
stat fisher_exact "[[4, 0], [0, 4]]"
mentdb
{"odds_ratio": "Infinity", "p_value": 0.028571428571428588}
No association
admin
stat fisher_exact "[[5, 5], [5, 5]]"
mentdb
{"odds_ratio": 1, "p_value": 1}

stat frequency <json_array>


Description

Frequency table of the values (sorted): count, frequency, cumulative count, cumulative frequency

Parameters

json_array: A JSON array of numbers - String - required

Examples (3)
admin
stat frequency "[1, 2, 2, 3, 3, 3]"
mentdb
[ {"value": 1, "count": 1, "frequency": 0.16666666666666666, "cumulative_count": 1, "cumulative_frequency": 0.16666666666666666}, {"value": 2, "count": 2, "frequency": 0.3333333333333333, "cumulative_count": 3, "cumulative_frequency": 0.5}, {"value": 3, "count": 3, "frequency": 0.5, "cumulative_count": 6, "cumulative_frequency": 1} ]
Counts of the results of a die
admin
stat frequency "[3, 6, 1, 3, 3, 6, 2, 5, 3, 1]"
mentdb
[ {"value": 1, "count": 2, "frequency": 0.2, "cumulative_count": 2, "cumulative_frequency": 0.2}, {"value": 2, "count": 1, "frequency": 0.1, "cumulative_count": 3, "cumulative_frequency": 0.3}, {"value": 3, "count": 4, "frequency": 0.4, "cumulative_count": 7, "cumulative_frequency": 0.7}, {"value": 5, "count": 1, "frequency": 0.1, "cumulative_count": 8, "cumulative_frequency": 0.8}, {"value": 6, "count": 2, "frequency": 0.2, "cumulative_count": 10, "cumulative_frequency": 1} ]
Decimal values
admin
stat frequency "[0.5, 1.5, 0.5]"
mentdb
[ {"value": 0.5, "count": 2, "frequency": 0.6666666666666666, "cumulative_count": 2, "cumulative_frequency": 0.6666666666666666}, {"value": 1.5, "count": 1, "frequency": 0.3333333333333333, "cumulative_count": 3, "cumulative_frequency": 1} ]

stat geo_mean <json_array>


Description

Get the geometric mean (strictly positive values)

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat geo_mean "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
4.603215596046737
Average growth of 10 %, 20 %, -5 %
admin
stat geo_mean "[1.10, 1.20, 0.95]"
mentdb
1.078365153390936
Geometric mean of 2 and 8 = 4
admin
stat geo_mean "[2, 8]"
mentdb
4
Negative value: error
admin
stat geo_mean "[-1, 4]"
mentdb
Sorry, an error appears (the geometric mean needs strictly positive values (index 0: -1)).

stat harm_mean <json_array>


Description

Get the harmonic mean (strictly positive values)

Parameters

json_array: A JSON array of numbers - String - required

Examples (3)
admin
stat harm_mean "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
4.201750729470613
Average speed of a round trip at 60 and 40 km/h
admin
stat harm_mean "[60, 40]"
mentdb
47.99999999999999
Resistors in parallel: R = harm_mean / n
admin
-> "[h]" (stat harm_mean "[100, 220, 470]"); math calc "[h]/3"
mentdb
59.97679814385151

stat histogram <json_array> <nb_classes>


Description

Count the values in classes of equal width between the minimum and the maximum (the last class includes the maximum)

Parameters

json_array: A JSON array of numbers - String - required
nb_classes: The number of classes (1 to 10000) - Number - required

Examples (4)
admin
stat histogram "[2, 4, 4, 4, 5, 5, 7, 9]" 3
mentdb
[ {"from": 2, "to": 4.333333333333334, "count": 4}, {"from": 4.333333333333334, "to": 6.666666666666667, "count": 2}, {"from": 6.666666666666667, "to": 9, "count": 2} ]
Classes of 10 measurements
admin
stat histogram "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]" 4
mentdb
[ {"from": 10.9, "to": 11.475, "count": 2}, {"from": 11.475, "to": 12.05, "count": 2}, {"from": 12.05, "to": 12.625, "count": 3}, {"from": 12.625, "to": 13.2, "count": 3} ]
One class
admin
stat histogram "[1, 2, 3]" 1
mentdb
[ {"from": 1, "to": 3, "count": 3} ]
Histogram of 1000 random normal values (the result changes each time)
admin
stat histogram (stat dist_random "normal" "[0, 1]" 1000) 5
mentdb
[ {"from": -2.7643164836927783, "to": -1.5700866806771514, "count": 73}, {"from": -1.5700866806771514, "to": -0.37585687766152454, "count": 276}, {"from": -0.37585687766152454, "to": 0.8183729253541023, "count": 441}, {"from": 0.8183729253541023, "to": 2.012602728369729, "count": 184}, {"from": 2.012602728369729, "to": 3.2068325313853556, "count": 26} ]

stat kurtosis <json_array>


Description

Get the sample excess kurtosis (0 for a normal law, like Excel KURT). At least 4 values.

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat kurtosis "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
0.940624999999998
Excess kurtosis of 10 measurements
admin
stat kurtosis "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
-0.6139183458089583
Heavy tails (an outlier): large kurtosis
admin
stat kurtosis "[10, 11, 12, 11, 10, 12, 11, 40]"
mentdb
7.870695545464381
Uniform values: negative excess
admin
stat kurtosis "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
mentdb
-1.2000000000000002

stat skewness <json_array>


Description

Get the sample skewness (adjusted Fisher-Pearson coefficient, like Excel SKEW). At least 3 values.

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat skewness "[2, 4, 4, 4, 5, 5, 7, 9]"
mentdb
0.8184875533567997
Skewed to the right
admin
stat skewness "[1, 1, 2, 2, 2, 3, 3, 9, 15]"
mentdb
1.932888123470467
Symmetric values: 0
admin
stat skewness "[1, 2, 3, 4, 5]"
mentdb
0
Tail on the left: negative
admin
stat skewness "[1, 8, 9, 9, 10, 10, 10]"
mentdb
-2.3668929480752556

stat ttest_1 <json_array> <mu>


Description

One-sample Student t-test, H0: mean = mu (two-sided).
Returns {t, df, p_value}.

Parameters

json_array: A JSON array of numbers - String - required
mu: The mean under H0 - Number - required

Examples (4)
admin
stat ttest_1 "[5.1, 4.9, 5.6, 5.8, 6.0, 5.4, 5.2, 5.7]" 5
mentdb
{"t": 3.46319825850646, "df": 7, "p_value": 0.010502026572664006}
Is the mean equal to 12?
admin
stat ttest_1 "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]" 12
mentdb
{"t": 0.7391304347826085, "df": 9, "p_value": 0.47866067498580556}
Is a machine filling 500 g? (8 packets)
admin
stat ttest_1 "[498, 502, 497, 495, 499, 501, 496, 494]" 500
mentdb
{"t": -2.2601124105026518, "df": 7, "p_value": 0.058321711731645}
Measures of g against 9.81
admin
stat ttest_1 "[9.78, 9.82, 9.80, 9.81, 9.79]" 9.81
mentdb
{"t": -1.4142135623730197, "df": 4, "p_value": 0.23019964108051982}

stat ttest_2 <json_array_x> <json_array_y>


Description

Two-sample Student t-test with unequal variances (Welch), H0: equal means (two-sided).
Returns {t, df (Welch-Satterthwaite), p_value}.

Parameters

json_array_x: The first sample - String - required
json_array_y: The second sample - String - required

Examples (4)
admin
stat ttest_2 "[5.1, 4.9, 5.6, 5.8, 6.0, 5.4, 5.2, 5.7]" "[4.8, 4.7, 5.0, 5.3, 5.1, 4.9, 4.6, 5.2]"
mentdb
{"t": 3.2198448535693887, "df": 12.002676704419159, "p_value": 0.007354672106819095}
Two groups (Welch, unequal variances)
admin
stat ttest_2 "[20.1, 21.3, 19.8, 22.0, 20.7]" "[22.4, 23.1, 21.9, 24.0, 22.8]"
mentdb
{"t": -3.8655211189601255, "df": 7.881657868661187, "p_value": 0.004909488538099173}
Same values: no difference
admin
stat ttest_2 "[1, 2, 3]" "[1, 2, 3]"
mentdb
{"t": 0, "df": 4, "p_value": 1}
Two groups of patients
admin
stat ttest_2 "[140, 135, 150, 142, 138, 145]" "[128, 132, 125, 130, 127, 133]"
mentdb
{"t": 4.991134744799425, "df": 7.9858219568581505, "p_value": 0.0010702030944247062}

stat ttest_paired <json_array_x> <json_array_y>


Description

Paired Student t-test, H0: mean of the differences = 0 (two-sided).
Returns {t, df, p_value}.

Parameters

json_array_x: The first series - String - required
json_array_y: The second series (same size) - String - required

Examples (4)
admin
stat ttest_paired "[5.1, 4.9, 5.6, 5.8, 6.0, 5.4, 5.2, 5.7]" "[4.8, 4.7, 5.0, 5.3, 5.1, 4.9, 4.6, 5.2]"
mentdb
{"t": 6.9021501079997005, "df": 7, "p_value": 2.308824976294872E-4}
Before / after on the same subjects
admin
stat ttest_paired "[140, 152, 138, 145, 160, 149]" "[135, 147, 136, 140, 151, 146]"
mentdb
{"t": 4.930147906655832, "df": 5, "p_value": 0.004359043914153663}
Weight before and after a diet
admin
stat ttest_paired "[82, 90, 75, 101, 88, 79, 95]" "[80, 87, 76, 97, 85, 78, 92]"
mentdb
{"t": 3.3824071260127297, "df": 6, "p_value": 0.014813722759443312}
Different sizes: error
admin
stat ttest_paired "[1, 2, 3]" "[1, 2]"
mentdb
Sorry, an error appears (the two arrays must have the same size (3 != 2)).

stat weighted_mean <json_values> <json_weights>


Description

Get the weighted mean (weights >= 0)

Parameters

json_values: The values - String - required
json_weights: The weights (same size) - String - required

Examples (4)
admin
stat weighted_mean "[10, 20, 30]" "[1, 2, 3]"
mentdb
23.333333333333332
Mean of grades with coefficients
admin
stat weighted_mean "[12, 15, 9]" "[2, 3, 1]"
mentdb
13
Mean of measures weighted by 1/sigma^2
admin
stat weighted_mean "[9.79, 9.82, 9.80]" "[10000, 2500, 40000]"
mentdb
9.799047619047618
Different sizes: error
admin
stat weighted_mean "[1, 2]" "[1]"
mentdb
Sorry, an error appears (the values and the weights must have the same size (2 != 1)).

stat zscore <json_array>


Description

Standardize the values: (x - mean) / sample standard deviation

Parameters

json_array: A JSON array of numbers - String - required

Examples (4)
admin
stat zscore "[1, 2, 3, 4, 5]"
mentdb
[-1.2649110640673518,-0.6324555320336759,0,0.6324555320336759,1.2649110640673518]
Standardized measurements
admin
stat zscore "[10, 12, 14, 16, 18]"
mentdb
[-1.2649110640673518,-0.6324555320336759,0,0.6324555320336759,1.2649110640673518]
Find an outlier: |z| > 2
admin
stat zscore "[10, 11, 12, 11, 10, 12, 11, 30]"
mentdb
[-0.4992667542615898,-0.3513358641100076,-0.20340497395842547,-0.3513358641100076,-0.4992667542615898,-0.20340497395842547,-0.3513358641100076,2.459351048770053]
Measures
admin
stat zscore "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]"
mentdb
[-0.09624323313555978,-1.0586755644911527,1.4161504304232302,-1.7461272297451484,0.8661890982200355,-0.6462045653387568,0.4537180990676372,1.141169764321633,0.04124709991523886,-0.37122389923715704]

stat ztest <json_array> <mu> <sigma>


Description

z-test with a known standard deviation, H0: mean = mu (two-sided).
Returns {z, p_value}.

Parameters

json_array: A JSON array of numbers - String - required
mu: The mean under H0 - Number - required
sigma: The known standard deviation - Number - required

Examples (4)
admin
stat ztest "[5.1, 4.9, 5.6, 5.8, 6.0, 5.4, 5.2, 5.7]" 5 0.4
mentdb
{"z": 3.2703688629877847, "p_value": 0.0010740732907223746}
Known standard deviation 0.5
admin
stat ztest "[12.1, 11.4, 13.2, 10.9, 12.8, 11.7, 12.5, 13.0, 12.2, 11.9]" 12 0.5
mentdb
{"z": 1.0751744044572484, "p_value": 0.2822966525833148}
Weights of packets, sigma known = 2 g
admin
stat ztest "[498, 502, 497, 495, 499, 501, 496, 494]" 500 2
mentdb
{"z": -3.1819805153394642, "p_value": 0.0014627165866811511}
The mean is equal to mu: z = 0
admin
stat ztest "[4, 5, 6]" 5 1
mentdb
{"z": 0, "p_value": 1}
start: 2026-10-29end: 2026-10-29v_start: 421v_end: