Skip to content
Statistics

statistics-ai999x

Descriptive statistics, probability distributions, confidence intervals, hypothesis tests, regression and correlation, experimental design, quality control and reliability.

110capabilities
16topics
110formulas typeset
8worked examples below
1.0.0version
About this model

What Statistics does

Statistics (statistics-ai999x) is an offline Python package for statistics. It covers descriptive statistics, probability distributions, confidence intervals, hypothesis tests, regression and correlation, experimental design, quality control and reliability.

It has 110 capabilities — 110 computational procedures — in 16 topics, the largest being Descriptive statistics, Probability distributions, Hypothesis tests, Regression and correlation, Confidence intervals and Nonparametric tests. Ask a question in words with ask(), or call a capability by name with typed inputs with solve(). Every answer carries its value and unit, the steps that produced it and the formula in LaTeX.

When a question is not determined — a value is missing, an input is out of range, or the request is outside the package — it says so and names what it needs, instead of guessing. It runs on an ordinary CPU without a network connection (Python >=3.10), and the same question always gets the same answer.

Install

pip install statistics-ai999x
hf download AI999X/statistics-ai999x --local-dir statistics-ai999x

What it covers

Analysis of variance1One-way ANOVACategorical data2Fisher's exact test (2 x 2) · McNemar's test for paired proportionsConfidence intervals7Confidence interval for a mean (sigma known, z-interval) · Confidence interval for a mean from data (t-interval) · Confidence interval for a mean from summary statistics (t-interval) …Confidence intervals and tests4Critical value of chi-square · Critical value of F · Critical value of Student's t …Descriptive statistics22Arithmetic mean · Coefficient of variation · Five-number summary and interquartile range …Effect sizes1Cohen's d and Hedges' gExperimental design42^2 factorial design: main effects and interaction · 2^3 factorial design: main effects and interactions · Cronbach's alpha (internal consistency) …Hypothesis tests14Bartlett's test for equal variances · Chi-square goodness-of-fit test · Chi-square test for a variance …Nonparametric tests7Friedman test · Kruskal-Wallis H test · Mann-Whitney U test (exact) …Power and sample size5Power of a one-sample z-test · Power of a two-sample z-test · Sample size per group to compare two means (z-test power) …Probability1Probability of at least one occurrenceProbability distributions17Binomial probability: at least k successes · Binomial probability: at most k successes · Binomial probability: exactly k successes …Quality control6c chart limits (defects per unit) · Individuals and moving range (I-MR) chart limits · p chart limits (fraction defective) …Regression and correlation10Confidence interval for a correlation (Fisher z) · Covariance · Durbin-Watson statistic …Reliability and survival7Exponential reliability (constant failure rate) · k-out-of-n system reliability · Kaplan-Meier survival estimate …Sampling distributions2Probability that a sample mean is above a value · Probability that a sample mean is below a value
Try it

Worked examples

Each question below was put to statistics-ai999x and the answer shown is the one it returned, with the steps it took.

Hypothesis testsm.ask(…)

Perform a one-sample t-test of [5.1, 4.9, 5.3, 5.5, 5.0, 5.2] against mu0 = 5, two-sided.

t = 1.889822365
df = 5
p_value = 0.1173867951
mean = 5.166666667
standard_deviation = 0.2160246899
Show the steps
  1. One-sample t-test
    t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}},\ \nu = n - 1
    with x = [5.1, 4.9, 5.3, 5.5, 5, 5.2], mu0 = 5, alternative = two-sided
    → t = 1.889822365, df = 5, p_value = 0.1173867951, mean = 5.166666667, standard_deviation = 0.2160246899
Capability: One-sample t-test
Probability distributionsm.ask(…)

For a normal distribution with mean = 100 and standard deviation = 15, find P(X < 120).

probability = 0.9087887803
z = 1.333333333
Show the steps
  1. Normal probability below a value
    P(X < x) = \Phi\left(\frac{x - \mu}{\sigma}\right)
    with mu = 100, sigma = 15, x = 120
    → probability = 0.9087887803, z = 1.333333333
Confidence intervalsm.ask(…)

Find the 95% confidence interval for the mean of [12, 15, 11, 18, 14, 16].

lower = 11.62370216
upper = 17.0429645
margin_of_error = 2.709631171
critical_value = 2.570581836
df = 5
mean = 14.33333333
Show the steps
  1. Confidence interval for a mean from data (t-interval)
    \bar{x} \pm t_{\alpha/2,\,n-1}\frac{s}{\sqrt{n}}
    with x = [12, 15, 11, 18, 14, 16], confidence = 0.95
    → lower = 11.62370216, upper = 17.0429645, margin_of_error = 2.709631171, critical_value = 2.570581836, df = 5, mean = 14.33333333
Hypothesis testsm.ask(…)

Chi-square test of independence for the table [[20, 30], [25, 25]].

chi_square = 1.01010101
df = 1
p_value = 0.3148786413
expected = [[22.5, 27.5], [22.5, 27.5]]
Show the steps
  1. Chi-square test of independence
    \chi^2 = \sum_{i,j}\frac{(O_{ij} - E_{ij})^2}{E_{ij}},\ E_{ij} = \frac{R_i C_j}{n}
    with table = [20 30; 25 25]
    → chi_square = 1.01010101, df = 1, p_value = 0.3148786413, expected = [[22.5, 27.5], [22.5, 27.5]]
Reliability and survivalm.solve(…)
m.solve("weibull_reliability", beta=2, eta=1000, t=500)
reliability = 0.7788007831
unreliability = 0.2211992169
hazard_rate = 0.001
mttf = 886.2269255
Show the steps
  1. Weibull reliability, hazard rate and MTTF
    R(t) = e^{-(t/\eta)^\beta},\quad h(t) = \frac{\beta}{\eta}\left(\frac{t}{\eta}\right)^{\beta-1}
    with beta = 2, eta = 1000, t = 500
    → reliability = 0.7788007831, unreliability = 0.2211992169, hazard_rate = 0.001, mttf = 886.2269255
Analysis of variancem.ask(…)

Perform a one-way ANOVA on groups [23, 25, 21, 22], [30, 28, 31, 29] and [26, 27, 24, 25].

f = 22.12
p_value = 0.0003357531392
df_between = 2
df_within = 9
ss_between = 92.16666667
ss_within = 18.75
Show the steps
  1. One-way ANOVA
    F = \frac{SS_B/(k-1)}{SS_W/(N-k)}
    with g1 = [23, 25, 21, 22], g2 = [30, 28, 31, 29], g3 = [26, 27, 24, 25]
    → f = 22.12, p_value = 0.0003357531392, df_between = 2, df_within = 9, ss_between = 92.16666667, ss_within = 18.75, ms_between = 46.08333333, ms_within = 2.083333333, eta_squared = 0.8309541698
Capability: One-way ANOVA
Categorical datam.ask(…)

Fisher's exact test for the table [[8, 2], [1, 5]], two-sided.

p_value = 0.03496503497
odds_ratio = 20
Show the steps
  1. Fisher's exact test (2 x 2)
    P(a) = \frac{\binom{a+b}{a}\binom{c+d}{c}}{\binom{n}{a+c}}
    with table = [8 2; 1 5], alternative = two-sided
    → p_value = 0.03496503497, odds_ratio = 20
Confidence intervals and testsm.ask(…)

Find the chi-square critical value with df = 4 and alpha = 0.05.

critical_value = 9.487729037
left_critical_value = 0.7107230214
Show the steps
  1. Critical value of chi-square
    \chi^2_{\alpha,\nu}:\ P(\chi^2_\nu > c) = \alpha
    with df = 4, alpha = 0.05
    → critical_value = 9.487729037, left_critical_value = 0.7107230214
Use it

From Python or the command line

Every snippet was run as shown; the output under it is what it printed.

import statistics_ai999x as m

a = m.ask("Perform a one-sample t-test of [5.1, 4.9, 5.3, 5.5, 5.0, 5.2] against mu0 = 5, two-sided.")
print(a.outcome)
print(a.values)
for step in a.steps:
    print(step["name"])
Output
SOLVED
{'t': 1.88982236504614, 'df': 5, 'p_value': 0.11738679514629244, 'mean': 5.166666666666667, 'standard_deviation': 0.2160246899469286}
One-sample t-test
Figures

Computed, not drawn by hand

Every value in these figures was computed by the package, each point a run of solve(); in a notebook, plot() and plot_relation() draw a capability's curves the same way.

One-sample t test: statistic against the rejection region

t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}},\ \nu = n - 1
One-sample t test: statistic against the rejection regionThe one-sample t test of x = 5.1, 4.9, 5.3, 5.5, 5.0, 5.2 against μ₀ = 5: the t density with 5 degrees of freedom (from the package's quantiles at 121 cumulative probabilities, differenced), the two-tailed rejection region beyond ±2.57058 for α = 0.05 shaded; marked: t = 1.88982, p-value = 0.117387.-5-2.502.5500.10.20.30.4±2.57058t = 1.88982rejection region, α = 0.05t distribution, 5 degrees of freedomtdensity
The one-sample t test of x = 5.1, 4.9, 5.3, 5.5, 5.0, 5.2 against μ₀ = 5: the t density with 5 degrees of freedom (from the package's quantiles at 121 cumulative probabilities, differenced), the two-tailed rejection region beyond ±2.57058 for α = 0.05 shaded; marked: t = 1.88982, p-value = 0.117387.

Poisson distribution and an at-least probability

P(X \ge k) = 1 - \sum_{j=0}^{k-1} \frac{e^{-\lambda}\lambda^j}{j!}
Poisson distribution and an at-least probabilityThe Poisson distribution with mean λ = 4: P(X = k) for k = 0 … 14, each from the package; the stems with k ≥ 2 carry P(X ≥ 2) = 0.908422; marked: the most probable count k = 4, P = 0.195367.051000.050.10.150.2P(4) = 0.195367k < 2k ≥ 2: P = 0.908422k — number of eventsP(X = k)
The Poisson distribution with mean λ = 4: P(X = k) for k = 0 … 14, each from the package; the stems with k ≥ 2 carry P(X ≥ 2) = 0.908422; marked: the most probable count k = 4, P = 0.195367.

Three groups as box plots, with their ANOVA

F = \frac{SS_B/(k-1)}{SS_W/(N-k)}
Three groups as box plots, with their ANOVABox plots of 3 groups (g1 = 23, 25, 21, 22; g2 = 30, 28, 31, 29; g3 = 26, 27, 24, 25): each box spans the quartiles and the bar is the median, all from the package's percentiles (g1 median 22.5, quartiles 21.75–23.5; g2 median 29.5, quartiles 28.75–30.25; g3 median 25.5, quartiles 24.75–26.25). One-way ANOVA: F = 22.12 with 2 and 9 degrees of freedom, p-value 0.000335753, η² = 0.830954.12322.52527.530g1g2g3groupvalue
Box plots of 3 groups (g1 = 23, 25, 21, 22; g2 = 30, 28, 31, 29; g3 = 26, 27, 24, 25): each box spans the quartiles and the bar is the median, all from the package's percentiles (g1 median 22.5, quartiles 21.75–23.5; g2 median 29.5, quartiles 28.75–30.25; g3 median 25.5, quartiles 24.75–26.25). One-way ANOVA: F = 22.12 with 2 and 9 degrees of freedom, p-value 0.000335753, η² = 0.830954.

Simple linear regression: data and fitted line

\hat{y} = b_0 + b_1 x,\quad b_1 = \frac{S_{xy}}{S_{xx}},\quad b_0 = \bar{y} - b_1\bar{x}
Simple linear regression: data and fitted lineThe least-squares line through x = 1, 2, 3, 4, 5, y = 2.2, 4.1, 6.1, 7.9, 10.2: intercept 0.16 (standard error 0.143295), slope 1.98 (standard error 0.0432049), r = 0.999287, R² = 0.998574, p-value of the slope 2.2873e-05, as returned by the package.12345246810y = 0.16 + 1.98xdataxy
The least-squares line through x = 1, 2, 3, 4, 5, y = 2.2, 4.1, 6.1, 7.9, 10.2: intercept 0.16 (standard error 0.143295), slope 1.98 (standard error 0.0432049), r = 0.999287, R² = 0.998574, p-value of the slope 2.2873e-05, as returned by the package.

Kaplan–Meier survival curve

\hat{S}(t) = \prod_{t_i \le t}\left(1 - \frac{d_i}{n_i}\right)
Kaplan–Meier survival curveThe Kaplan–Meier survival curve returned by the package for times 6, 6, 6, 7, 10, 13, 16, 22, 23 with event indicators 1, 1, 1, 0, 1, 1, 1, 1, 1 (0 = censored): it steps down at each event time 6, 10, 13, 16, 22, 23; marked: t = 12, S = 0.533333.0102000.250.50.751S(12) = 0.533333Kaplan–Meier estimatecensoredt — timeS(t) — survival probability
The Kaplan–Meier survival curve returned by the package for times 6, 6, 6, 7, 10, 13, 16, 22, 23 with event indicators 1, 1, 1, 0, 1, 1, 1, 1, 1 (0 = censored): it steps down at each event time 6, 10, 13, 16, 22, 23; marked: t = 12, S = 0.533333.

Confidence intervals for a mean at five levels

\bar{x} \pm t_{\alpha/2,\,n-1}\frac{s}{\sqrt{n}}
Confidence intervals for a mean at five levelst confidence intervals for the mean of x = 12, 15, 11, 18, 14, 16 at 5 confidence levels, each from the package: 50 % [13.5673, 15.0993]; 80 % [12.7776, 15.8891]; 90 % [12.2093, 16.4574]; 95 % [11.6237, 17.043]; 99 % [10.0831, 18.5836] (sample mean 14.3333, 5 degrees of freedom); higher confidence, wider interval.10152050 %: [13.5673, 15.0993]80 %: [12.7776, 15.8891]90 %: [12.2093, 16.4574]95 %: [11.6237, 17.043]99 %: [10.0831, 18.5836]sample mean 14.3333μ — population mean
t confidence intervals for the mean of x = 12, 15, 11, 18, 14, 16 at 5 confidence levels, each from the package: 50 % [13.5673, 15.0993]; 80 % [12.7776, 15.8891]; 90 % [12.2093, 16.4574]; 95 % [11.6237, 17.043]; 99 % [10.0831, 18.5836] (sample mean 14.3333, 5 degrees of freedom); higher confidence, wider interval.
Formulas

The mathematics inside

12 of its 110 formulas; every one is in the capability browser below.

One-sample t-test
t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}},\ \nu = n - 1
Normal probability below a value
P(X < x) = \Phi\left(\frac{x - \mu}{\sigma}\right)
Confidence interval for a mean from data (t-interval)
\bar{x} \pm t_{\alpha/2,\,n-1}\frac{s}{\sqrt{n}}
Chi-square test of independence
\chi^2 = \sum_{i,j}\frac{(O_{ij} - E_{ij})^2}{E_{ij}},\ E_{ij} = \frac{R_i C_j}{n}
Weibull reliability, hazard rate and MTTF
R(t) = e^{-(t/\eta)^\beta},\quad h(t) = \frac{\beta}{\eta}\left(\frac{t}{\eta}\right)^{\beta-1}
One-way ANOVA
F = \frac{SS_B/(k-1)}{SS_W/(N-k)}
Fisher's exact test (2 x 2)
P(a) = \frac{\binom{a+b}{a}\binom{c+d}{c}}{\binom{n}{a+c}}
Critical value of chi-square
\chi^2_{\alpha,\nu}:\ P(\chi^2_\nu > c) = \alpha
McNemar's test for paired proportions
\chi^2 = \frac{(|b - c| - 1)^2}{b + c}
Confidence interval for a mean (sigma known, z-interval)
\bar{x} \pm z_{\alpha/2}\frac{\sigma}{\sqrt{n}}
Critical value of F
F_{\alpha;\,\nu_1,\nu_2}:\ P(F_{\nu_1,\nu_2} > c) = \alpha
Arithmetic mean
\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i
Capabilities

Every capability, with an example

Search by name, formula, input or topic. Each capability opens to show what it takes, what it returns, when it applies, and a question it answered.

110 capabilities

Analysis of variance 1

One-way ANOVAone_way_anova

One-way analysis of variance for 2 to 5 independent groups: F statistic, p-value, sums of squares and eta squared.

F = \frac{SS_B/(k-1)}{SS_W/(N-k)}

Inputs

  • g1 group 1 vector
  • g2 group 2 vector
  • g3 group 3 vector optional
  • g4 group 4 vector optional
  • g5 group 5 vector optional

Returns

  • f MS between / MS within
  • p_value upper-tail p-value
  • df_between k - 1
  • df_within N - k
  • ss_between between-group sum of squares
  • ss_within within-group sum of squares
  • ms_between mean square between
  • ms_within mean square within
  • eta_squared SSB / SST

Applies when

  • independent groups
  • roughly normal populations with equal variances

Example

m.ask("Perform a one-way ANOVA on groups [23, 25, 21, 22], [30, 28, 31, 29] and [26, 27, 24, 25].")
→ f = 22.12, p_value = 0.000335753, df_between = 2, df_within = 9, ss_between = 92.1667, ss_within = 18.75, ms_between = 46.0833, ms_within = 2.08333, eta_squared = 0.830954

Categorical data 2

Fisher's exact test (2 x 2)fisher_exact_test

Fisher's exact test of association in a 2 x 2 table, with the sample odds ratio.

P(a) = \frac{\binom{a+b}{a}\binom{c+d}{c}}{\binom{n}{a+c}}

Inputs

  • table 2 x 2 table of counts [[a, b], [c, d]] matrix
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • p_value exact p-value (two-sided: tables no more likely than the observed one)
  • odds_ratio ad/(bc); empty when b c = 0

Applies when

  • fixed margins (conditional test)
  • whole-number counts

Example

m.ask("Fisher's exact test for the table [[8, 2], [1, 5]], two-sided.")
→ p_value = 0.034965, odds_ratio = 20
McNemar's test for paired proportionsmcnemar_test

McNemar's test for a 2 x 2 table of paired outcomes: continuity-corrected chi-square and the exact binomial p-value.

\chi^2 = \frac{(|b - c| - 1)^2}{b + c}

Inputs

  • table 2 x 2 table of paired counts [[both yes, yes/no], [no/yes, both no]] matrix

Returns

  • chi_square (|b - c| - 1)^2 / (b + c)
  • p_value chi-square p-value (1 df)
  • exact_p_value exact binomial p-value
  • discordant b + c

Applies when

  • paired (matched) binary outcomes
  • b + c > 0

Example

m.ask("McNemar's test for the paired table [[30, 12], [5, 53]].")
→ chi_square = 2.11765, p_value = 0.14561, exact_p_value = 0.143463, discordant = 17

Confidence intervals 7

Confidence interval for a mean (sigma known, z-interval)ci_mean_known_sigma

The z confidence interval for a population mean when the population standard deviation sigma is known.

\bar{x} \pm z_{\alpha/2}\frac{\sigma}{\sqrt{n}}

Inputs

  • xbar sample mean
  • sigma population standard deviation (known)
  • n sample size integer
  • confidence confidence level as a fraction (0.95 for 95%)

Returns

  • lower lower limit
  • upper upper limit
  • margin_of_error z sigma / sqrt(n)
  • critical_value z critical value

Applies when

  • sigma known
  • normal population or large n
  • random sample

Example

m.ask("Find the 95% confidence interval for the mean with sample mean = 52, population standard deviation = 8 and n = 36.")
→ lower = 49.3867, upper = 54.6133, margin_of_error = 2.61329, critical_value = 1.95996
Confidence interval for a mean from data (t-interval)ci_mean_t

The t confidence interval for a population mean from sample data (sigma unknown).

\bar{x} \pm t_{\alpha/2,\,n-1}\frac{s}{\sqrt{n}}

Inputs

  • x the data values (at least two) vector
  • confidence confidence level as a fraction (0.95 for 95%)

Returns

  • lower lower limit
  • upper upper limit
  • mean sample mean
  • margin_of_error t s / sqrt(n)
  • critical_value t critical value
  • df n - 1

Applies when

  • random sample from a roughly normal population (or large n)
  • sigma unknown

Example

m.ask("Find the 95% confidence interval for the mean of [12, 15, 11, 18, 14, 16].")
→ lower = 11.6237, upper = 17.043, margin_of_error = 2.70963, critical_value = 2.57058, df = 5, mean = 14.3333
Confidence interval for a mean from summary statistics (t-interval)ci_mean_t_summary

The t confidence interval for a mean from the sample mean, sample standard deviation and n.

\bar{x} \pm t_{\alpha/2,\,n-1}\frac{s}{\sqrt{n}}

Inputs

  • xbar sample mean
  • s sample standard deviation
  • n sample size (>= 2) integer
  • confidence confidence level as a fraction (0.95 for 95%)

Returns

  • lower lower limit
  • upper upper limit
  • margin_of_error t s / sqrt(n)
  • critical_value t critical value
  • df n - 1

Applies when

  • random sample from a roughly normal population (or large n)
  • sigma unknown

Example

m.ask("Find the 95% confidence interval for the mean with sample mean = 25, sample standard deviation = 4 and n = 16.")
→ lower = 22.8686, upper = 27.1314, margin_of_error = 2.13145, critical_value = 2.13145, df = 15
Confidence interval for a proportion (Wald)ci_proportion

The large-sample (Wald) confidence interval for a population proportion from x successes in n trials.

\hat{p} \pm z_{\alpha/2}\sqrt{\frac{\hat{p}(1-\hat{p})}{n}}

Inputs

  • x number of successes integer
  • n sample size integer
  • confidence confidence level as a fraction (0.95 for 95%)

Returns

  • proportion sample proportion x/n
  • lower lower limit (clipped at 0)
  • upper upper limit (clipped at 1)
  • margin_of_error z sqrt(p(1-p)/n)

Applies when

  • 0 < x < n
  • large sample: n p and n(1 - p) at least about 10
  • limits clipped to [0, 1]

Example

m.ask("Find the 95% confidence interval for a proportion with x = 48 successes out of n = 120.")
→ proportion = 0.4, lower = 0.312348, upper = 0.487652, margin_of_error = 0.0876523
Confidence interval for a variance and standard deviationci_variance

The chi-square confidence interval for a population variance (and standard deviation) from sample data.

\left[\frac{(n-1)s^2}{\chi^2_{1-\alpha/2,\,n-1}},\ \frac{(n-1)s^2}{\chi^2_{\alpha/2,\,n-1}}\right]

Inputs

  • x the data values (at least two) vector
  • confidence confidence level as a fraction (0.95 for 95%)

Returns

  • variance sample variance
  • lower lower limit for the variance
  • upper upper limit for the variance
  • sd_lower lower limit for the standard deviation
  • sd_upper upper limit for the standard deviation

Applies when

  • normal population (the interval is sensitive to non-normality)

Example

m.ask("Find the 95% confidence interval for the population variance of [12, 15, 11, 18, 14, 16].")
→ variance = 6.66667, lower = 2.59757, upper = 40.1021, sd_lower = 1.6117, sd_upper = 6.33262
Confidence interval for the difference of two meansci_two_means

The t confidence interval for mu1 - mu2 from two independent samples (Welch or pooled variances).

(\bar{x}_1 - \bar{x}_2) \pm t_{\alpha/2,\,\nu}\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}

Inputs

  • x first sample vector
  • y second sample vector
  • confidence confidence level as a fraction (0.95 for 95%)
  • variance welch (unequal variances) or pooled (equal variances) choice

Returns

  • difference mean(x) - mean(y)
  • lower lower limit
  • upper upper limit
  • df degrees of freedom (Welch-Satterthwaite or n1 + n2 - 2)
  • standard_error standard error of the difference

Applies when

  • independent random samples
  • roughly normal populations or large samples

Example

m.ask("Find the 95% confidence interval for the difference in means of [12, 15, 11, 18, 14] and [10, 9, 13, 11, 8] using Welch.")
→ difference = 3.8, lower = 0.278295, upper = 7.3217, df = 7.17415, standard_error = 1.49666
Wilson score interval for a proportionwilson_interval

The Wilson score confidence interval for a proportion (good coverage for small n and for p near 0 or 1).

\frac{\hat{p} + \frac{z^2}{2n} \pm z\sqrt{\frac{\hat{p}(1-\hat{p})}{n} + \frac{z^2}{4n^2}}}{1 + \frac{z^2}{n}}

Inputs

  • x number of successes integer
  • n sample size integer
  • confidence confidence level as a fraction (0.95 for 95%)

Returns

  • proportion x/n
  • lower lower limit
  • upper upper limit
  • center interval centre

Applies when

  • 0 <= x <= n
  • independent trials

Example

m.ask("Find the 95% Wilson interval for x = 3 successes out of n = 20.")
→ proportion = 0.15, lower = 0.0523687, upper = 0.360419, center = 0.206394

Confidence intervals and tests 4

Critical value of chi-squarechi_square_critical_value

The right-tail chi-square critical value (P(X > c) = alpha) for given degrees of freedom, and the left-tail value (P(X < c) = alpha).

\chi^2_{\alpha,\nu}:\ P(\chi^2_\nu > c) = \alpha

Inputs

  • df degrees of freedom (> 0)
  • alpha tail area

Returns

  • critical_value right-tail critical value
  • left_critical_value left-tail critical value

Applies when

  • df > 0
  • 0 < alpha < 1

Example

m.ask("Find the chi-square critical value with df = 4 and alpha = 0.05.")
→ critical_value = 9.48773, left_critical_value = 0.710723
Critical value of Ff_critical_value

The right-tail F critical value (P(F > c) = alpha) for numerator and denominator degrees of freedom.

F_{\alpha;\,\nu_1,\nu_2}:\ P(F_{\nu_1,\nu_2} > c) = \alpha

Inputs

  • df1 numerator degrees of freedom
  • df2 denominator degrees of freedom
  • alpha tail area

Returns

  • critical_value right-tail F critical value

Applies when

  • df1, df2 > 0
  • 0 < alpha < 1

Example

m.ask("Find the F critical value with df1 = 3, df2 = 20 and alpha = 0.05.")
→ critical_value = 3.09839
Critical value of Student's tt_critical_value

The Student t critical value for given degrees of freedom and significance (or confidence) level.

t_{\alpha/2,\,\nu}:\ P(T_\nu > t) = \alpha/2

Inputs

  • df degrees of freedom (> 0)
  • alpha significance level (1 - confidence)
  • tails two-tailed, right-tailed or left-tailed choice

Returns

  • critical_value t critical value (negative for a left-tailed test)

Applies when

  • df > 0
  • 0 < alpha < 1
  • a confidence level is read as two-tailed

Example

m.ask("Find the critical t value for a 95% confidence interval with df = 10.")
→ critical_value = 2.22814
Critical value of zz_critical_value

The standard normal critical value for a significance level (or confidence level), two-tailed or one-tailed.

z_{\alpha/2} = \Phi^{-1}(1 - \alpha/2)

Inputs

  • alpha significance level (1 - confidence)
  • tails two-tailed, right-tailed or left-tailed choice

Returns

  • critical_value z critical value (negative for a left-tailed test)

Applies when

  • 0 < alpha < 1
  • a confidence level is read as two-tailed

Example

m.ask("Find the critical z value for a 95% confidence interval.")
→ critical_value = 1.95996

Descriptive statistics 22

Arithmetic meanmean

The arithmetic mean (average) of a list of numbers.

\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i

Inputs

  • x the data values vector

Returns

  • mean arithmetic mean
  • n number of values
  • sum sum of the values

Example

m.ask("Find the mean of [2, 4, 9].")
→ mean = 5, n = 3, sum = 15
Coefficient of variationcoefficient_of_variation

The coefficient of variation (sample standard deviation divided by the mean), as a ratio and a percentage.

CV = \frac{s}{\bar{x}}

Inputs

  • x the data values (at least two) vector

Returns

  • cv s / mean
  • cv_percent 100 s / mean
  • mean mean
  • standard_deviation sample standard deviation

Applies when

  • positive mean
  • sample standard deviation (n - 1)

Example

m.ask("Find the coefficient of variation of [10, 12, 14, 16, 18].")
→ cv = 0.225877, cv_percent = 22.5877, mean = 14, standard_deviation = 3.16228
Five-number summary and interquartile rangefive_number_summary

Minimum, first quartile, median, third quartile, maximum and the interquartile range of a data set.

Q_p = x_{(\lfloor h \rfloor)} + (h - \lfloor h \rfloor)\,(x_{(\lfloor h \rfloor + 1)} - x_{(\lfloor h \rfloor)}),\ h = 1 + (n-1)p

Inputs

  • x the data values (at least two) vector
  • method quantile method: linear (type 7, spreadsheet/numpy default) or weibull (type 6, p(n+1)) choice optional

Returns

  • minimum smallest value
  • q1 first quartile
  • median median
  • q3 third quartile
  • maximum largest value
  • iqr interquartile range Q3 - Q1

Applies when

  • quartiles by linear interpolation between order statistics (Hyndman-Fan type 7, as in spreadsheets and numpy) unless method = weibull (type 6, as in Minitab and SPSS); textbooks that take medians of the halves can differ

Example

m.ask("Find the five-number summary of [1, 3, 5, 7, 9, 11, 13, 15].")
→ minimum = 1, q1 = 4.5, median = 8, q3 = 11.5, maximum = 15, iqr = 7
Geometric meangeometric_mean

The geometric mean of positive numbers (average growth factors, ratios).

G = \left(\prod x_i\right)^{1/n}

Inputs

  • x positive values vector

Returns

  • geometric_mean n-th root of the product

Applies when

  • all values positive

Example

m.ask("Find the geometric mean of [2, 8].")
→ geometric_mean = 4
Harmonic meanharmonic_mean

The harmonic mean of positive numbers (average speeds over equal distances, average rates).

H = \frac{n}{\sum 1/x_i}

Inputs

  • x positive values vector

Returns

  • harmonic_mean n divided by the sum of reciprocals

Applies when

  • all values positive

Example

m.ask("Find the harmonic mean of [40, 60].")
→ harmonic_mean = 48
Mean absolute deviationmean_absolute_deviation

The mean absolute deviation about the mean of a list of numbers.

MAD = \frac{1}{n}\sum |x_i - \bar{x}|

Inputs

  • x the data values vector

Returns

  • mean_absolute_deviation average distance from the mean
  • mean mean

Example

m.ask("Find the mean absolute deviation of [2, 4, 6, 8].")
→ mean_absolute_deviation = 2, mean = 5
Mean and standard deviation of a frequency tablefrequency_table_statistics

The mean and the sample and population standard deviations of data given as values with frequencies.

\bar{x} = \frac{\sum f_i x_i}{\sum f_i},\quad s = \sqrt{\frac{\sum f_i (x_i - \bar{x})^2}{n - 1}}

Inputs

  • x the distinct values vector
  • f their frequencies (whole numbers) vector

Returns

  • mean sum(f x) / n
  • sample_standard_deviation divisor n - 1
  • population_standard_deviation divisor n
  • n total frequency

Applies when

  • frequencies are whole numbers
  • total frequency >= 2

Example

m.ask("Find the mean and standard deviation of the frequency table with values [1, 2, 3, 4] and frequencies [3, 5, 8, 4].")
→ mean = 2.65, sample_standard_deviation = 0.988087, population_standard_deviation = 0.963068, n = 20
Medianmedian

The median (middle value) of a list of numbers; the mean of the two middle values when n is even.

\tilde{x} = x_{((n+1)/2)} \ \text{or}\ \tfrac12\left(x_{(n/2)} + x_{(n/2+1)}\right)

Inputs

  • x the data values vector

Returns

  • median median
  • n number of values

Example

m.ask("Find the median of [7, 1, 5, 3, 9].")
→ median = 5, n = 5
Median absolute deviationmedian_absolute_deviation

The median absolute deviation (MAD) about the median, a robust measure of spread (unscaled).

MAD = \operatorname{median}\left(|x_i - \tilde{x}|\right)

Inputs

  • x the data values vector

Returns

  • median_absolute_deviation median of |x - median|
  • median median

Applies when

  • unscaled (multiply by 1.4826 to estimate a normal sigma)

Example

m.ask("Find the median absolute deviation of [1, 1, 2, 2, 4, 6, 9].")
→ median_absolute_deviation = 1, median = 2
Modemode

The mode(s) of a list of numbers: every value that occurs most often (no mode when all values occur equally often).

\operatorname{mode} = \arg\max_v \#\{i : x_i = v\}

Inputs

  • x the data values vector

Returns

  • modes the most frequent value(s), ascending; empty if there is no mode
  • frequency how often the mode occurs
  • has_mode yes or no

Applies when

  • no mode is reported when every distinct value occurs equally often

Example

m.ask("Find the mode of [3, 7, 7, 2, 9, 7, 3].")
→ modes = [7.0], frequency = 3, has_mode = yes
Outliers by the 1.5 IQR ruleiqr_outliers

The lower and upper fences Q1 - 1.5 IQR and Q3 + 1.5 IQR and the values outside them.

[Q_1 - 1.5\,IQR,\ Q_3 + 1.5\,IQR]

Inputs

  • x the data values (at least four) vector

Returns

  • lower_fence Q1 - 1.5 IQR
  • upper_fence Q3 + 1.5 IQR
  • outliers values outside the fences
  • q1 first quartile
  • q3 third quartile
  • iqr interquartile range

Applies when

  • quartiles by linear interpolation (type 7)

Example

m.ask("Find the outliers in [10, 12, 12, 13, 12, 11, 14, 13, 15, 102].")
→ lower_fence = 9.375, upper_fence = 16.375, outliers = [102.0], q1 = 12, q3 = 13.75, iqr = 1.75
Percentile of a data setpercentile

The p-th percentile of a data set (linear interpolation, or the weibull/p(n+1) method).

P_p = x_{(\lfloor h \rfloor)} + (h - \lfloor h \rfloor)(x_{(\lfloor h \rfloor+1)} - x_{(\lfloor h \rfloor)})

Inputs

  • x the data values (at least two) vector
  • p the percentile, 0 to 100
  • method quantile method: linear (type 7, spreadsheet/numpy default) or weibull (type 6, p(n+1)) choice optional

Returns

  • percentile the p-th percentile

Applies when

  • 0 <= p <= 100
  • linear interpolation (type 7) unless method = weibull (type 6)

Example

m.ask("Find the 90th percentile of [15, 20, 35, 40, 50].")
→ percentile = 46
Population standard deviationpopulation_standard_deviation

The population standard deviation of a list of numbers (divisor n).

\sigma = \sqrt{\frac{1}{n}\sum (x_i - \mu)^2}

Inputs

  • x the data values vector

Returns

  • standard_deviation population standard deviation
  • mean arithmetic mean
  • n number of values
  • variance the companion measure

Applies when

  • the data are the whole population (divisor n)

Example

m.ask("Find the population standard deviation of [2, 4, 4, 4, 5, 5, 7, 9].")
→ mean = 5, n = 8, standard_deviation = 2, variance = 4
Population variancepopulation_variance

The population variance of a list of numbers (divisor n).

\sigma^2 = \frac{1}{n}\sum (x_i - \mu)^2

Inputs

  • x the data values vector

Returns

  • variance population variance
  • mean arithmetic mean
  • n number of values
  • standard_deviation the companion measure

Applies when

  • the data are the whole population (divisor n)

Example

m.ask("Find the population variance of [2, 4, 4, 4, 5, 5, 7, 9].")
→ mean = 5, n = 8, variance = 4, standard_deviation = 2
Rangerange

The range (largest minus smallest value) of a list of numbers.

R = x_{\max} - x_{\min}

Inputs

  • x the data values vector

Returns

  • range maximum minus minimum
  • minimum smallest value
  • maximum largest value

Example

m.ask("Find the range of [12, 4, 19, 7].")
→ range = 15, minimum = 4, maximum = 19
Sample standard deviationsample_standard_deviation

The sample standard deviation of a list of numbers (divisor n - 1).

s = \sqrt{\frac{1}{n-1}\sum (x_i - \bar{x})^2}

Inputs

  • x the data values (at least two) vector

Returns

  • standard_deviation sample standard deviation
  • mean arithmetic mean
  • n number of values
  • variance the companion measure

Applies when

  • the data are a sample (divisor n - 1, Bessel's correction); at least two values

Example

m.ask("Find the sample standard deviation of [2, 4, 4, 4, 5, 5, 7, 9].")
→ mean = 5, n = 8, standard_deviation = 2.13809, variance = 4.57143
Sample variancesample_variance

The sample variance of a list of numbers (divisor n - 1).

s^2 = \frac{1}{n-1}\sum (x_i - \bar{x})^2

Inputs

  • x the data values (at least two) vector

Returns

  • variance sample variance
  • mean arithmetic mean
  • n number of values
  • standard_deviation the companion measure

Applies when

  • the data are a sample (divisor n - 1, Bessel's correction); at least two values

Example

m.ask("Find the sample variance of [2, 4, 4, 4, 5, 5, 7, 9].")
→ mean = 5, n = 8, variance = 4.57143, standard_deviation = 2.13809
Skewness and kurtosisskewness_kurtosis

Sample skewness and excess kurtosis: the adjusted Fisher-Pearson estimates (G1, G2, as in spreadsheets and most software) and the moment estimates (g1, g2).

G_1 = \frac{\sqrt{n(n-1)}}{n-2}\,\frac{m_3}{m_2^{3/2}},\quad G_2 = \frac{(n-1)\left((n+1)g_2 + 6\right)}{(n-2)(n-3)}

Inputs

  • x the data values (at least four) vector

Returns

  • skewness adjusted skewness G1
  • excess_kurtosis adjusted excess kurtosis G2
  • skewness_biased moment skewness g1
  • excess_kurtosis_biased moment excess kurtosis g2

Applies when

  • at least four values, not all equal

Example

m.ask("Find the skewness and kurtosis of [2, 3, 3, 4, 8, 12, 20].")
→ skewness = 1.39985, excess_kurtosis = 1.37206, skewness_biased = 1.08001, excess_kurtosis_biased = -0.178307
Standard error of the meanstandard_error_of_mean

The standard error of the mean of a sample: s / sqrt(n).

SE_{\bar{x}} = \frac{s}{\sqrt{n}}

Inputs

  • x the data values (at least two) vector

Returns

  • standard_error s / sqrt(n)
  • standard_deviation sample standard deviation
  • n sample size

Example

m.ask("Find the standard error of the mean of [12, 15, 11, 18, 14].")
→ standard_error = 1.22474, standard_deviation = 2.73861, n = 5
Trimmed meantrimmed_mean

The trimmed mean: the mean after removing the given proportion of values from EACH end.

\bar{x}_{\alpha} = \frac{1}{n - 2k}\sum_{i=k+1}^{n-k} x_{(i)},\ k = \lfloor \alpha n \rfloor

Inputs

  • x the data values vector
  • proportion proportion cut from each end (0.1 for a 10% trimmed mean)

Returns

  • trimmed_mean mean of the remaining values
  • removed_each_end values removed at each end

Applies when

  • 0 <= proportion < 0.5
  • floor(proportion * n) values removed from each end

Example

m.ask("Find the 10% trimmed mean of [2, 4, 5, 6, 7, 8, 9, 10, 12, 50].")
→ trimmed_mean = 7.625, removed_each_end = 1
Weighted meanweighted_mean

The weighted mean of values x with weights w (grade-point averages, portfolio averages).

\bar{x}_w = \frac{\sum w_i x_i}{\sum w_i}

Inputs

  • x the values vector
  • w the weights (non-negative, same length) vector

Returns

  • weighted_mean sum(w x) / sum(w)
  • total_weight sum of the weights

Applies when

  • same number of values and weights
  • weights >= 0 with a positive sum

Example

m.ask("Find the weighted mean of values [90, 80, 70] with weights [3, 2, 1].")
→ weighted_mean = 83.3333, total_weight = 6
z-score of a valuez_score

The z-score (standard score) of a value x in a distribution with mean mu and standard deviation sigma.

z = \frac{x - \mu}{\sigma}

Inputs

  • x the value
  • mu the mean
  • sigma the standard deviation (> 0)

Returns

  • z number of standard deviations x lies above (+) or below (-) the mean

Applies when

  • sigma > 0

Example

m.ask("Find the z-score of x = 85 when the mean = 70 and the standard deviation = 10.")
→ z = 1.5

Effect sizes 1

Cohen's d and Hedges' gcohens_d

The standardized mean difference of two independent samples: Cohen's d (pooled SD) and Hedges' g (bias-corrected).

d = \frac{\bar{x}_1 - \bar{x}_2}{s_p},\ s_p = \sqrt{\frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2-2}}

Inputs

  • x first sample vector
  • y second sample vector

Returns

  • d (mean x - mean y) / pooled SD
  • hedges_g d (1 - 3/(4(n1 + n2) - 9))
  • pooled_sd pooled standard deviation

Applies when

  • independent samples

Example

m.ask("Find Cohen's d for [12, 15, 11, 18, 14] and [10, 9, 13, 11, 8].")
→ d = 1.60579, hedges_g = 1.45039, pooled_sd = 2.36643

Experimental design 4

2^2 factorial design: main effects and interactionfactorial_2x2_effects

Effects of a two-level 4-run factorial experiment from one response per run in standard (Yates) order ((1), a, b, ab).

\text{Effect} = \frac{\text{contrast}}{2^{k-1}}

Inputs

  • y 4 responses in standard order vector

Returns

  • grand_mean average response
  • A effect A
  • B effect B
  • AB effect AB

Applies when

  • responses in standard order
  • one response (or cell mean) per run

Example

m.ask("Find the effects of the 2^2 factorial design with responses in standard order [28, 36, 18, 31].")
→ grand_mean = 28.25, A = 10.5, B = -7.5, AB = 2.5
2^3 factorial design: main effects and interactionsfactorial_2x2x2_effects

Effects of a two-level 8-run factorial experiment from one response per run in standard (Yates) order ((1), a, b, ab, c, ac, bc, abc).

\text{Effect} = \frac{\text{contrast}}{2^{k-1}}

Inputs

  • y 8 responses in standard order vector

Returns

  • grand_mean average response
  • A effect A
  • B effect B
  • C effect C
  • AB effect AB
  • AC effect AC
  • BC effect BC
  • ABC effect ABC

Applies when

  • responses in standard order
  • one response (or cell mean) per run

Example

m.ask("Find the effects of the 2^3 factorial design with responses in standard order [22, 32, 35, 55, 44, 40, 60, 39].")
→ grand_mean = 40.875, A = 1.25, B = 12.75, C = 9.75, AB = -1.75, AC = -13.75, BC = -5.25, ABC = -6.75
Cronbach's alpha (internal consistency)cronbach_alpha

Cronbach's alpha for a questionnaire or test: rows are respondents, columns are items.

\alpha = \frac{k}{k-1}\left(1 - \frac{\sum s_i^2}{s_T^2}\right)

Inputs

  • data scores: one row per respondent, one column per item matrix

Returns

  • alpha k/(k-1) (1 - sum of item variances / variance of totals)
  • items k
  • respondents n

Applies when

  • at least 2 items and 2 respondents

Example

m.ask("Find Cronbach's alpha for [[4, 5, 4], [3, 3, 4], [5, 5, 5], [2, 3, 2], [4, 4, 3]].")
→ alpha = 0.913043, items = 3, respondents = 5
Randomized complete block design (two-way ANOVA without replication)randomized_block_anova

Two-way ANOVA for a randomized complete block design: rows are blocks, columns are treatments, one observation per cell; F-tests for treatments and blocks.

F_{\text{trt}} = \frac{SS_{\text{trt}}/(t-1)}{SS_E/((t-1)(b-1))}

Inputs

  • data table with one row per block and one column per treatment matrix

Returns

  • f_treatment F for treatments
  • p_treatment p-value for treatments
  • f_block F for blocks
  • p_block p-value for blocks
  • ss_treatment treatment sum of squares
  • ss_block block sum of squares
  • ss_error error sum of squares
  • df_treatment t - 1
  • df_block b - 1
  • df_error (t - 1)(b - 1)

Applies when

  • one observation per block and treatment
  • additive model (no block x treatment interaction)
  • normal errors with constant variance

Example

m.ask("Analyse the randomized block design with data [[12, 14, 15], [10, 13, 13], [11, 15, 16], [9, 12, 14]].")
→ f_treatment = 39, p_treatment = 0.000364431, f_block = 9.25, p_block = 0.0114399, ss_treatment = 34.6667, ss_block = 12.3333, ss_error = 2.66667, df_treatment = 2, df_block = 3, df_error = 6

Hypothesis tests 14

Bartlett's test for equal variancesbartlett_test

Bartlett's test of equal variances across 2 to 5 groups (normal populations).

T = \frac{(N-k)\ln s_p^2 - \sum (n_i - 1)\ln s_i^2}{1 + \frac{1}{3(k-1)}\left(\sum \frac{1}{n_i - 1} - \frac{1}{N-k}\right)}

Inputs

  • g1 group 1 vector
  • g2 group 2 vector
  • g3 group 3 vector optional
  • g4 group 4 vector optional
  • g5 group 5 vector optional

Returns

  • statistic Bartlett's chi-square statistic
  • df k - 1
  • p_value p-value

Applies when

  • normal populations (Bartlett's test is sensitive to non-normality)
  • at least 2 values per group

Example

m.ask("Bartlett's test for [21, 24, 19, 26, 23], [22, 23, 22, 24, 23] and [18, 28, 20, 30, 24].")
→ statistic = 8.61822, df = 2, p_value = 0.0134455
Chi-square goodness-of-fit testchi_square_goodness_of_fit

The chi-square goodness-of-fit test of observed counts against expected proportions (equal if omitted).

\chi^2 = \sum \frac{(O_i - E_i)^2}{E_i},\ \nu = k - 1

Inputs

  • observed observed counts per category vector
  • proportions expected proportions or relative weights per category (equal if omitted) vector optional

Returns

  • chi_square sum (O - E)^2 / E
  • df categories - 1
  • p_value upper-tail p-value
  • expected expected counts

Applies when

  • independent observations
  • expected counts at least about 5
  • proportions are rescaled to sum to 1

Example

m.ask("Chi-square goodness-of-fit test for observed [18, 22, 20, 25, 15] with equal expected proportions.")
→ chi_square = 2.9, df = 4, p_value = 0.574697, expected = [20.0, 20.0, 20.0, 20.0, 20.0]
Chi-square test for a variancechi_square_variance_test

The chi-square test of H0: sigma = sigma0 for a normal population from sample data.

\chi^2 = \frac{(n-1)s^2}{\sigma_0^2}

Inputs

  • x the data values (at least two) vector
  • sigma0 hypothesised standard deviation
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • chi_square (n - 1) s^2 / sigma0^2
  • df n - 1
  • p_value p-value
  • sample_variance s^2

Applies when

  • normal population (the test is sensitive to non-normality)

Example

m.ask("Chi-square test for a variance: data [10.2, 9.8, 10.5, 10.1, 9.6, 10.4], sigma0 = 0.3, two-sided.")
→ chi_square = 6.66667, df = 5, p_value = 0.493268, sample_variance = 0.12
Chi-square test of independencechi_square_independence

The chi-square test of independence (or homogeneity) for an r x c contingency table of counts.

\chi^2 = \sum_{i,j}\frac{(O_{ij} - E_{ij})^2}{E_{ij}},\ E_{ij} = \frac{R_i C_j}{n}

Inputs

  • table contingency table of counts (rows x columns) matrix

Returns

  • chi_square Pearson chi-square statistic
  • df (r - 1)(c - 1)
  • p_value upper-tail p-value
  • expected expected counts under independence

Applies when

  • independent observations
  • expected counts at least about 5
  • no continuity correction

Example

m.ask("Chi-square test of independence for the table [[20, 30], [25, 25]].")
→ chi_square = 1.0101, df = 1, p_value = 0.314879, expected = [[22.5, 27.5], [22.5, 27.5]]
F-test for equality of two variancesf_test_variances

The F-test of H0: sigma1^2 = sigma2^2 from two independent normal samples.

F = \frac{s_1^2}{s_2^2}

Inputs

  • x first sample vector
  • y second sample vector
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • f s1^2 / s2^2
  • df1 n1 - 1
  • df2 n2 - 1
  • p_value p-value

Applies when

  • independent samples from normal populations (sensitive to non-normality)

Example

m.ask("F-test for equality of variances of [21, 24, 19, 26, 23, 25] and [22, 23, 22, 24, 23], two-sided.")
→ f = 9.71429, df1 = 5, df2 = 4, p_value = 0.046857
Levene's test for equal varianceslevene_test

Levene's test of equal variances across 2 to 5 groups, centred at the median (Brown-Forsythe) or the mean.

W = \frac{(N-k)\sum n_i(\bar{z}_{i\cdot} - \bar{z})^2}{(k-1)\sum\sum (z_{ij} - \bar{z}_{i\cdot})^2},\ z_{ij} = |x_{ij} - \tilde{x}_i|

Inputs

  • g1 group 1 vector
  • g2 group 2 vector
  • g3 group 3 vector optional
  • g4 group 4 vector optional
  • g5 group 5 vector optional
  • center median (Brown-Forsythe) or mean (Levene's original) choice

Returns

  • w Levene statistic
  • p_value p-value
  • df1 k - 1
  • df2 N - k

Applies when

  • independent groups, at least 2 values each

Example

m.ask("Levene's test (median centred) for [21, 24, 19, 26, 23], [22, 23, 22, 24, 23] and [18, 28, 20, 30, 24].")
→ w = 4.97727, p_value = 0.026665, df1 = 2, df2 = 12
One-proportion z-testproportion_z_test

The z-test of H0: p = p0 for a population proportion from x successes in n trials.

z = \frac{\hat{p} - p_0}{\sqrt{p_0(1-p_0)/n}}

Inputs

  • x number of successes integer
  • n sample size integer
  • p0 hypothesised proportion
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • z (x/n - p0)/sqrt(p0(1 - p0)/n)
  • p_value p-value
  • proportion x/n

Applies when

  • n p0 and n(1 - p0) at least about 10
  • independent trials

Example

m.ask("Test H0: p = 0.5 for a proportion with x = 58 successes out of n = 100, p0 = 0.5, two-sided.")
→ z = 1.6, p_value = 0.109599, proportion = 0.58
One-sample t-testt_test_one_sample

The one-sample t-test of H0: mu = mu0 from sample data: t statistic, degrees of freedom and p-value.

t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}},\ \nu = n - 1

Inputs

  • x the data values (at least two) vector
  • mu0 hypothesised mean
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • t (mean - mu0)/(s/sqrt(n))
  • df n - 1
  • p_value p-value
  • mean sample mean
  • standard_deviation sample standard deviation

Applies when

  • random sample from a roughly normal population (or large n)
  • the alternative must be stated for a one-sided claim

Example

m.ask("Perform a one-sample t-test of [5.1, 4.9, 5.3, 5.5, 5.0, 5.2] against mu0 = 5, two-sided.")
→ t = 1.88982, df = 5, p_value = 0.117387, mean = 5.16667, standard_deviation = 0.216025
One-sample z-test for a mean (sigma known)z_test_mean

The z statistic and p-value for H0: mu = mu0 when the population standard deviation is known.

z = \frac{\bar{x} - \mu_0}{\sigma/\sqrt{n}}

Inputs

  • xbar sample mean
  • mu0 hypothesised mean
  • sigma population standard deviation (known)
  • n sample size integer
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • z (xbar - mu0) / (sigma / sqrt(n))
  • p_value p-value for the chosen alternative

Applies when

  • sigma known
  • normal population or large n
  • the alternative must be stated for a one-sided claim

Example

m.ask("Perform a z-test of H0: mu = 50 with sample mean = 52, sigma = 5 and n = 36, two-sided.")
→ z = 2.4, p_value = 0.0163951
Paired t-testpaired_t_test

The paired (dependent samples) t-test on the differences x - y: t statistic, df and p-value.

t = \frac{\bar{d}}{s_d/\sqrt{n}},\ \nu = n - 1

Inputs

  • x first measurement of each pair vector
  • y second measurement of each pair vector
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • t mean difference / (s_d / sqrt(n))
  • df n - 1
  • p_value p-value
  • mean_difference mean of x - y

Applies when

  • pairs measured on the same units
  • differences roughly normal (or many pairs)

Example

m.ask("Perform a paired t-test on before [200, 190, 210, 220, 205] and after [195, 185, 200, 214, 200], two-sided.")
→ t = 6.39481, df = 4, p_value = 0.00307015, mean_difference = 6.2
Two-proportion z-testtwo_proportion_z_test

The pooled z-test of H0: p1 = p2 from x1 of n1 and x2 of n2 successes.

z = \frac{\hat{p}_1 - \hat{p}_2}{\sqrt{\hat{p}(1-\hat{p})\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}}

Inputs

  • x1 successes in sample 1 integer
  • n1 size of sample 1 integer
  • x2 successes in sample 2 integer
  • n2 size of sample 2 integer
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • z z statistic (pooled standard error)
  • p_value p-value
  • pooled_proportion (x1 + x2)/(n1 + n2)
  • difference x1/n1 - x2/n2

Applies when

  • independent samples
  • at least about 10 successes and failures in each sample

Example

m.ask("Two-proportion z-test with x1 = 45, n1 = 100, x2 = 30, n2 = 100, two-sided.")
→ z = 2.19089, p_value = 0.0284597, pooled_proportion = 0.375, difference = 0.15
Two-sample t-test (pooled variances)t_test_two_sample_pooled

Two-sample t-test (pooled variances) comparing the means of two independent samples: t statistic, degrees of freedom, p-value.

t = \frac{\bar{x}_1 - \bar{x}_2}{s_p\sqrt{1/n_1 + 1/n_2}},\ \nu = n_1 + n_2 - 2

Inputs

  • x first sample vector
  • y second sample vector
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • t t statistic
  • df degrees of freedom
  • p_value p-value
  • difference mean(x) - mean(y)

Applies when

  • independent random samples
  • roughly normal populations or large samples
  • equal population variances assumed

Example

m.ask("Perform a two-sample t-test with pooled variances on [12, 15, 11, 18, 14] and [10, 9, 13, 11, 8], two-sided.")
→ t = 2.53898, df = 8, p_value = 0.0347658, difference = 3.8
Two-sample t-test from summary statisticst_test_summary_statistics

The two-sample t-test from the means, sample standard deviations and sizes of two groups (Welch or pooled).

t = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{s_1^2/n_1 + s_2^2/n_2}}

Inputs

  • m1 mean of group 1
  • s1 sample standard deviation of group 1
  • n1 size of group 1 integer
  • m2 mean of group 2
  • s2 sample standard deviation of group 2
  • n2 size of group 2 integer
  • variance welch (unequal variances) or pooled (equal variances) choice
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • t t statistic
  • df degrees of freedom
  • p_value p-value
  • difference m1 - m2

Applies when

  • independent random samples
  • roughly normal populations or large samples

Example

m.ask("Two-sample t-test from summary statistics with pooled variances: mean1 = 20, sd1 = 4, n1 = 15, mean2 = 17, sd2 = 5, n2 = 12, two-sided.")
→ t = 1.73379, df = 25, p_value = 0.0952738, difference = 3
Welch's two-sample t-test (unequal variances)welch_t_test

Welch's two-sample t-test (unequal variances) comparing the means of two independent samples: t statistic, degrees of freedom, p-value.

t = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{s_1^2/n_1 + s_2^2/n_2}}

Inputs

  • x first sample vector
  • y second sample vector
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • t t statistic
  • df degrees of freedom
  • p_value p-value
  • difference mean(x) - mean(y)

Applies when

  • independent random samples
  • roughly normal populations or large samples
  • Welch-Satterthwaite degrees of freedom

Example

m.ask("Perform a two-sample t-test with unequal variances on [12, 15, 11, 18, 14] and [10, 9, 13, 11, 8], two-sided.")
→ t = 2.53898, df = 7.17415, p_value = 0.0379455, difference = 3.8

Nonparametric tests 7

Friedman testfriedman_test

The Friedman rank test for k >= 3 related treatments measured on the same blocks (subjects): rows are blocks, columns are treatments.

Q = \frac{12}{nk(k+1)}\sum_j R_j^2 - 3n(k+1)

Inputs

  • data table with one row per block (subject) and one column per treatment matrix

Returns

  • chi_square Friedman statistic (tie-corrected)
  • df k - 1
  • p_value chi-square p-value

Applies when

  • at least 3 treatments and 2 blocks
  • chi-square approximation

Example

m.ask("Perform a Friedman test on [[7, 9, 8], [6, 5, 7], [9, 7, 6], [8, 5, 6], [7, 8, 9]].")
→ chi_square = 0.4, df = 2, p_value = 0.818731
Kruskal-Wallis H testkruskal_wallis

The Kruskal-Wallis rank test comparing 2 to 5 independent groups (nonparametric one-way ANOVA).

H = \frac{12}{N(N+1)}\sum \frac{R_i^2}{n_i} - 3(N+1)

Inputs

  • g1 group 1 vector
  • g2 group 2 vector
  • g3 group 3 vector optional
  • g4 group 4 vector optional
  • g5 group 5 vector optional

Returns

  • h H statistic (tie-corrected)
  • df k - 1
  • p_value chi-square p-value

Applies when

  • independent groups, ordinal or continuous data
  • chi-square approximation (about 5 or more per group)

Example

m.ask("Perform a Kruskal-Wallis test on [27, 2, 4, 18, 7, 9], [20, 8, 14, 36, 21, 22] and [34, 31, 3, 23, 30, 6].")
→ h = 2.8538, df = 2, p_value = 0.240052
Mann-Whitney U test (exact)mann_whitney_exact

The Mann-Whitney U test (exact): compares two independent samples by ranks (statistic U of the first sample and the p-value).

U_1 = R_1 - \frac{n_1(n_1+1)}{2}

Inputs

  • x first sample vector
  • y second sample vector
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • u U statistic of the first sample (R1 - n1(n1+1)/2)
  • p_value p-value

Applies when

  • independent samples, ordinal or continuous data
  • no ties
  • samples of at most 30

Example

m.ask("Perform a exact Mann-Whitney U test on [3.1, 5.2, 4.3, 6.4, 7.5] and [1.5, 2.6, 2.2, 3.9], two-sided.")
→ u = 19, p_value = 0.031746
Mann-Whitney U test (large-sample)mann_whitney_u

The Mann-Whitney U test (large-sample): compares two independent samples by ranks (statistic U of the first sample and the p-value).

U_1 = R_1 - \frac{n_1(n_1+1)}{2}

Inputs

  • x first sample vector
  • y second sample vector
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • u U statistic of the first sample (R1 - n1(n1+1)/2)
  • p_value p-value

Applies when

  • independent samples, ordinal or continuous data
  • normal approximation with tie correction and continuity correction

Example

m.ask("Perform a Mann-Whitney U test on [3, 5, 4, 6, 7] and [1.5, 2.6, 2.2, 3.9], two-sided.")
→ u = 19, p_value = 0.0373364
Sign testsign_test

The sign test for the median difference of paired data (or of differences given directly): exact binomial p-value.

P = 2\min\left(P(K \le k), P(K \ge k)\right),\ K \sim \mathrm{Bin}(n, \tfrac12)

Inputs

  • x differences, or the first measurement of each pair vector
  • y second measurement of each pair (optional) vector optional
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • positives number of positive differences
  • n non-zero differences
  • p_value exact binomial p-value

Applies when

  • paired data
  • zero differences dropped

Example

m.ask("Perform a sign test on before [125, 115, 130, 140, 141, 115, 140, 125] and after [110, 122, 125, 120, 140, 124, 123, 137], two-sided.")
→ positives = 5, n = 8, p_value = 0.726562
Wilcoxon signed-rank test (exact)wilcoxon_signed_rank_exact

The Wilcoxon signed-rank test (exact) for paired data (x - y) or for differences given directly (x alone); zero differences are dropped.

R^+ = \sum_{d_i > 0} \operatorname{rank}(|d_i|)

Inputs

  • x differences, or the first measurement of each pair vector
  • y second measurement of each pair (optional) vector optional
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • statistic min(R+, R-) for a two-sided test, R+ otherwise
  • p_value p-value
  • r_plus sum of ranks of positive differences
  • n non-zero differences

Applies when

  • paired data, symmetric distribution of differences
  • zero differences dropped
  • no zero and no tied absolute differences
  • at most 60 differences

Example

m.ask("Perform a exact Wilcoxon signed-rank test on before [125, 115, 130, 140, 141, 115, 140, 125] and after [110, 122, 125, 120, 140, 124, 123, 137], two-sided.")
→ statistic = 12, p_value = 0.460938, r_plus = 24, n = 8
Wilcoxon signed-rank test (large-sample)wilcoxon_signed_rank

The Wilcoxon signed-rank test (large-sample) for paired data (x - y) or for differences given directly (x alone); zero differences are dropped.

R^+ = \sum_{d_i > 0} \operatorname{rank}(|d_i|)

Inputs

  • x differences, or the first measurement of each pair vector
  • y second measurement of each pair (optional) vector optional
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • statistic min(R+, R-) for a two-sided test, R+ otherwise
  • p_value p-value
  • r_plus sum of ranks of positive differences
  • n non-zero differences

Applies when

  • paired data, symmetric distribution of differences
  • zero differences dropped
  • normal approximation with tie correction, no continuity correction

Example

m.ask("Perform a Wilcoxon signed-rank test on before [125, 115, 130, 140, 141, 115, 140, 125] and after [110, 122, 125, 120, 140, 124, 123, 137], two-sided.")
→ statistic = 12, p_value = 0.400814, r_plus = 24, n = 8

Power and sample size 5

Power of a one-sample z-testpower_one_sample_z

The power of a one-sample z-test for a standardized effect size d (Cohen's d), sample size n and significance level alpha.

1 - \beta = \Phi\left(d\sqrt{n_{\text{eff}}} - z_{1-\alpha/2}\right) + \Phi\left(-d\sqrt{n_{\text{eff}}} - z_{1-\alpha/2}\right)

Inputs

  • d standardized effect size (difference / sigma)
  • n sample size
  • alpha significance level
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • power probability of rejecting H0 when the effect is d

Applies when

  • normal approximation (sigma known)
  • two-sided power includes both rejection tails

Example

m.ask("Find the power of a one-sample z-test with effect size d = 0.5, n = 30 and alpha = 0.05, two-sided.")
→ power = 0.781908
Power of a two-sample z-testpower_two_sample_z

The power of a two-sample z-test for a standardized effect size d (Cohen's d), sample size n per group and significance level alpha.

1 - \beta = \Phi\left(d\sqrt{n_{\text{eff}}} - z_{1-\alpha/2}\right) + \Phi\left(-d\sqrt{n_{\text{eff}}} - z_{1-\alpha/2}\right)

Inputs

  • d standardized effect size (difference / sigma)
  • n sample size per group
  • alpha significance level
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • power probability of rejecting H0 when the effect is d

Applies when

  • normal approximation (sigma known)
  • two-sided power includes both rejection tails

Example

m.ask("Find the power of a two-sample z-test with effect size d = 0.5, n = 30 and alpha = 0.05, two-sided.")
→ power = 0.490686
Sample size per group to compare two means (z-test power)sample_size_two_means

The sample size per group for a two-sample z-test to reach a target power for a standardized effect size d.

n \approx 2\left(\frac{z_{1-\alpha/2} + z_{1-\beta}}{d}\right)^2

Inputs

  • d standardized effect size (difference / sigma)
  • alpha significance level
  • power target power (e.g. 0.8)
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • n_per_group required size per group (rounded up)
  • n_exact solution before rounding

Applies when

  • equal group sizes
  • normal approximation
  • two-sided power includes both tails

Example

m.ask("What sample size per group is needed for two groups with effect size d = 0.5, alpha = 0.05 and power = 0.8, two-sided?")
→ n_per_group = 63, n_exact = 62.7909
Sample size to estimate a meansample_size_mean

The smallest n giving a z confidence interval for a mean with the required margin of error, sigma known.

n = \left\lceil \left(\frac{z_{\alpha/2}\,\sigma}{E}\right)^2 \right\rceil

Inputs

  • sigma population standard deviation (planning value)
  • margin margin of error
  • confidence confidence level as a fraction (0.95 for 95%)

Returns

  • n required sample size (rounded up)
  • n_exact (z sigma / E)^2

Applies when

  • sigma known or a planning estimate

Example

m.ask("What sample size is needed to estimate the mean within margin of error = 2 with sigma = 15 at 95% confidence?")
→ n = 217, n_exact = 216.082
Sample size to estimate a proportionsample_size_proportion

The smallest n giving a confidence interval for a proportion with the required margin of error (p = 0.5 if no estimate).

n = \left\lceil \frac{z_{\alpha/2}^2\,p(1-p)}{E^2} \right\rceil

Inputs

  • margin margin of error (as a proportion, 0.03 for 3 points)
  • confidence confidence level as a fraction (0.95 for 95%)
  • p planning estimate of the proportion (default 0.5) optional

Returns

  • n required sample size (rounded up)
  • n_exact z^2 p(1-p)/E^2 before rounding

Applies when

  • large-sample (Wald) interval
  • simple random sample

Example

m.ask("What sample size is needed to estimate a proportion within margin of error = 0.03 at 95% confidence?")
→ n = 1068, n_exact = 1067.07

Probability 1

Probability of at least one occurrenceprobability_at_least_one

The probability that an event of probability p occurs at least once in n independent trials.

P(\text{at least one}) = 1 - (1 - p)^n

Inputs

  • p probability of the event on one trial
  • n number of independent trials integer

Returns

  • probability 1 - (1 - p)^n
  • none probability that it never occurs, (1 - p)^n

Applies when

  • independent trials with the same probability p

Example

m.ask("What is the probability of at least one success in n = 5 independent trials with probability = 0.2?")
→ probability = 0.67232, none = 0.32768

Probability distributions 17

Binomial probability: at least k successesbinomial_at_least

The probability of at least k successes in n independent trials with success probability p.

P(X \ge k) = \sum_{j=k}^{n} \binom{n}{j} p^j (1-p)^{n-j}

Inputs

  • n number of trials integer
  • k number of successes integer
  • p probability of success on each trial

Returns

  • probability P(X >= k)

Applies when

  • n independent trials, constant success probability 0 < p < 1
  • 0 <= k <= n

Example

m.ask("Find the binomial probability of at least k = 3 successes in n = 10 trials with p = 0.4.")
→ probability = 0.83271
Binomial probability: at most k successesbinomial_at_most

The probability of at most k successes in n independent trials with success probability p.

P(X \le k) = \sum_{j=0}^{k} \binom{n}{j} p^j (1-p)^{n-j}

Inputs

  • n number of trials integer
  • k number of successes integer
  • p probability of success on each trial

Returns

  • probability P(X <= k)

Applies when

  • n independent trials, constant success probability 0 < p < 1
  • 0 <= k <= n

Example

m.ask("Find the binomial probability of at most k = 3 successes in n = 10 trials with p = 0.4.")
→ probability = 0.382281
Binomial probability: exactly k successesbinomial_exactly

The probability of exactly k successes in n independent trials with success probability p.

P(X = k) = \binom{n}{k} p^k (1-p)^{n-k}

Inputs

  • n number of trials integer
  • k number of successes integer
  • p probability of success on each trial

Returns

  • probability P(X = k)

Applies when

  • n independent trials, constant success probability 0 < p < 1
  • 0 <= k <= n

Example

m.ask("Find the binomial probability of exactly k = 3 successes in n = 10 trials with p = 0.4.")
→ probability = 0.214991
Expected value and variance of a discrete random variablediscrete_random_variable

The expected value, variance and standard deviation of a discrete random variable given its values and probabilities.

E[X] = \sum x_i p_i,\quad \operatorname{Var}(X) = \sum (x_i - \mu)^2 p_i

Inputs

  • x the values of the random variable vector
  • p their probabilities (summing to 1) vector

Returns

  • expected_value E[X] = sum x p
  • variance Var[X] = sum (x - E[X])^2 p
  • standard_deviation sqrt(Var[X])

Applies when

  • probabilities non-negative, summing to 1 (within 1e-9)

Example

m.ask("Find the expected value of a random variable with values [0, 1, 2, 3] and probabilities [0.1, 0.3, 0.4, 0.2].")
→ expected_value = 1.7, variance = 0.81, standard_deviation = 0.9
Exponential probability above a valueexponential_probability_above

P(X > x) for an exponential distribution given its rate lambda or its mean.

P(X > x) = e^{-\lambda x}

Inputs

  • x the value (>= 0)
  • rate rate lambda (events per unit) optional
  • mean mean 1/lambda (instead of the rate) optional

Returns

  • probability P(X > x)

Applies when

  • exponential (memoryless) waiting time
  • x >= 0
  • exactly one of rate or mean

Example

m.ask("For an exponential distribution with rate = 0.5, find P(X > 3).")
→ probability = 0.22313
Exponential probability below a valueexponential_probability_below

P(X < x) for an exponential distribution given its rate lambda or its mean.

P(X < x) = 1 - e^{-\lambda x}

Inputs

  • x the value (>= 0)
  • rate rate lambda (events per unit) optional
  • mean mean 1/lambda (instead of the rate) optional

Returns

  • probability P(X < x)

Applies when

  • exponential (memoryless) waiting time
  • x >= 0
  • exactly one of rate or mean

Example

m.ask("For an exponential distribution with rate = 0.5, find P(X < 3).")
→ probability = 0.77687
Geometric distribution: first success on trial kgeometric_probability

The probability that the first success occurs on trial k, and that it occurs on or before trial k.

P(X = k) = (1-p)^{k-1}p,\quad P(X \le k) = 1 - (1-p)^k

Inputs

  • p probability of success on each trial
  • k the trial number (1, 2, ...) integer

Returns

  • probability P(X = k) = (1 - p)^(k-1) p
  • cumulative P(X <= k) = 1 - (1 - p)^k

Applies when

  • independent trials, constant p
  • X counts trials up to and including the first success

Example

m.ask("For a geometric distribution with p = 0.2, find the probability that the first success is on trial k = 4.")
→ probability = 0.1024, cumulative = 0.5904
Hypergeometric probability (sampling without replacement)hypergeometric_probability

The probability of exactly k successes, and of at most k, in n draws without replacement from a population of N items of which K are successes.

P(X = k) = \frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}

Inputs

  • N population size integer
  • K number of successes in the population integer
  • n number of draws integer
  • k number of successes drawn integer

Returns

  • probability P(X = k)
  • cumulative P(X <= k)

Applies when

  • draws without replacement
  • K <= N, n <= N, k <= n

Example

m.ask("Find the hypergeometric probability with population size = 50, population successes = 5, draws = 10 and k = 2.")
→ probability = 0.20984, cumulative = 0.95174
Inverse normal (normal percentile)inverse_normal

The value x with P(X < x) = p for a normal distribution (percentiles, cut-offs, top and bottom percentages).

x = \mu + \sigma\,\Phi^{-1}(p)

Inputs

  • p cumulative probability to the left of x (0 < p < 1)
  • mu the mean
  • sigma the standard deviation (> 0)

Returns

  • x the value with P(X < x) = p
  • z the standard normal quantile

Applies when

  • 0 < p < 1
  • sigma > 0

Example

m.ask("Find the 90th percentile of a normal distribution with mean = 100 and standard deviation = 15.")
→ x = 119.223, z = 1.28155
Mean and standard deviation of a binomial distributionbinomial_mean_sd

The mean np, variance np(1-p) and standard deviation of a binomial random variable.

\mu = np,\quad \sigma = \sqrt{np(1-p)}

Inputs

  • n number of trials integer
  • p probability of success

Returns

  • mean n p
  • variance n p (1 - p)
  • standard_deviation sqrt(n p (1 - p))

Applies when

  • 0 < p < 1

Example

m.ask("Find the mean and standard deviation of a binomial distribution with n = 50 and p = 0.3.")
→ mean = 15, variance = 10.5, standard_deviation = 3.24037
Negative binomial: r-th success on trial nnegative_binomial_probability

The probability that the r-th success occurs on trial n (independent trials with success probability p).

P(N = n) = \binom{n-1}{r-1} p^r (1-p)^{n-r}

Inputs

  • r number of successes required integer
  • p probability of success
  • n the trial number integer

Returns

  • probability C(n-1, r-1) p^r (1-p)^(n-r)

Applies when

  • independent trials, constant p
  • n >= r

Example

m.ask("Negative binomial: find the probability that the r = 3 success occurs on trial n = 7 with p = 0.4.")
→ probability = 0.124416
Normal probability above a valuenormal_probability_above

P(X > x) for a normal distribution with mean mu and standard deviation sigma (the area to the right).

P(X > x) = 1 - \Phi\left(\frac{x - \mu}{\sigma}\right)

Inputs

  • x the value
  • mu the mean
  • sigma the standard deviation (> 0)

Returns

  • probability P(X > x)
  • z the z-score of x

Applies when

  • X normally distributed
  • sigma > 0

Example

m.ask("For a normal distribution with mean = 100 and standard deviation = 15, find P(X > 130).")
→ probability = 0.0227501, z = 2
Normal probability below a valuenormal_probability_below

P(X < x) for a normal distribution with mean mu and standard deviation sigma (the area to the left).

P(X < x) = \Phi\left(\frac{x - \mu}{\sigma}\right)

Inputs

  • x the value
  • mu the mean
  • sigma the standard deviation (> 0)

Returns

  • probability P(X < x)
  • z the z-score of x

Applies when

  • X normally distributed
  • sigma > 0

Example

m.ask("For a normal distribution with mean = 100 and standard deviation = 15, find P(X < 120).")
→ probability = 0.908789, z = 1.33333
Normal probability between two valuesnormal_probability_between

P(a < X < b) for a normal distribution with mean mu and standard deviation sigma.

P(a < X < b) = \Phi\left(\frac{b-\mu}{\sigma}\right) - \Phi\left(\frac{a-\mu}{\sigma}\right)

Inputs

  • a lower bound
  • b upper bound
  • mu the mean
  • sigma the standard deviation (> 0)

Returns

  • probability P(a < X < b)
  • z_a z-score of a
  • z_b z-score of b

Applies when

  • X normally distributed
  • sigma > 0
  • a < b

Example

m.ask("For a normal distribution with mean = 100 and standard deviation = 15, find P(85 < X < 115).")
→ probability = 0.682689, z_a = -1, z_b = 1
Poisson probability: at least k eventspoisson_at_least

The probability of at least k events when events occur independently at mean rate lambda per interval.

P(X \ge k) = 1 - \sum_{j=0}^{k-1} \frac{e^{-\lambda}\lambda^j}{j!}

Inputs

  • lam the mean number of events (lambda > 0)
  • k number of events integer

Returns

  • probability the Poisson probability

Applies when

  • events independent, at a constant mean rate
  • lambda > 0, k a whole number

Example

m.ask("For a Poisson distribution with lambda = 4, find the probability of at least k = 2 events.")
→ probability = 0.908422
Poisson probability: at most k eventspoisson_at_most

The probability of at most k events when events occur independently at mean rate lambda per interval.

P(X \le k) = \sum_{j=0}^{k} \frac{e^{-\lambda}\lambda^j}{j!}

Inputs

  • lam the mean number of events (lambda > 0)
  • k number of events integer

Returns

  • probability the Poisson probability

Applies when

  • events independent, at a constant mean rate
  • lambda > 0, k a whole number

Example

m.ask("For a Poisson distribution with lambda = 4, find the probability of at most k = 2 events.")
→ probability = 0.238103
Poisson probability: exactly k eventspoisson_exactly

The probability of exactly k events when events occur independently at mean rate lambda per interval.

P(X = k) = \frac{e^{-\lambda}\lambda^k}{k!}

Inputs

  • lam the mean number of events (lambda > 0)
  • k number of events integer

Returns

  • probability the Poisson probability

Applies when

  • events independent, at a constant mean rate
  • lambda > 0, k a whole number

Example

m.ask("For a Poisson distribution with lambda = 4, find the probability of exactly k = 2 events.")
→ probability = 0.146525

Quality control 6

c chart limits (defects per unit)c_chart

Centre line and 3-sigma limits of a c chart from counts of defects per inspection unit.

\bar{c} \pm 3\sqrt{\bar{c}}

Inputs

  • counts defects counted in each unit vector

Returns

  • center c-bar
  • ucl c-bar + 3 sqrt(c-bar)
  • lcl max(0, c-bar - 3 sqrt(c-bar))

Applies when

  • constant inspection unit
  • Poisson-distributed counts

Example

m.ask("Find the c chart limits for defect counts [3, 5, 2, 6, 4, 7, 3, 4].")
→ center = 4.25, ucl = 10.4347, lcl = 0
Individuals and moving range (I-MR) chart limitsindividuals_moving_range_chart

Control limits of the individuals (X) and moving range charts from individual measurements in time order.

UCL_x = \bar{x} + 2.66\,\overline{MR}

Inputs

  • x individual measurements in time order vector

Returns

  • center mean
  • mean_moving_range average moving range of span 2
  • x_ucl mean + 2.66 MR-bar
  • x_lcl mean - 2.66 MR-bar
  • mr_ucl 3.267 MR-bar
  • mr_lcl 0

Applies when

  • measurements in time order
  • constants E2 = 2.66 (3/d2) and D4 = 3.267 for span 2

Example

m.ask("Find the I-MR chart limits for [10.2, 9.8, 10.5, 10.1, 9.7, 10.3, 10.0].")
→ center = 10.0857, mean_moving_range = 0.466667, x_ucl = 11.327, x_lcl = 8.84438, mr_ucl = 1.5246, mr_lcl = 0
p chart limits (fraction defective)p_chart

Centre line and 3-sigma limits of a p chart from counts of defective items in samples of constant size n.

\bar{p} \pm 3\sqrt{\frac{\bar{p}(1-\bar{p})}{n}}

Inputs

  • defectives number of defective items in each sample vector
  • n sample size (constant) integer

Returns

  • center p-bar
  • ucl upper control limit (at most 1)
  • lcl lower control limit (at least 0)
  • sigma sqrt(p-bar (1 - p-bar)/n)

Applies when

  • constant sample size
  • LCL truncated at 0

Example

m.ask("Find the p chart limits for defectives [4, 6, 3, 5, 7, 2, 5] with sample size n = 100.")
→ center = 0.0457143, ucl = 0.108374, lcl = 0, sigma = 0.0208865
Process capability (Cp, Cpk) and expected nonconformingprocess_capability

Process capability indices Cp, Cpk (with Cpu, Cpl) and the expected parts per million outside the specification for a normal process with mean mu and standard deviation sigma.

C_p = \frac{USL - LSL}{6\sigma},\quad C_{pk} = \min\left(\frac{USL - \mu}{3\sigma}, \frac{\mu - LSL}{3\sigma}\right)

Inputs

  • mu process mean
  • sigma process standard deviation
  • lsl lower specification limit
  • usl upper specification limit

Returns

  • cp (USL - LSL)/(6 sigma)
  • cpk min(Cpu, Cpl)
  • cpu (USL - mu)/(3 sigma)
  • cpl (mu - LSL)/(3 sigma)
  • ppm_out expected nonconforming parts per million

Applies when

  • normal, stable (in-control) process
  • USL > LSL

Example

m.ask("Find Cp and Cpk for a process with mean = 10.2, standard deviation = 0.1, LSL = 9.8 and USL = 10.5.")
→ cp = 1.16667, cpk = 1, cpu = 1, cpl = 1.33333, ppm_out = 1381.57
X-bar and R control chart limitsxbar_r_chart

Centre lines and 3-sigma control limits of X-bar and R charts from subgroups (rows) of size 2 to 10.

UCL_{\bar{x}} = \bar{\bar{x}} + A_2\bar{R},\quad UCL_R = D_4\bar{R}

Inputs

  • data one row per subgroup, one column per observation (subgroup size 2-10) matrix

Returns

  • center_xbar grand mean
  • mean_range average range
  • xbar_ucl X-bar UCL
  • xbar_lcl X-bar LCL
  • r_ucl R chart UCL
  • r_lcl R chart LCL
  • A2 A2
  • D3 D3
  • D4 D4

Applies when

  • equal subgroup sizes 2 to 10
  • standard 3-decimal control chart constants (A2, D3, D4)

Example

m.ask("Find the X-bar and R chart limits for subgroups [[10.2, 9.9, 10.1, 10.0], [10.3, 10.1, 9.8, 10.2], [9.9, 10.0, 10.1, 9.7]].")
→ center_xbar = 10.025, mean_range = 0.4, xbar_ucl = 10.3166, xbar_lcl = 9.7334, r_ucl = 0.9128, r_lcl = 0, A2 = 0.729, D3 = 0, D4 = 2.282
X-bar and S control chart limitsxbar_s_chart

Centre lines and 3-sigma control limits of X-bar and S charts from subgroups (rows) of size 2 to 10.

UCL_{\bar{x}} = \bar{\bar{x}} + A_3\bar{s},\quad UCL_s = B_4\bar{s}

Inputs

  • data one row per subgroup, one column per observation (subgroup size 2-10) matrix

Returns

  • center_xbar grand mean
  • mean_sd average subgroup standard deviation
  • xbar_ucl X-bar UCL
  • xbar_lcl X-bar LCL
  • s_ucl S chart UCL
  • s_lcl S chart LCL
  • A3 A3
  • B3 B3
  • B4 B4

Applies when

  • equal subgroup sizes 2 to 10
  • standard 3-decimal constants (A3, B3, B4)

Example

m.ask("Find the X-bar and S chart limits for subgroups [[10.2, 9.9, 10.1, 10.0], [10.3, 10.1, 9.8, 10.2], [9.9, 10.0, 10.1, 9.7]].")
→ center_xbar = 10.025, mean_sd = 0.171969, xbar_ucl = 10.305, xbar_lcl = 9.74503, s_ucl = 0.389681, s_lcl = 0, A3 = 1.628, B3 = 0, B4 = 2.266

Regression and correlation 10

Confidence interval for a correlation (Fisher z)correlation_confidence_interval

The Fisher z-transformation confidence interval for the population correlation from paired data.

\tanh\left(\operatorname{atanh}(r) \pm \frac{z_{\alpha/2}}{\sqrt{n-3}}\right)

Inputs

  • x values of the first variable (x) vector
  • y paired values of the second variable (y) vector
  • confidence confidence level as a fraction (0.95 for 95%)

Returns

  • r sample correlation
  • lower lower limit
  • upper upper limit

Applies when

  • bivariate normal data
  • at least 4 pairs
  • |r| < 1

Example

m.ask("Find the 95% confidence interval for the correlation of x = [1, 2, 3, 4, 5, 6] and y = [2, 3, 5, 4, 6, 7].")
→ r = 0.942857, lower = 0.559149, upper = 0.9939
Covariancecovariance

The sample (n - 1) and population (n) covariance of paired data.

s_{xy} = \frac{1}{n-1}\sum (x_i - \bar{x})(y_i - \bar{y})

Inputs

  • x values of the first variable (x) vector
  • y paired values of the second variable (y) vector

Returns

  • sample_covariance divisor n - 1
  • population_covariance divisor n

Example

m.ask("Find the covariance of x = [2, 4, 6, 8] and y = [1, 3, 2, 5].")
→ sample_covariance = 3.66667, population_covariance = 2.75
Durbin-Watson statisticdurbin_watson

The Durbin-Watson statistic of regression residuals (about 2: no first-order autocorrelation; towards 0: positive; towards 4: negative).

d = \frac{\sum_{t=2}^{n} (e_t - e_{t-1})^2}{\sum_{t=1}^{n} e_t^2}

Inputs

  • residuals regression residuals in time order vector

Returns

  • durbin_watson sum of squared successive differences / sum of squares

Applies when

  • residuals in time order

Example

m.ask("Compute the Durbin-Watson statistic for residuals [0.5, -0.2, 0.3, -0.4, 0.1, 0.6, -0.5].")
→ durbin_watson = 2.53448
Kendall's tau-b rank correlationkendall_tau

Kendall's tau-b (tie-adjusted) between paired data with its two-sided large-sample p-value.

\tau_b = \frac{C - D}{\sqrt{(n_0 - n_1)(n_0 - n_2)}}

Inputs

  • x values of the first variable (x) vector
  • y paired values of the second variable (y) vector

Returns

  • tau Kendall's tau-b
  • p_value two-sided p-value (normal approximation with tie correction)
  • concordant concordant pairs
  • discordant discordant pairs

Applies when

  • paired ordinal or continuous data
  • large-sample normal approximation for the p-value

Example

m.ask("Find Kendall's tau for x = [1, 2, 3, 4, 5, 6] and y = [2, 1, 4, 3, 6, 5].")
→ tau = 0.6, p_value = 0.0908739, concordant = 12, discordant = 3
Multiple linear regressionmultiple_linear_regression

Ordinary least squares with several predictors: coefficients (intercept first), R squared, adjusted R squared and the overall F-test.

\hat{\beta} = (X^\top X)^{-1}X^\top y,\quad R^2 = 1 - \frac{SSE}{SST}

Inputs

  • X predictor matrix: one row per observation, one column per predictor matrix
  • y response values vector

Returns

  • coefficients [intercept, b1, ..., bk]
  • r_squared R squared
  • adj_r_squared adjusted R squared
  • f overall F statistic
  • f_p_value p-value of the F test
  • residual_se residual standard error

Applies when

  • n > k + 1
  • predictors not collinear
  • inference assumes independent normal errors

Example

m.ask("Fit a multiple regression of y = [10, 12, 15, 19, 22, 25] on X = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5]].")
→ coefficients = [6.229166666666668, 3.0625, 0.06249999999999978], r_squared = 0.993659, adj_r_squared = 0.989431, f = 235.038, f_p_value = 0.000504992, residual_se = 0.600925
Pearson correlation coefficientpearson_correlation

Pearson's correlation coefficient r between paired data, r squared, and the two-sided p-value for H0: rho = 0.

r = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum (x_i - \bar{x})^2 \sum (y_i - \bar{y})^2}}

Inputs

  • x values of the first variable (x) vector
  • y paired values of the second variable (y) vector

Returns

  • r correlation coefficient
  • r_squared coefficient of determination
  • p_value two-sided p-value (t with n - 2 df)
  • n number of pairs

Applies when

  • paired observations
  • linear relationship; the p-value assumes bivariate normality

Example

m.ask("Find the correlation coefficient of x = [1, 2, 3, 4, 5] and y = [2, 4, 5, 4, 5].")
→ r = 0.774597, r_squared = 0.6, p_value = 0.124027, n = 5
Prediction from a least squares lineregression_prediction

The predicted y at a given x0 from the least-squares line fitted to paired data.

\hat{y}_0 = b_0 + b_1 x_0

Inputs

  • x values of the first variable (x) vector
  • y paired values of the second variable (y) vector
  • x0 the x value to predict at

Returns

  • y_hat b0 + b1 x0
  • slope slope
  • intercept intercept

Applies when

  • x0 within the range of the data (extrapolation is unreliable)

Example

m.ask("Using the regression line for x = [1, 2, 3, 4, 5] and y = [2.2, 4.1, 6.1, 7.9, 10.2], predict y at x0 = 3.5.")
→ y_hat = 7.09, slope = 1.98, intercept = 0.16
Significance test for a correlation coefficientcorrelation_t_test

The t-test of H0: rho = 0 from a sample correlation r and the number of pairs n.

t = r\sqrt{\frac{n-2}{1-r^2}}

Inputs

  • r sample correlation coefficient
  • n number of pairs (>= 3) integer
  • alternative alternative hypothesis: two-sided (default), greater or less choice optional

Returns

  • t r sqrt((n - 2)/(1 - r^2))
  • df n - 2
  • p_value p-value

Applies when

  • -1 < r < 1
  • bivariate normal data

Example

m.ask("Test the significance of a correlation r = 0.45 with n = 30 pairs, two-sided.")
→ t = 2.66641, df = 28, p_value = 0.0125911
Simple linear regression (least squares line)simple_linear_regression

The least-squares line y = intercept + slope x: coefficients, r, r squared, standard errors and the slope's p-value.

\hat{y} = b_0 + b_1 x,\quad b_1 = \frac{S_{xy}}{S_{xx}},\quad b_0 = \bar{y} - b_1\bar{x}

Inputs

  • x values of the first variable (x) vector
  • y paired values of the second variable (y) vector

Returns

  • slope b1 = Sxy/Sxx
  • intercept b0 = ybar - b1 xbar
  • r correlation
  • r_squared coefficient of determination
  • p_value two-sided p-value for H0: slope = 0
  • slope_se standard error of the slope
  • intercept_se standard error of the intercept
  • residual_se residual standard error

Applies when

  • at least 3 pairs, x not all equal
  • inference assumes independent normal errors with constant variance

Example

m.ask("Find the least squares regression line for x = [1, 2, 3, 4, 5] and y = [2.2, 4.1, 6.1, 7.9, 10.2].")
→ slope = 1.98, intercept = 0.16, r = 0.999287, r_squared = 0.998574, p_value = 2.28734e-05, slope_se = 0.0432049, intercept_se = 0.143295, residual_se = 0.136626
Spearman rank correlationspearman_correlation

Spearman's rank correlation coefficient (ties given average ranks) with its two-sided p-value.

\rho_s = r\left(\operatorname{rank}(x), \operatorname{rank}(y)\right)

Inputs

  • x values of the first variable (x) vector
  • y paired values of the second variable (y) vector

Returns

  • rho Spearman's rho
  • p_value two-sided p-value (t approximation, n - 2 df)
  • n pairs

Applies when

  • paired ordinal or continuous data
  • p-value by the t approximation

Example

m.ask("Find the Spearman rank correlation of x = [10, 20, 30, 40, 50] and y = [12, 25, 22, 41, 48].")
→ rho = 0.9, p_value = 0.0373861, n = 5

Reliability and survival 7

Exponential reliability (constant failure rate)exponential_reliability

Reliability R(t) = exp(-lambda t), unreliability and MTTF for a constant failure rate (given the rate or the MTBF).

R(t) = e^{-\lambda t},\quad MTTF = 1/\lambda

Inputs

  • t mission time
  • rate failure rate lambda optional
  • mtbf mean time between failures (instead of the rate) optional

Returns

  • reliability exp(-lambda t)
  • unreliability 1 - R(t)
  • mttf 1/lambda
  • failure_rate lambda

Applies when

  • constant failure rate (useful-life period)
  • exactly one of rate or MTBF

Example

m.ask("Find the reliability at t = 1000 hours for a constant failure rate = 0.0002 per hour.")
→ reliability = 0.818731, unreliability = 0.181269, mttf = 5000, failure_rate = 0.0002
k-out-of-n system reliabilityk_out_of_n_reliability

The reliability of a system that works when at least k of n identical independent components work.

R = \sum_{j=k}^{n}\binom{n}{j} r^j (1-r)^{n-j}

Inputs

  • n number of components integer
  • k number that must work integer
  • r reliability of one component

Returns

  • reliability P(at least k of n work)

Applies when

  • identical, independent components

Example

m.ask("Find the reliability of a k-out-of-n system with k = 2, n = 3 and component reliability = 0.9.")
→ reliability = 0.972
Kaplan-Meier survival estimatekaplan_meier

The Kaplan-Meier (product-limit) estimate of the survival function from times with event/censoring indicators, evaluated at time t, and the whole step curve.

\hat{S}(t) = \prod_{t_i \le t}\left(1 - \frac{d_i}{n_i}\right)

Inputs

  • times follow-up times vector
  • events 1 = event observed, 0 = censored vector
  • t time at which to report S(t)

Returns

  • survival S(t)
  • event_times distinct event times
  • survival_curve S just after each event time

Applies when

  • non-informative censoring
  • a censoring at an event time counts as still at risk

Example

m.ask("Kaplan-Meier: times [6, 6, 6, 7, 10, 13, 16, 22, 23] with events [1, 1, 1, 0, 1, 1, 1, 1, 1]; find the survival at t = 12.")
→ survival = 0.533333, event_times = [6.0, 10.0, 13.0, 16.0, 22.0, 23.0], survival_curve = [0.6666666666666667, 0.5333333333333334, 0.4000000000000001, 0.2666666666666668, 0.1333333333333334, 0.0]
Log-rank test comparing two survival curveslog_rank_test

The log-rank (Mantel-Cox) test of equal survival in two groups from times and event indicators.

\chi^2 = \frac{\left(\sum (d_{1i} - e_{1i})\right)^2}{\sum v_i}

Inputs

  • times1 times, group 1 vector
  • events1 events (1/0), group 1 vector
  • times2 times, group 2 vector
  • events2 events (1/0), group 2 vector

Returns

  • chi_square (O1 - E1)^2 / V
  • p_value chi-square p-value (1 df)
  • observed_1 events in group 1
  • expected_1 expected events in group 1

Applies when

  • non-informative censoring
  • proportional hazards gives the test its best power

Example

m.ask("Log-rank test: group 1 times [6, 6, 6, 7, 10, 13, 16] events [1, 1, 1, 0, 1, 1, 1], group 2 times [1, 1, 2, 2, 3, 4, 4] events [1, 1, 1, 1, 1, 1, 1].")
→ chi_square = 13.8115, p_value = 0.000202097, observed_1 = 6, expected_1 = 10.4222
Reliability of a parallel systemparallel_system_reliability

The reliability of independent components in parallel (at least one must work).

R_p = 1 - \prod (1 - R_i)

Inputs

  • r component reliabilities (0 to 1) vector

Returns

  • reliability system reliability

Applies when

  • independent components

Example

m.ask("Find the reliability of a parallel system with component reliabilities [0.95, 0.9, 0.98].")
→ reliability = 0.9999
Reliability of a series systemseries_system_reliability

The reliability of independent components in series (all must work).

R_s = \prod R_i

Inputs

  • r component reliabilities (0 to 1) vector

Returns

  • reliability system reliability

Applies when

  • independent components

Example

m.ask("Find the reliability of a series system with component reliabilities [0.95, 0.9, 0.98].")
→ reliability = 0.8379
Weibull reliability, hazard rate and MTTFweibull_reliability

Reliability R(t), unreliability, hazard rate and mean time to failure of a two-parameter Weibull distribution.

R(t) = e^{-(t/\eta)^\beta},\quad h(t) = \frac{\beta}{\eta}\left(\frac{t}{\eta}\right)^{\beta-1}

Inputs

  • beta shape parameter beta
  • eta scale parameter eta (characteristic life)
  • t time

Returns

  • reliability exp(-(t/eta)^beta)
  • unreliability 1 - R(t)
  • hazard_rate (beta/eta)(t/eta)^(beta-1)
  • mttf eta Gamma(1 + 1/beta)

Applies when

  • two-parameter Weibull (no location shift)
  • t >= 0

Example

m.ask("For a Weibull distribution with beta = 2 and eta = 1000 hours, find the reliability at t = 500.")
→ reliability = 0.778801, unreliability = 0.221199, hazard_rate = 0.001, mttf = 886.227

Sampling distributions 2

Probability that a sample mean is above a valuesample_mean_probability_above

P(sample mean > x) for samples of size n from a population with mean mu and standard deviation sigma (central limit theorem).

P(\bar{X} < x) = \Phi\left(\frac{x - \mu}{\sigma/\sqrt{n}}\right)

Inputs

  • x the value for the sample mean
  • mu population mean
  • sigma population standard deviation
  • n sample size integer

Returns

  • probability the probability
  • z z = (x - mu)/(sigma/sqrt(n))
  • standard_error sigma/sqrt(n)

Applies when

  • population normal, or n large enough for the central limit theorem
  • independent observations

Example

m.ask("A population has mean = 50 and standard deviation = 10; for a sample of size n = 25, find the probability that the sample mean is greater than 52.")
→ probability = 0.158655, z = 1, standard_error = 2
Probability that a sample mean is below a valuesample_mean_probability_below

P(sample mean < x) for samples of size n from a population with mean mu and standard deviation sigma (central limit theorem).

P(\bar{X} < x) = \Phi\left(\frac{x - \mu}{\sigma/\sqrt{n}}\right)

Inputs

  • x the value for the sample mean
  • mu population mean
  • sigma population standard deviation
  • n sample size integer

Returns

  • probability the probability
  • z z = (x - mu)/(sigma/sqrt(n))
  • standard_error sigma/sqrt(n)

Applies when

  • population normal, or n large enough for the central limit theorem
  • independent observations

Example

m.ask("A population has mean = 50 and standard deviation = 10; for a sample of size n = 25, find the probability that the sample mean is less than 52.")
→ probability = 0.841345, z = 1, standard_error = 2
Questions

Frequently asked

What does statistics-ai999x do?

Statistics answers questions in statistics: descriptive statistics, probability distributions, confidence intervals, hypothesis tests, regression and correlation, experimental design, quality control and reliability. Each answer gives the value with its unit, the steps and the formula in LaTeX.

How do I install statistics-ai999x?

With pip: pip install statistics-ai999x. The same files are on Hugging Face (hf download AI999X/statistics-ai999x --local-dir statistics-ai999x) and GitHub.

Does it run offline?

Yes. It is a Python package that runs on an ordinary CPU without a network connection (Python >=3.10); no GPU and no API key are needed.

How many capabilities does statistics-ai999x have?

110 capabilities in 16 topics, including Descriptive statistics, Probability distributions, Hypothesis tests, Regression and correlation, Confidence intervals.

Which field and tasks does it cover?

Field: Mathematics & Statistics. Tasks: Question Answering, Token Classification, Text Classification, Tabular Regression, Sentence Similarity, Feature Extraction.

What does an answer look like?

Asked "Perform a one-sample t-test of [5.1, 4.9, 5.3, 5.5, 5.0, 5.2] against mu0 = 5, two-sided.", it answers: t = 1.88982, df = 5, p_value = 0.117387, mean = 5.16667, standard_deviation = 0.216025.

What happens when a question cannot be answered?

It says so and names what is missing or out of range, instead of guessing a number.

More from AI999X

Explore every model.