pyyeti.stats.ksingle

pyyeti.stats.ksingle(p, c, n)[source]

Compute statistical k-factor for a single-sided tolerance limit.

Parameters:
  • p (scalar or array_like; real) – Portion of population to bound; 0 < p < 1

  • c (scalar or array_like; real) – Probability level (confidence); 0 < c < 1

  • n (scalar or array_like; integer) – Number of observations in sample; n > 1

Returns:

k (scalar or ndarray; real) – The statistical k-factor for a single-sided tolerance limit.

Notes

The inputs p, c, and n must be broadcast-compatible.

The k-factor allows the computation of a tolerance bound that has the probability c of bounding at least the proportion p of the population. The statistics are based on having a sample of a normally distributed population; n is the number of observations in the sample.

The tolerance bound is computed by:

bound = m + k std  (or  bound = m - k std)

where m is the sample mean and std is the sample standard deviation.

Note

The math behind this routine is covered in the pyYeti Tutorials: Calculating MPE and Qual statistical levels from flight data. There is also a link to the source Jupyter notebook at the top of the tutorial.

See also

kdouble()

Examples

Assume we have 21 samples. Determine the k-factor to have a 90% probability of bounding 99% of the population. In other words, we need the ‘P99/90’ single-sided k-factor for N = 21. (From table: N = 21, k = 3.028)

>>> from pyyeti.stats import ksingle
>>> ksingle(.99, .90, 21)
3.02823...

Make a table of single-sided k-factors using 50% confidence. The probabilities will be: 95%, 97.725%, 99% and 99.865%. Number of samples will be: 2-10, 1000000. Have n define the rows and p define the columns:

>>> import numpy as np
>>> from pandas import DataFrame
>>> n = [[i] for i in range(2, 11)]  # create list of lists
>>> n.append([1000000])
>>> p = [.95, .97725, .99, .99865]
>>> table = ksingle(p, .50, n)
>>> DataFrame(table, index=[i[0] for i in n], columns=p)
          0.95000   0.97725   0.99000   0.99865
2        2.338727  2.880624  3.375968  4.391208
3        1.938416  2.369068  2.764477  3.579188
4        1.829514  2.231482  2.600817  3.362580
5        1.779283  2.168283  2.525770  3.263359
6        1.750462  2.132099  2.482840  3.206631
7        1.731792  2.108690  2.455081  3.169958
8        1.718720  2.092314  2.435669  3.144318
9        1.709060  2.080220  2.421337  3.125390
10       1.701632  2.070925  2.410323  3.110845
1000000  1.644854  2.000003  2.326349  2.999978