package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
val get_py : string -> Py.Object.t

Get an attribute of this module as a Py.Object.t. This is useful to pass a Python function to another function.

val argstoarray : Py.Object.t list -> Py.Object.t

Constructs a 2D array from a group of sequences.

Sequences are filled with missing values to match the length of the longest sequence.

Parameters ---------- args : sequences Group of sequences.

Returns ------- argstoarray : MaskedArray A ( `m` x `n` ) masked array, where `m` is the number of arguments and `n` the length of the longest argument.

Notes ----- `numpy.ma.row_stack` has identical behavior, but is called with a sequence of sequences.

val brunnermunzel : ?alternative:[ `Less | `Two_sided | `Greater ] -> ?distribution:[ `T | `Normal ] -> x:Py.Object.t -> y:Py.Object.t -> unit -> float * float

Computes the Brunner-Munzel test on samples x and y

Missing values in `x` and/or `y` are discarded.

Parameters ---------- x, y : array_like Array of samples, should be one-dimensional. alternative : 'less', 'two-sided', or 'greater', optional Whether to get the p-value for the one-sided hypothesis ('less' or 'greater') or for the two-sided hypothesis ('two-sided'). Defaults value is 'two-sided' . distribution: 't' or 'normal', optional Whether to get the p-value by t-distribution or by standard normal distribution. Defaults value is 't' .

Returns ------- statistic : float The Brunner-Munzer W statistic. pvalue : float p-value assuming an t distribution. One-sided or two-sided, depending on the choice of `alternative` and `distribution`.

See Also -------- mannwhitneyu : Mann-Whitney rank test on two samples.

Notes ------- For more details on `brunnermunzel`, see `stats.brunnermunzel`.

val chisquare : ?f_exp:[> `Ndarray ] Np.Obj.t -> ?ddof:int -> ?axis:[ `I of int | `None ] -> f_obs:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t * Py.Object.t

Calculate a one-way chi-square test.

The chi-square test tests the null hypothesis that the categorical data has the given frequencies.

Parameters ---------- f_obs : array_like Observed frequencies in each category. f_exp : array_like, optional Expected frequencies in each category. By default the categories are assumed to be equally likely. ddof : int, optional 'Delta degrees of freedom': adjustment to the degrees of freedom for the p-value. The p-value is computed using a chi-squared distribution with ``k - 1 - ddof`` degrees of freedom, where `k` is the number of observed frequencies. The default value of `ddof` is 0. axis : int or None, optional The axis of the broadcast result of `f_obs` and `f_exp` along which to apply the test. If axis is None, all values in `f_obs` are treated as a single data set. Default is 0.

Returns ------- chisq : float or ndarray The chi-squared test statistic. The value is a float if `axis` is None or `f_obs` and `f_exp` are 1-D. p : float or ndarray The p-value of the test. The value is a float if `ddof` and the return value `chisq` are scalars.

See Also -------- scipy.stats.power_divergence

Notes ----- This test is invalid when the observed or expected frequencies in each category are too small. A typical rule is that all of the observed and expected frequencies should be at least 5.

The default degrees of freedom, k-1, are for the case when no parameters of the distribution are estimated. If p parameters are estimated by efficient maximum likelihood then the correct degrees of freedom are k-1-p. If the parameters are estimated in a different way, then the dof can be between k-1-p and k-1. However, it is also possible that the asymptotic distribution is not chi-square, in which case this test is not appropriate.

References ---------- .. 1 Lowry, Richard. 'Concepts and Applications of Inferential Statistics'. Chapter 8. https://web.archive.org/web/20171022032306/http://vassarstats.net:80/textbook/ch8pt1.html .. 2 'Chi-squared test', https://en.wikipedia.org/wiki/Chi-squared_test

Examples -------- When just `f_obs` is given, it is assumed that the expected frequencies are uniform and given by the mean of the observed frequencies.

>>> from scipy.stats import chisquare >>> chisquare(16, 18, 16, 14, 12, 12) (2.0, 0.84914503608460956)

With `f_exp` the expected frequencies can be given.

>>> chisquare(16, 18, 16, 14, 12, 12, f_exp=16, 16, 16, 16, 16, 8) (3.5, 0.62338762774958223)

When `f_obs` is 2-D, by default the test is applied to each column.

>>> obs = np.array([16, 18, 16, 14, 12, 12], [32, 24, 16, 28, 20, 24]).T >>> obs.shape (6, 2) >>> chisquare(obs) (array( 2. , 6.66666667), array( 0.84914504, 0.24663415))

By setting ``axis=None``, the test is applied to all data in the array, which is equivalent to applying the test to the flattened array.

>>> chisquare(obs, axis=None) (23.31034482758621, 0.015975692534127565) >>> chisquare(obs.ravel()) (23.31034482758621, 0.015975692534127565)

`ddof` is the change to make to the default degrees of freedom.

>>> chisquare(16, 18, 16, 14, 12, 12, ddof=1) (2.0, 0.73575888234288467)

The calculation of the p-values is done by broadcasting the chi-squared statistic with `ddof`.

>>> chisquare(16, 18, 16, 14, 12, 12, ddof=0,1,2) (2.0, array( 0.84914504, 0.73575888, 0.5724067 ))

`f_obs` and `f_exp` are also broadcast. In the following, `f_obs` has shape (6,) and `f_exp` has shape (2, 6), so the result of broadcasting `f_obs` and `f_exp` has shape (2, 6). To compute the desired chi-squared statistics, we use ``axis=1``:

>>> chisquare(16, 18, 16, 14, 12, 12, ... f_exp=[16, 16, 16, 16, 16, 8], [8, 20, 20, 16, 12, 12], ... axis=1) (array( 3.5 , 9.25), array( 0.62338763, 0.09949846))

val compare_medians_ms : ?axis:int -> group_1:[> `Ndarray ] Np.Obj.t -> group_2:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Compares the medians from two independent groups along the given axis.

The comparison is performed using the McKean-Schrader estimate of the standard error of the medians.

Parameters ---------- group_1 : array_like First dataset. Has to be of size >=7. group_2 : array_like Second dataset. Has to be of size >=7. axis : int, optional Axis along which the medians are estimated. If None, the arrays are flattened. If `axis` is not None, then `group_1` and `group_2` should have the same shape.

Returns ------- compare_medians_ms : float, ndarray If `axis` is None, then returns a float, otherwise returns a 1-D ndarray of floats with a length equal to the length of `group_1` along `axis`.

val count_tied_groups : ?use_missing:bool -> x:Py.Object.t -> unit -> Py.Object.t

Counts the number of tied values.

Parameters ---------- x : sequence Sequence of data on which to counts the ties use_missing : bool, optional Whether to consider missing values as tied.

Returns ------- count_tied_groups : dict Returns a dictionary (nb of ties: nb of groups).

Examples -------- >>> from scipy.stats import mstats >>> z = 0, 0, 0, 2, 2, 2, 3, 3, 4, 5, 6 >>> mstats.count_tied_groups(z)

1, 3: 2

In the above example, the ties were 0 (3x), 2 (3x) and 3 (2x).

>>> z = np.ma.array(0, 0, 1, 2, 2, 2, 3, 3, 4, 5, 6) >>> mstats.count_tied_groups(z)

2, 3: 1

>>> z[1,-1] = np.ma.masked >>> mstats.count_tied_groups(z, use_missing=True)

2, 3: 1

val describe : ?axis:[ `I of int | `None ] -> ?ddof:int -> ?bias:bool -> a:[> `Ndarray ] Np.Obj.t -> unit -> int * (int * int) * float * float * float * float

Computes several descriptive statistics of the passed array.

Parameters ---------- a : array_like Data array axis : int or None, optional Axis along which to calculate statistics. Default 0. If None, compute over the whole array `a`. ddof : int, optional degree of freedom (default 0); note that default ddof is different from the same routine in stats.describe bias : bool, optional If False, then the skewness and kurtosis calculations are corrected for statistical bias.

Returns ------- nobs : int (size of the data (discarding missing values)

minmax : (int, int) min, max

mean : float arithmetic mean

variance : float unbiased variance

skewness : float biased skewness

kurtosis : float biased kurtosis

Examples -------- >>> from scipy.stats.mstats import describe >>> ma = np.ma.array(range(6), mask=0, 0, 0, 1, 1, 1) >>> describe(ma) DescribeResult(nobs=3, minmax=(masked_array(data=0, mask=False, fill_value=999999), masked_array(data=2, mask=False, fill_value=999999)), mean=1.0, variance=0.6666666666666666, skewness=masked_array(data=0., mask=False, fill_value=1e+20), kurtosis=-1.5)

val f_oneway : Py.Object.t list -> float * float

Performs a 1-way ANOVA, returning an F-value and probability given any number of groups. From Heiman, pp.394-7.

Usage: ``f_oneway( *args)``, where ``*args`` is 2 or more arrays, one per treatment group.

Returns ------- statistic : float The computed F-value of the test. pvalue : float The associated p-value from the F-distribution.

val find_repeats : Py.Object.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t * [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Find repeats in arr and return a tuple (repeats, repeat_count).

The input is cast to float64. Masked values are discarded.

Parameters ---------- arr : sequence Input array. The array is flattened if it is not 1D.

Returns ------- repeats : ndarray Array of repeated values. counts : ndarray Array of counts.

val friedmanchisquare : Py.Object.t list -> float * float

Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA. This function calculates the Friedman Chi-square test for repeated measures and returns the result, along with the associated probability value.

Each input is considered a given group. Ideally, the number of treatments among each group should be equal. If this is not the case, only the first n treatments are taken into account, where n is the number of treatments of the smallest group. If a group has some missing values, the corresponding treatments are masked in the other groups. The test statistic is corrected for ties.

Masked values in one group are propagated to the other groups.

Returns ------- statistic : float the test statistic. pvalue : float the associated p-value.

val gmean : ?axis:[ `I of int | `None ] -> ?dtype:Np.Dtype.t -> a:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Compute the geometric mean along the specified axis.

Return the geometric average of the array elements. That is: n-th root of (x1 * x2 * ... * xn)

Parameters ---------- a : array_like Input array or object that can be converted to an array. axis : int or None, optional Axis along which the geometric mean is computed. Default is 0. If None, compute over the whole array `a`. dtype : dtype, optional Type of the returned array and of the accumulator in which the elements are summed. If dtype is not specified, it defaults to the dtype of a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used.

Returns ------- gmean : ndarray See `dtype` parameter above.

See Also -------- numpy.mean : Arithmetic average numpy.average : Weighted average hmean : Harmonic mean

Notes ----- The geometric average is computed over a single dimension of the input array, axis=0 by default, or all values in the array if axis=None. float64 intermediate and return values are used for integer inputs.

Use masked arrays to ignore any non-finite values in the input or that arise in the calculations such as Not a Number and infinity because masked arrays automatically mask any non-finite values.

Examples -------- >>> from scipy.stats import gmean >>> gmean(1, 4) 2.0 >>> gmean(1, 2, 3, 4, 5, 6, 7) 3.3800151591412964

val hdmedian : ?axis:int -> ?var:bool -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Returns the Harrell-Davis estimate of the median along the given axis.

Parameters ---------- data : ndarray Data array. axis : int, optional Axis along which to compute the quantiles. If None, use a flattened array. var : bool, optional Whether to return the variance of the estimate.

Returns ------- hdmedian : MaskedArray The median values. If ``var=True``, the variance is returned inside the masked array. E.g. for a 1-D array the shape change from (1,) to (2,).

val hdquantiles : ?prob:Py.Object.t -> ?axis:int -> ?var:bool -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Computes quantile estimates with the Harrell-Davis method.

The quantile estimates are calculated as a weighted linear combination of order statistics.

Parameters ---------- data : array_like Data array. prob : sequence, optional Sequence of quantiles to compute. axis : int or None, optional Axis along which to compute the quantiles. If None, use a flattened array. var : bool, optional Whether to return the variance of the estimate.

Returns ------- hdquantiles : MaskedArray A (p,) array of quantiles (if `var` is False), or a (2,p) array of quantiles and variances (if `var` is True), where ``p`` is the number of quantiles.

See Also -------- hdquantiles_sd

val hdquantiles_sd : ?prob:Py.Object.t -> ?axis:int -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

The standard error of the Harrell-Davis quantile estimates by jackknife.

Parameters ---------- data : array_like Data array. prob : sequence, optional Sequence of quantiles to compute. axis : int, optional Axis along which to compute the quantiles. If None, use a flattened array.

Returns ------- hdquantiles_sd : MaskedArray Standard error of the Harrell-Davis quantile estimates.

See Also -------- hdquantiles

val hmean : ?axis:[ `I of int | `None ] -> ?dtype:Np.Dtype.t -> a:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Calculate the harmonic mean along the specified axis.

That is: n / (1/x1 + 1/x2 + ... + 1/xn)

Parameters ---------- a : array_like Input array, masked array or object that can be converted to an array. axis : int or None, optional Axis along which the harmonic mean is computed. Default is 0. If None, compute over the whole array `a`. dtype : dtype, optional Type of the returned array and of the accumulator in which the elements are summed. If `dtype` is not specified, it defaults to the dtype of `a`, unless `a` has an integer `dtype` with a precision less than that of the default platform integer. In that case, the default platform integer is used.

Returns ------- hmean : ndarray See `dtype` parameter above.

See Also -------- numpy.mean : Arithmetic average numpy.average : Weighted average gmean : Geometric mean

Notes ----- The harmonic mean is computed over a single dimension of the input array, axis=0 by default, or all values in the array if axis=None. float64 intermediate and return values are used for integer inputs.

Use masked arrays to ignore any non-finite values in the input or that arise in the calculations such as Not a Number and infinity.

Examples -------- >>> from scipy.stats import hmean >>> hmean(1, 4) 1.6000000000000001 >>> hmean(1, 2, 3, 4, 5, 6, 7) 2.6997245179063363

val idealfourths : ?axis:int -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Returns an estimate of the lower and upper quartiles.

Uses the ideal fourths algorithm.

Parameters ---------- data : array_like Input array. axis : int, optional Axis along which the quartiles are estimated. If None, the arrays are flattened.

Returns ------- idealfourths :

st of floats, masked array

}

Returns the two internal values that divide `data` into four parts using the ideal fourths algorithm either along the flattened array (if `axis` is None) or along `axis` of `data`.

val kendalltau : ?use_ties:bool -> ?use_missing:bool -> ?method_:[ `Auto | `Asymptotic | `Exact ] -> x:Py.Object.t -> y:Py.Object.t -> unit -> float * float

Computes Kendall's rank correlation tau on two variables *x* and *y*.

Parameters ---------- x : sequence First data list (for example, time). y : sequence Second data list. use_ties : True, False, optional Whether ties correction should be performed. use_missing : False, True, optional Whether missing data should be allocated a rank of 0 (False) or the average rank (True) method: 'auto', 'asymptotic', 'exact', optional Defines which method is used to calculate the p-value 1_. 'asymptotic' uses a normal approximation valid for large samples. 'exact' computes the exact p-value, but can only be used if no ties are present. 'auto' is the default and selects the appropriate method based on a trade-off between speed and accuracy.

Returns ------- correlation : float Kendall tau pvalue : float Approximate 2-side p-value.

References ---------- .. 1 Maurice G. Kendall, 'Rank Correlation Methods' (4th Edition), Charles Griffin & Co., 1970.

val kendalltau_seasonal : Py.Object.t -> Py.Object.t

Computes a multivariate Kendall's rank correlation tau, for seasonal data.

Parameters ---------- x : 2-D ndarray Array of seasonal data, with seasons in columns.

val kruskal : Py.Object.t list -> float * float

Compute the Kruskal-Wallis H-test for independent samples

Parameters ---------- sample1, sample2, ... : array_like Two or more arrays with the sample measurements can be given as arguments.

Returns ------- statistic : float The Kruskal-Wallis H statistic, corrected for ties pvalue : float The p-value for the test using the assumption that H has a chi square distribution

Notes ----- For more details on `kruskal`, see `stats.kruskal`.

Examples -------- >>> from scipy.stats.mstats import kruskal

Random samples from three different brands of batteries were tested to see how long the charge lasted. Results were as follows:

>>> a = 6.3, 5.4, 5.7, 5.2, 5.0 >>> b = 6.9, 7.0, 6.1, 7.9 >>> c = 7.2, 6.9, 6.1, 6.5

Test the hypotesis that the distribution functions for all of the brands' durations are identical. Use 5% level of significance.

>>> kruskal(a, b, c) KruskalResult(statistic=7.113812154696133, pvalue=0.028526948491942164)

The null hypothesis is rejected at the 5% level of significance because the returned p-value is less than the critical value of 5%.

val kruskalwallis : Py.Object.t list -> float * float

Compute the Kruskal-Wallis H-test for independent samples

Parameters ---------- sample1, sample2, ... : array_like Two or more arrays with the sample measurements can be given as arguments.

Returns ------- statistic : float The Kruskal-Wallis H statistic, corrected for ties pvalue : float The p-value for the test using the assumption that H has a chi square distribution

Notes ----- For more details on `kruskal`, see `stats.kruskal`.

Examples -------- >>> from scipy.stats.mstats import kruskal

Random samples from three different brands of batteries were tested to see how long the charge lasted. Results were as follows:

>>> a = 6.3, 5.4, 5.7, 5.2, 5.0 >>> b = 6.9, 7.0, 6.1, 7.9 >>> c = 7.2, 6.9, 6.1, 6.5

Test the hypotesis that the distribution functions for all of the brands' durations are identical. Use 5% level of significance.

>>> kruskal(a, b, c) KruskalResult(statistic=7.113812154696133, pvalue=0.028526948491942164)

The null hypothesis is rejected at the 5% level of significance because the returned p-value is less than the critical value of 5%.

val ks_2samp : ?alternative:[ `Two_sided | `Less | `Greater ] -> data1:[> `Ndarray ] Np.Obj.t -> data2:[> `Ndarray ] Np.Obj.t -> unit -> float * float

Computes the Kolmogorov-Smirnov test on two samples.

Missing values are discarded.

Parameters ---------- data1 : array_like First data set data2 : array_like Second data set alternative : 'two-sided', 'less', 'greater', optional Indicates the alternative hypothesis. Default is 'two-sided'.

Returns ------- d : float Value of the Kolmogorov Smirnov test p : float Corresponding p-value.

val ks_twosamp : ?alternative:[ `Two_sided | `Less | `Greater ] -> data1:[> `Ndarray ] Np.Obj.t -> data2:[> `Ndarray ] Np.Obj.t -> unit -> float * float

Computes the Kolmogorov-Smirnov test on two samples.

Missing values are discarded.

Parameters ---------- data1 : array_like First data set data2 : array_like Second data set alternative : 'two-sided', 'less', 'greater', optional Indicates the alternative hypothesis. Default is 'two-sided'.

Returns ------- d : float Value of the Kolmogorov Smirnov test p : float Corresponding p-value.

val kurtosis : ?axis:[ `I of int | `None ] -> ?fisher:bool -> ?bias:bool -> a:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Computes the kurtosis (Fisher or Pearson) of a dataset.

Kurtosis is the fourth central moment divided by the square of the variance. If Fisher's definition is used, then 3.0 is subtracted from the result to give 0.0 for a normal distribution.

If bias is False then the kurtosis is calculated using k statistics to eliminate bias coming from biased moment estimators

Use `kurtosistest` to see if result is close enough to normal.

Parameters ---------- a : array data for which the kurtosis is calculated axis : int or None, optional Axis along which the kurtosis is calculated. Default is 0. If None, compute over the whole array `a`. fisher : bool, optional If True, Fisher's definition is used (normal ==> 0.0). If False, Pearson's definition is used (normal ==> 3.0). bias : bool, optional If False, then the calculations are corrected for statistical bias.

Returns ------- kurtosis : array The kurtosis of values along an axis. If all values are equal, return -3 for Fisher's definition and 0 for Pearson's definition.

Notes ----- For more details about `kurtosis`, see `stats.kurtosis`.

val kurtosistest : ?axis:[ `I of int | `None ] -> a:[> `Ndarray ] Np.Obj.t -> unit -> float * float

Tests whether a dataset has normal kurtosis

Parameters ---------- a : array array of the sample data axis : int or None, optional Axis along which to compute test. Default is 0. If None, compute over the whole array `a`.

Returns ------- statistic : float The computed z-score for this test. pvalue : float The 2-sided p-value for the hypothesis test

Notes ----- For more details about `kurtosistest`, see `stats.kurtosistest`.

val linregress : ?y:Py.Object.t -> x:Py.Object.t -> unit -> Py.Object.t

Linear regression calculation

Note that the non-masked version is used, and that this docstring is replaced by the non-masked docstring + some info on missing data.

val mannwhitneyu : ?use_continuity:bool -> x:Py.Object.t -> y:Py.Object.t -> unit -> float * float

Computes the Mann-Whitney statistic

Missing values in `x` and/or `y` are discarded.

Parameters ---------- x : sequence Input y : sequence Input use_continuity : True, False, optional Whether a continuity correction (1/2.) should be taken into account.

Returns ------- statistic : float The Mann-Whitney statistics pvalue : float Approximate p-value assuming a normal distribution.

val median_cihs : ?alpha:float -> ?axis:int -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Computes the alpha-level confidence interval for the median of the data.

Uses the Hettmasperger-Sheather method.

Parameters ---------- data : array_like Input data. Masked values are discarded. The input should be 1D only, or `axis` should be set to None. alpha : float, optional Confidence level of the intervals. axis : int or None, optional Axis along which to compute the quantiles. If None, use a flattened array.

Returns ------- median_cihs Alpha level confidence interval.

val meppf : ?alpha:float -> ?beta:float -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Returns plotting positions (or empirical percentile points) for the data.

Plotting positions are defined as ``(i-alpha)/(n+1-alpha-beta)``, where:

  • i is the rank order statistics
  • n is the number of unmasked values along the given axis
  • `alpha` and `beta` are two parameters.

Typical values for `alpha` and `beta` are:

  • (0,1) : ``p(k) = k/n``, linear interpolation of cdf (R, type 4)
  • (.5,.5) : ``p(k) = (k-1/2.)/n``, piecewise linear function (R, type 5)
  • (0,0) : ``p(k) = k/(n+1)``, Weibull (R type 6)
  • (1,1) : ``p(k) = (k-1)/(n-1)``, in this case, ``p(k) = modeF(x[k])``. That's R default (R type 7)
  • (1/3,1/3): ``p(k) = (k-1/3)/(n+1/3)``, then ``p(k) ~ medianF(x[k])``. The resulting quantile estimates are approximately median-unbiased regardless of the distribution of x. (R type 8)
  • (3/8,3/8): ``p(k) = (k-3/8)/(n+1/4)``, Blom. The resulting quantile estimates are approximately unbiased if x is normally distributed (R type 9)
  • (.4,.4) : approximately quantile unbiased (Cunnane)
  • (.35,.35): APL, used with PWM
  • (.3175, .3175): used in scipy.stats.probplot

Parameters ---------- data : array_like Input data, as a sequence or array of dimension at most 2. alpha : float, optional Plotting positions parameter. Default is 0.4. beta : float, optional Plotting positions parameter. Default is 0.4.

Returns ------- positions : MaskedArray The calculated plotting positions.

val mjci : ?prob:Py.Object.t -> ?axis:int -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Returns the Maritz-Jarrett estimators of the standard error of selected experimental quantiles of the data.

Parameters ---------- data : ndarray Data array. prob : sequence, optional Sequence of quantiles to compute. axis : int or None, optional Axis along which to compute the quantiles. If None, use a flattened array.

val mode : ?axis:[ `I of int | `None ] -> a:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t * [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Returns an array of the modal (most common) value in the passed array.

Parameters ---------- a : array_like n-dimensional array of which to find mode(s). axis : int or None, optional Axis along which to operate. Default is 0. If None, compute over the whole array `a`.

Returns ------- mode : ndarray Array of modal values. count : ndarray Array of counts for each mode.

Notes ----- For more details, see `stats.mode`.

Examples -------- >>> from scipy import stats >>> from scipy.stats import mstats >>> m_arr = np.ma.array(1, 1, 0, 0, 0, 0, mask=0, 0, 1, 1, 1, 0) >>> stats.mode(m_arr) ModeResult(mode=array(0), count=array(4)) >>> mstats.mode(m_arr) ModeResult(mode=array(1.), count=array(2.))

val moment : ?moment:int -> ?axis:[ `I of int | `None ] -> a:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Calculates the nth moment about the mean for a sample.

Parameters ---------- a : array_like data moment : int, optional order of central moment that is returned axis : int or None, optional Axis along which the central moment is computed. Default is 0. If None, compute over the whole array `a`.

Returns ------- n-th central moment : ndarray or float The appropriate moment along the given axis or over all values if axis is None. The denominator for the moment calculation is the number of observations, no degrees of freedom correction is done.

Notes ----- For more details about `moment`, see `stats.moment`.

val mquantiles : ?prob:[> `Ndarray ] Np.Obj.t -> ?alphap:float -> ?betap:float -> ?axis:int -> ?limit:Py.Object.t -> a:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Computes empirical quantiles for a data array.

Samples quantile are defined by ``Q(p) = (1-gamma)*xj + gamma*xj+1``, where ``xj`` is the j-th order statistic, and gamma is a function of ``j = floor(n*p + m)``, ``m = alphap + p*(1 - alphap - betap)`` and ``g = n*p + m - j``.

Reinterpreting the above equations to compare to **R** lead to the equation: ``p(k) = (k - alphap)/(n + 1 - alphap - betap)``

Typical values of (alphap,betap) are:

  • (0,1) : ``p(k) = k/n`` : linear interpolation of cdf ( **R** type 4)
  • (.5,.5) : ``p(k) = (k - 1/2.)/n`` : piecewise linear function ( **R** type 5)
  • (0,0) : ``p(k) = k/(n+1)`` : ( **R** type 6)
  • (1,1) : ``p(k) = (k-1)/(n-1)``: p(k) = modeF(x[k]). ( **R** type 7, **R** default)
  • (1/3,1/3): ``p(k) = (k-1/3)/(n+1/3)``: Then p(k) ~ medianF(x[k]). The resulting quantile estimates are approximately median-unbiased regardless of the distribution of x. ( **R** type 8)
  • (3/8,3/8): ``p(k) = (k-3/8)/(n+1/4)``: Blom. The resulting quantile estimates are approximately unbiased if x is normally distributed ( **R** type 9)
  • (.4,.4) : approximately quantile unbiased (Cunnane)
  • (.35,.35): APL, used with PWM

Parameters ---------- a : array_like Input data, as a sequence or array of dimension at most 2. prob : array_like, optional List of quantiles to compute. alphap : float, optional Plotting positions parameter, default is 0.4. betap : float, optional Plotting positions parameter, default is 0.4. axis : int, optional Axis along which to perform the trimming. If None (default), the input array is first flattened. limit : tuple, optional Tuple of (lower, upper) values. Values of `a` outside this open interval are ignored.

Returns ------- mquantiles : MaskedArray An array containing the calculated quantiles.

Notes ----- This formulation is very similar to **R** except the calculation of ``m`` from ``alphap`` and ``betap``, where in **R** ``m`` is defined with each type.

References ---------- .. 1 *R* statistical software: https://www.r-project.org/ .. 2 *R* ``quantile`` function: http://stat.ethz.ch/R-manual/R-devel/library/stats/html/quantile.html

Examples -------- >>> from scipy.stats.mstats import mquantiles >>> a = np.array(6., 47., 49., 15., 42., 41., 7., 39., 43., 40., 36.) >>> mquantiles(a) array( 19.2, 40. , 42.8)

Using a 2D array, specifying axis and limit.

>>> data = np.array([ 6., 7., 1.], ... [ 47., 15., 2.], ... [ 49., 36., 3.], ... [ 15., 39., 4.], ... [ 42., 40., -999.], ... [ 41., 41., -999.], ... [ 7., -999., -999.], ... [ 39., -999., -999.], ... [ 43., -999., -999.], ... [ 40., -999., -999.], ... [ 36., -999., -999.]) >>> print(mquantiles(data, axis=0, limit=(0, 50))) [19.2 14.6 1.45] [40. 37.5 2.5 ] [42.8 40.05 3.55]

>>> data:, 2 = -999. >>> print(mquantiles(data, axis=0, limit=(0, 50))) [19.200000000000003 14.6 --] [40.0 37.5 --] [42.800000000000004 40.05 --]

val mquantiles_cimj : ?prob:Py.Object.t -> ?alpha:float -> ?axis:int -> data:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t * [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Computes the alpha confidence interval for the selected quantiles of the data, with Maritz-Jarrett estimators.

Parameters ---------- data : ndarray Data array. prob : sequence, optional Sequence of quantiles to compute. alpha : float, optional Confidence level of the intervals. axis : int or None, optional Axis along which to compute the quantiles. If None, use a flattened array.

Returns ------- ci_lower : ndarray The lower boundaries of the confidence interval. Of the same length as `prob`. ci_upper : ndarray The upper boundaries of the confidence interval. Of the same length as `prob`.

val msign : Py.Object.t -> Py.Object.t

Returns the sign of x, or 0 if x is masked.

val normaltest : ?axis:[ `I of int | `None ] -> a:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t * Py.Object.t

Tests whether a sample differs from a normal distribution.

Parameters ---------- a : array_like The array containing the data to be tested. axis : int or None, optional Axis along which to compute test. Default is 0. If None, compute over the whole array `a`.

Returns ------- statistic : float or array ``s^2 + k^2``, where ``s`` is the z-score returned by `skewtest` and ``k`` is the z-score returned by `kurtosistest`. pvalue : float or array A 2-sided chi squared probability for the hypothesis test.

Notes ----- For more details about `normaltest`, see `stats.normaltest`.

val obrientransform : Py.Object.t list -> Py.Object.t

Computes a transform on input data (any number of columns). Used to test for homogeneity of variance prior to running one-way stats. Each array in ``*args`` is one level of a factor. If an `f_oneway()` run on the transformed data and found significant, variances are unequal. From Maxwell and Delaney, p.112.

Returns: transformed data for use in an ANOVA

val pearsonr : x:Py.Object.t -> y:Py.Object.t -> unit -> float

Calculates a Pearson correlation coefficient and the p-value for testing non-correlation.

The Pearson correlation coefficient measures the linear relationship between two datasets. Strictly speaking, Pearson's correlation requires that each dataset be normally distributed. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Correlations of -1 or +1 imply an exact linear relationship. Positive correlations imply that as `x` increases, so does `y`. Negative correlations imply that as `x` increases, `y` decreases.

The p-value roughly indicates the probability of an uncorrelated system producing datasets that have a Pearson correlation at least as extreme as the one computed from these datasets. The p-values are not entirely reliable but are probably reasonable for datasets larger than 500 or so.

Parameters ---------- x : 1-D array_like Input y : 1-D array_like Input

Returns ------- pearsonr : float Pearson's correlation coefficient, 2-tailed p-value.

References ---------- http://www.statsoft.com/textbook/glosp.html#Pearson%20Correlation

val plotting_positions : ?alpha:float -> ?beta:float -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Returns plotting positions (or empirical percentile points) for the data.

Plotting positions are defined as ``(i-alpha)/(n+1-alpha-beta)``, where:

  • i is the rank order statistics
  • n is the number of unmasked values along the given axis
  • `alpha` and `beta` are two parameters.

Typical values for `alpha` and `beta` are:

  • (0,1) : ``p(k) = k/n``, linear interpolation of cdf (R, type 4)
  • (.5,.5) : ``p(k) = (k-1/2.)/n``, piecewise linear function (R, type 5)
  • (0,0) : ``p(k) = k/(n+1)``, Weibull (R type 6)
  • (1,1) : ``p(k) = (k-1)/(n-1)``, in this case, ``p(k) = modeF(x[k])``. That's R default (R type 7)
  • (1/3,1/3): ``p(k) = (k-1/3)/(n+1/3)``, then ``p(k) ~ medianF(x[k])``. The resulting quantile estimates are approximately median-unbiased regardless of the distribution of x. (R type 8)
  • (3/8,3/8): ``p(k) = (k-3/8)/(n+1/4)``, Blom. The resulting quantile estimates are approximately unbiased if x is normally distributed (R type 9)
  • (.4,.4) : approximately quantile unbiased (Cunnane)
  • (.35,.35): APL, used with PWM
  • (.3175, .3175): used in scipy.stats.probplot

Parameters ---------- data : array_like Input data, as a sequence or array of dimension at most 2. alpha : float, optional Plotting positions parameter. Default is 0.4. beta : float, optional Plotting positions parameter. Default is 0.4.

Returns ------- positions : MaskedArray The calculated plotting positions.

val pointbiserialr : x:Py.Object.t -> y:[> `Ndarray ] Np.Obj.t -> unit -> float * float

Calculates a point biserial correlation coefficient and its p-value.

Parameters ---------- x : array_like of bools Input array. y : array_like Input array.

Returns ------- correlation : float R value pvalue : float 2-tailed p-value

Notes ----- Missing values are considered pair-wise: if a value is missing in x, the corresponding value in y is masked.

For more details on `pointbiserialr`, see `stats.pointbiserialr`.

val rankdata : ?axis:int -> ?use_missing:bool -> data:Py.Object.t -> unit -> Py.Object.t

Returns the rank (also known as order statistics) of each data point along the given axis.

If some values are tied, their rank is averaged. If some values are masked, their rank is set to 0 if use_missing is False, or set to the average rank of the unmasked values if use_missing is True.

Parameters ---------- data : sequence Input data. The data is transformed to a masked array axis : None,int, optional Axis along which to perform the ranking. If None, the array is first flattened. An exception is raised if the axis is specified for arrays with a dimension larger than 2 use_missing : bool, optional Whether the masked values have a rank of 0 (False) or equal to the average rank of the unmasked values (True).

val rsh : ?points:Py.Object.t -> data:Py.Object.t -> unit -> Py.Object.t

Evaluates Rosenblatt's shifted histogram estimators for each data point.

Rosenblatt's estimator is a centered finite-difference approximation to the derivative of the empirical cumulative distribution function.

Parameters ---------- data : sequence Input data, should be 1-D. Masked values are ignored. points : sequence or None, optional Sequence of points where to evaluate Rosenblatt shifted histogram. If None, use the data.

val scoreatpercentile : ?limit:Py.Object.t -> ?alphap:Py.Object.t -> ?betap:Py.Object.t -> data:Py.Object.t -> per:Py.Object.t -> unit -> Py.Object.t

Calculate the score at the given 'per' percentile of the sequence a. For example, the score at per=50 is the median.

This function is a shortcut to mquantile

val sem : ?axis:[ `I of int | `None ] -> ?ddof:int -> a:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Calculates the standard error of the mean of the input array.

Also sometimes called standard error of measurement.

Parameters ---------- a : array_like An array containing the values for which the standard error is returned. axis : int or None, optional If axis is None, ravel `a` first. If axis is an integer, this will be the axis over which to operate. Defaults to 0. ddof : int, optional Delta degrees-of-freedom. How many degrees of freedom to adjust for bias in limited samples relative to the population estimate of variance. Defaults to 1.

Returns ------- s : ndarray or float The standard error of the mean in the sample(s), along the input axis.

Notes ----- The default value for `ddof` changed in scipy 0.15.0 to be consistent with `stats.sem` as well as with the most common definition used (like in the R documentation).

Examples -------- Find standard error along the first axis:

>>> from scipy import stats >>> a = np.arange(20).reshape(5,4) >>> print(stats.mstats.sem(a)) 2.8284271247461903 2.8284271247461903 2.8284271247461903 2.8284271247461903

Find standard error across the whole array, using n degrees of freedom:

>>> print(stats.mstats.sem(a, axis=None, ddof=0)) 1.2893796958227628

val sen_seasonal_slopes : Py.Object.t -> Py.Object.t

None

val siegelslopes : ?x:[> `Ndarray ] Np.Obj.t -> ?method_:[ `Hierarchical | `Separate ] -> y:[> `Ndarray ] Np.Obj.t -> unit -> float * float

Computes the Siegel estimator for a set of points (x, y).

`siegelslopes` implements a method for robust linear regression using repeated medians to fit a line to the points (x, y). The method is robust to outliers with an asymptotic breakdown point of 50%.

Parameters ---------- y : array_like Dependent variable. x : array_like or None, optional Independent variable. If None, use ``arange(len(y))`` instead. method : 'hierarchical', 'separate' If 'hierarchical', estimate the intercept using the estimated slope ``medslope`` (default option). If 'separate', estimate the intercept independent of the estimated slope. See Notes for details.

Returns ------- medslope : float Estimate of the slope of the regression line. medintercept : float Estimate of the intercept of the regression line.

See also -------- theilslopes : a similar technique without repeated medians

Notes ----- For more details on `siegelslopes`, see `scipy.stats.siegelslopes`.

val skew : ?axis:[ `I of int | `None ] -> ?bias:bool -> a:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Computes the skewness of a data set.

Parameters ---------- a : ndarray data axis : int or None, optional Axis along which skewness is calculated. Default is 0. If None, compute over the whole array `a`. bias : bool, optional If False, then the calculations are corrected for statistical bias.

Returns ------- skewness : ndarray The skewness of values along an axis, returning 0 where all values are equal.

Notes ----- For more details about `skew`, see `stats.skew`.

val skewtest : ?axis:[ `I of int | `None ] -> a:[> `Ndarray ] Np.Obj.t -> unit -> float * float

Tests whether the skew is different from the normal distribution.

Parameters ---------- a : array The data to be tested axis : int or None, optional Axis along which statistics are calculated. Default is 0. If None, compute over the whole array `a`.

Returns ------- statistic : float The computed z-score for this test. pvalue : float a 2-sided p-value for the hypothesis test

Notes ----- For more details about `skewtest`, see `stats.skewtest`.

val spearmanr : ?y:Py.Object.t -> ?use_ties:bool -> ?axis:int -> ?nan_policy:[ `Propagate | `Raise | `Omit ] -> x:Py.Object.t -> unit -> float * float

Calculates a Spearman rank-order correlation coefficient and the p-value to test for non-correlation.

The Spearman correlation is a nonparametric measure of the linear relationship between two datasets. Unlike the Pearson correlation, the Spearman correlation does not assume that both datasets are normally distributed. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Correlations of -1 or +1 imply a monotonic relationship. Positive correlations imply that as `x` increases, so does `y`. Negative correlations imply that as `x` increases, `y` decreases.

Missing values are discarded pair-wise: if a value is missing in `x`, the corresponding value in `y` is masked.

The p-value roughly indicates the probability of an uncorrelated system producing datasets that have a Spearman correlation at least as extreme as the one computed from these datasets. The p-values are not entirely reliable but are probably reasonable for datasets larger than 500 or so.

Parameters ---------- x, y : 1D or 2D array_like, y is optional One or two 1-D or 2-D arrays containing multiple variables and observations. When these are 1-D, each represents a vector of observations of a single variable. For the behavior in the 2-D case, see under ``axis``, below. use_ties : bool, optional DO NOT USE. Does not do anything, keyword is only left in place for backwards compatibility reasons. axis : int or None, optional If axis=0 (default), then each column represents a variable, with observations in the rows. If axis=1, the relationship is transposed: each row represents a variable, while the columns contain observations. If axis=None, then both arrays will be raveled. nan_policy : 'propagate', 'raise', 'omit', optional Defines how to handle when input contains nan. 'propagate' returns nan, 'raise' throws an error, 'omit' performs the calculations ignoring nan values. Default is 'propagate'.

Returns ------- correlation : float Spearman correlation coefficient pvalue : float 2-tailed p-value.

References ---------- CRCProbStat2000 section 14.7

val theilslopes : ?x:[> `Ndarray ] Np.Obj.t -> ?alpha:float -> y:[> `Ndarray ] Np.Obj.t -> unit -> float * float * float * float

Computes the Theil-Sen estimator for a set of points (x, y).

`theilslopes` implements a method for robust linear regression. It computes the slope as the median of all slopes between paired values.

Parameters ---------- y : array_like Dependent variable. x : array_like or None, optional Independent variable. If None, use ``arange(len(y))`` instead. alpha : float, optional Confidence degree between 0 and 1. Default is 95% confidence. Note that `alpha` is symmetric around 0.5, i.e. both 0.1 and 0.9 are interpreted as 'find the 90% confidence interval'.

Returns ------- medslope : float Theil slope. medintercept : float Intercept of the Theil line, as ``median(y) - medslope*median(x)``. lo_slope : float Lower bound of the confidence interval on `medslope`. up_slope : float Upper bound of the confidence interval on `medslope`.

See also -------- siegelslopes : a similar technique with repeated medians

Notes ----- For more details on `theilslopes`, see `stats.theilslopes`.

val tmax : ?upperlimit:float -> ?axis:[ `I of int | `None ] -> ?inclusive:bool -> a:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Compute the trimmed maximum

This function computes the maximum value of an array along a given axis, while ignoring values larger than a specified upper limit.

Parameters ---------- a : array_like array of values upperlimit : None or float, optional Values in the input array greater than the given limit will be ignored. When upperlimit is None, then all values are used. The default value is None. axis : int or None, optional Axis along which to operate. Default is 0. If None, compute over the whole array `a`. inclusive : True, False, optional This flag determines whether values exactly equal to the upper limit are included. The default value is True.

Returns ------- tmax : float, int or ndarray

Notes ----- For more details on `tmax`, see `stats.tmax`.

Examples -------- >>> from scipy.stats import mstats >>> a = np.array([6, 8, 3, 0], ... [3, 9, 1, 2], ... [8, 7, 8, 2], ... [5, 6, 0, 2], ... [4, 5, 5, 2]) ... ... >>> mstats.tmax(a, 4) masked_array(data=4, --, 3, 2, mask=False, True, False, False, fill_value=999999)

val tmean : ?limits:Py.Object.t -> ?inclusive:Py.Object.t -> ?axis:int -> a:[> `Ndarray ] Np.Obj.t -> unit -> float

Compute the trimmed mean.

Parameters ---------- a : array_like Array of values. limits : None or (lower limit, upper limit), optional Values in the input array less than the lower limit or greater than the upper limit will be ignored. When limits is None (default), then all values are used. Either of the limit values in the tuple can also be None representing a half-open interval. inclusive : (bool, bool), optional A tuple consisting of the (lower flag, upper flag). These flags determine whether values exactly equal to the lower or upper limits are included. The default value is (True, True). axis : int or None, optional Axis along which to operate. If None, compute over the whole array. Default is None.

Returns ------- tmean : float

Notes ----- For more details on `tmean`, see `stats.tmean`.

Examples -------- >>> from scipy.stats import mstats >>> a = np.array([6, 8, 3, 0], ... [3, 9, 1, 2], ... [8, 7, 8, 2], ... [5, 6, 0, 2], ... [4, 5, 5, 2]) ... ... >>> mstats.tmean(a, (2,5)) 3.3 >>> mstats.tmean(a, (2,5), axis=0) masked_array(data=4.0, 5.0, 4.0, 2.0, mask=False, False, False, False, fill_value=1e+20)

val tmin : ?lowerlimit:float -> ?axis:[ `I of int | `None ] -> ?inclusive:bool -> a:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Compute the trimmed minimum

Parameters ---------- a : array_like array of values lowerlimit : None or float, optional Values in the input array less than the given limit will be ignored. When lowerlimit is None, then all values are used. The default value is None. axis : int or None, optional Axis along which to operate. Default is 0. If None, compute over the whole array `a`. inclusive : True, False, optional This flag determines whether values exactly equal to the lower limit are included. The default value is True.

Returns ------- tmin : float, int or ndarray

Notes ----- For more details on `tmin`, see `stats.tmin`.

Examples -------- >>> from scipy.stats import mstats >>> a = np.array([6, 8, 3, 0], ... [3, 2, 1, 2], ... [8, 1, 8, 2], ... [5, 3, 0, 2], ... [4, 7, 5, 2]) ... >>> mstats.tmin(a, 5) masked_array(data=5, 7, 5, --, mask=False, False, False, True, fill_value=999999)

val trim : ?limits:Py.Object.t -> ?inclusive:Py.Object.t -> ?relative:bool -> ?axis:int -> a:Py.Object.t -> unit -> Py.Object.t

Trims an array by masking the data outside some given limits.

Returns a masked version of the input array.

Parameters ---------- a : sequence Input array limits : None, tuple, optional If `relative` is False, tuple (lower limit, upper limit) in absolute values. Values of the input array lower (greater) than the lower (upper) limit are masked.

If `relative` is True, tuple (lower percentage, upper percentage) to cut on each side of the array, with respect to the number of unmasked data.

Noting n the number of unmasked data before trimming, the (n*limits0)th smallest data and the (n*limits1)th largest data are masked, and the total number of unmasked data after trimming is n*(1.-sum(limits)) In each case, the value of one limit can be set to None to indicate an open interval.

If limits is None, no trimming is performed inclusive : (bool, bool) tuple, optional If `relative` is False, tuple indicating whether values exactly equal to the absolute limits are allowed. If `relative` is True, tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False). relative : bool, optional Whether to consider the limits as absolute values (False) or proportions to cut (True). axis : int, optional Axis along which to trim.

Examples -------- >>> from scipy.stats.mstats import trim >>> z = 1, 2, 3, 4, 5, 6, 7, 8, 9,10 >>> print(trim(z,(3,8))) -- -- 3 4 5 6 7 8 -- -- >>> print(trim(z,(0.1,0.2),relative=True)) -- 2 3 4 5 6 7 8 -- --

val trima : ?limits:Py.Object.t -> ?inclusive:Py.Object.t -> a:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Trims an array by masking the data outside some given limits.

Returns a masked version of the input array.

Parameters ---------- a : array_like Input array. limits : None, tuple, optional Tuple of (lower limit, upper limit) in absolute values. Values of the input array lower (greater) than the lower (upper) limit will be masked. A limit is None indicates an open interval. inclusive : (bool, bool) tuple, optional Tuple of (lower flag, upper flag), indicating whether values exactly equal to the lower (upper) limit are allowed.

Examples -------- >>> from scipy.stats.mstats import trima

>>> a = np.arange(10)

The interval is left-closed and right-open, i.e., `2, 8)`. Trim the array by keeping only values in the interval. >>> trima(a, limits=(2, 8), inclusive=(True, False)) masked_array(data=[--, --, 2, 3, 4, 5, 6, 7, --, --], mask=[ True, True, False, False, False, False, False, False, True, True], fill_value=999999)

val trimboth : ?proportiontocut:float -> ?inclusive:Py.Object.t -> ?axis:int -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Trims the smallest and largest data values.

Trims the `data` by masking the ``int(proportiontocut * n)`` smallest and ``int(proportiontocut * n)`` largest values of data along the given axis, where n is the number of unmasked values before trimming.

Parameters ---------- data : ndarray Data to trim. proportiontocut : float, optional Percentage of trimming (as a float between 0 and 1). If n is the number of unmasked values before trimming, the number of values after trimming is ``(1 - 2*proportiontocut) * n``. Default is 0.2. inclusive : (bool, bool) tuple, optional Tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False). axis : int, optional Axis along which to perform the trimming. If None, the input array is first flattened.

val trimmed_mean : ?limits:[ `Tuple of Py.Object.t | `None ] -> ?inclusive:Py.Object.t -> ?relative:bool -> ?axis:int -> a:Py.Object.t -> unit -> Py.Object.t

Returns the trimmed mean of the data along the given axis.

Parameters ---------- a : sequence Input array limits : None, tuple, optional If `relative` is False, tuple (lower limit, upper limit) in absolute values. Values of the input array lower (greater) than the lower (upper) limit are masked.

If `relative` is True, tuple (lower percentage, upper percentage) to cut on each side of the array, with respect to the number of unmasked data.

Noting n the number of unmasked data before trimming, the (n*limits0)th smallest data and the (n*limits1)th largest data are masked, and the total number of unmasked data after trimming is n*(1.-sum(limits)) In each case, the value of one limit can be set to None to indicate an open interval.

If limits is None, no trimming is performed inclusive : (bool, bool) tuple, optional If `relative` is False, tuple indicating whether values exactly equal to the absolute limits are allowed. If `relative` is True, tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False). relative : bool, optional Whether to consider the limits as absolute values (False) or proportions to cut (True). axis : int, optional Axis along which to trim.

val trimmed_mean_ci : ?limits:[ `Tuple of Py.Object.t | `None ] -> ?inclusive:Py.Object.t -> ?alpha:float -> ?axis:int -> data:[> `Ndarray ] Np.Obj.t -> unit -> Py.Object.t

Selected confidence interval of the trimmed mean along the given axis.

Parameters ---------- data : array_like Input data. limits : None, tuple, optional None or a two item tuple. Tuple of the percentages to cut on each side of the array, with respect to the number of unmasked data, as floats between 0. and 1. If ``n`` is the number of unmasked data before trimming, then (``n * limits0``)th smallest data and (``n * limits1``)th largest data are masked. The total number of unmasked data after trimming is ``n * (1. - sum(limits))``. The value of one limit can be set to None to indicate an open interval.

Defaults to (0.2, 0.2). inclusive : (2,) tuple of boolean, optional If relative==False, tuple indicating whether values exactly equal to the absolute limits are allowed. If relative==True, tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False).

Defaults to (True, True). alpha : float, optional Confidence level of the intervals.

Defaults to 0.05. axis : int, optional Axis along which to cut. If None, uses a flattened version of `data`.

Defaults to None.

Returns ------- trimmed_mean_ci : (2,) ndarray The lower and upper confidence intervals of the trimmed data.

val trimmed_std : ?limits:[ `Tuple of Py.Object.t | `None ] -> ?inclusive:Py.Object.t -> ?relative:bool -> ?axis:int -> ?ddof:[ `Zero | `I of int ] -> a:Py.Object.t -> unit -> Py.Object.t

Returns the trimmed standard deviation of the data along the given axis.

Parameters ---------- a : sequence Input array limits : None, tuple, optional If `relative` is False, tuple (lower limit, upper limit) in absolute values. Values of the input array lower (greater) than the lower (upper) limit are masked.

If `relative` is True, tuple (lower percentage, upper percentage) to cut on each side of the array, with respect to the number of unmasked data.

Noting n the number of unmasked data before trimming, the (n*limits0)th smallest data and the (n*limits1)th largest data are masked, and the total number of unmasked data after trimming is n*(1.-sum(limits)) In each case, the value of one limit can be set to None to indicate an open interval.

If limits is None, no trimming is performed inclusive : (bool, bool) tuple, optional If `relative` is False, tuple indicating whether values exactly equal to the absolute limits are allowed. If `relative` is True, tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False). relative : bool, optional Whether to consider the limits as absolute values (False) or proportions to cut (True). axis : int, optional Axis along which to trim.

ddof :

,integer

, optional Means Delta Degrees of Freedom. The denominator used during computations is (n-ddof). DDOF=0 corresponds to a biased estimate, DDOF=1 to an un- biased estimate of the variance.

val trimmed_stde : ?limits:Py.Object.t -> ?inclusive:Py.Object.t -> ?axis:int -> a:Py.Object.t -> unit -> Py.Object.t

Returns the standard error of the trimmed mean along the given axis.

Parameters ---------- a : sequence Input array limits : (0.1,0.1), tuple of float, optional tuple (lower percentage, upper percentage) to cut on each side of the array, with respect to the number of unmasked data.

If n is the number of unmasked data before trimming, the values smaller than ``n * limits0`` and the values larger than ``n * `limits1`` are masked, and the total number of unmasked data after trimming is ``n * (1.-sum(limits))``. In each case, the value of one limit can be set to None to indicate an open interval. If `limits` is None, no trimming is performed. inclusive : (bool, bool) tuple optional Tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False). axis : int, optional Axis along which to trim.

Returns ------- trimmed_stde : scalar or ndarray

val trimmed_var : ?limits:[ `Tuple of Py.Object.t | `None ] -> ?inclusive:Py.Object.t -> ?relative:bool -> ?axis:int -> ?ddof:[ `Zero | `I of int ] -> a:Py.Object.t -> unit -> Py.Object.t

Returns the trimmed variance of the data along the given axis.

Parameters ---------- a : sequence Input array limits : None, tuple, optional If `relative` is False, tuple (lower limit, upper limit) in absolute values. Values of the input array lower (greater) than the lower (upper) limit are masked.

If `relative` is True, tuple (lower percentage, upper percentage) to cut on each side of the array, with respect to the number of unmasked data.

Noting n the number of unmasked data before trimming, the (n*limits0)th smallest data and the (n*limits1)th largest data are masked, and the total number of unmasked data after trimming is n*(1.-sum(limits)) In each case, the value of one limit can be set to None to indicate an open interval.

If limits is None, no trimming is performed inclusive : (bool, bool) tuple, optional If `relative` is False, tuple indicating whether values exactly equal to the absolute limits are allowed. If `relative` is True, tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False). relative : bool, optional Whether to consider the limits as absolute values (False) or proportions to cut (True). axis : int, optional Axis along which to trim.

ddof :

,integer

, optional Means Delta Degrees of Freedom. The denominator used during computations is (n-ddof). DDOF=0 corresponds to a biased estimate, DDOF=1 to an un- biased estimate of the variance.

val trimr : ?limits:Py.Object.t -> ?inclusive:Py.Object.t -> ?axis:int -> a:Py.Object.t -> unit -> Py.Object.t

Trims an array by masking some proportion of the data on each end. Returns a masked version of the input array.

Parameters ---------- a : sequence Input array. limits : None, tuple, optional Tuple of the percentages to cut on each side of the array, with respect to the number of unmasked data, as floats between 0. and 1. Noting n the number of unmasked data before trimming, the (n*limits0)th smallest data and the (n*limits1)th largest data are masked, and the total number of unmasked data after trimming is n*(1.-sum(limits)). The value of one limit can be set to None to indicate an open interval. inclusive : (True,True) tuple, optional Tuple of flags indicating whether the number of data being masked on the left (right) end should be truncated (True) or rounded (False) to integers. axis : None,int, optional Axis along which to trim. If None, the whole array is trimmed, but its shape is maintained.

val trimtail : ?proportiontocut:float -> ?tail:[ `Left | `Right ] -> ?inclusive:Py.Object.t -> ?axis:int -> data:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Trims the data by masking values from one tail.

Parameters ---------- data : array_like Data to trim. proportiontocut : float, optional Percentage of trimming. If n is the number of unmasked values before trimming, the number of values after trimming is ``(1 - proportiontocut) * n``. Default is 0.2. tail : 'left','right', optional If 'left' the `proportiontocut` lowest values will be masked. If 'right' the `proportiontocut` highest values will be masked. Default is 'left'. inclusive : (bool, bool) tuple, optional Tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False). Default is (True, True). axis : int, optional Axis along which to perform the trimming. If None, the input array is first flattened. Default is None.

Returns ------- trimtail : ndarray Returned array of same shape as `data` with masked tail values.

val tsem : ?limits:Py.Object.t -> ?inclusive:Py.Object.t -> ?axis:[ `I of int | `None ] -> ?ddof:int -> a:[> `Ndarray ] Np.Obj.t -> unit -> float

Compute the trimmed standard error of the mean.

This function finds the standard error of the mean for given values, ignoring values outside the given `limits`.

Parameters ---------- a : array_like array of values limits : None or (lower limit, upper limit), optional Values in the input array less than the lower limit or greater than the upper limit will be ignored. When limits is None, then all values are used. Either of the limit values in the tuple can also be None representing a half-open interval. The default value is None. inclusive : (bool, bool), optional A tuple consisting of the (lower flag, upper flag). These flags determine whether values exactly equal to the lower or upper limits are included. The default value is (True, True). axis : int or None, optional Axis along which to operate. If None, compute over the whole array. Default is zero. ddof : int, optional Delta degrees of freedom. Default is 1.

Returns ------- tsem : float

Notes ----- For more details on `tsem`, see `stats.tsem`.

val ttest_1samp : ?axis:[ `I of int | `None ] -> a:[> `Ndarray ] Np.Obj.t -> popmean:[ `Ndarray of [> `Ndarray ] Np.Obj.t | `F of float ] -> unit -> Py.Object.t * Py.Object.t

Calculates the T-test for the mean of ONE group of scores.

Parameters ---------- a : array_like sample observation popmean : float or array_like expected value in null hypothesis, if array_like than it must have the same shape as `a` excluding the axis dimension axis : int or None, optional Axis along which to compute test. If None, compute over the whole array `a`.

Returns ------- statistic : float or array t-statistic pvalue : float or array two-tailed p-value

Notes ----- For more details on `ttest_1samp`, see `stats.ttest_1samp`.

val ttest_ind : ?axis:[ `I of int | `None ] -> ?equal_var:bool -> a:Py.Object.t -> b:Py.Object.t -> unit -> Py.Object.t * Py.Object.t

Calculates the T-test for the means of TWO INDEPENDENT samples of scores.

Parameters ---------- a, b : array_like The arrays must have the same shape, except in the dimension corresponding to `axis` (the first, by default). axis : int or None, optional Axis along which to compute test. If None, compute over the whole arrays, `a`, and `b`. equal_var : bool, optional If True, perform a standard independent 2 sample test that assumes equal population variances. If False, perform Welch's t-test, which does not assume equal population variance.

.. versionadded:: 0.17.0

Returns ------- statistic : float or array The calculated t-statistic. pvalue : float or array The two-tailed p-value.

Notes ----- For more details on `ttest_ind`, see `stats.ttest_ind`.

val ttest_onesamp : ?axis:[ `I of int | `None ] -> a:[> `Ndarray ] Np.Obj.t -> popmean:[ `Ndarray of [> `Ndarray ] Np.Obj.t | `F of float ] -> unit -> Py.Object.t * Py.Object.t

Calculates the T-test for the mean of ONE group of scores.

Parameters ---------- a : array_like sample observation popmean : float or array_like expected value in null hypothesis, if array_like than it must have the same shape as `a` excluding the axis dimension axis : int or None, optional Axis along which to compute test. If None, compute over the whole array `a`.

Returns ------- statistic : float or array t-statistic pvalue : float or array two-tailed p-value

Notes ----- For more details on `ttest_1samp`, see `stats.ttest_1samp`.

val ttest_rel : ?axis:[ `I of int | `None ] -> a:Py.Object.t -> b:Py.Object.t -> unit -> Py.Object.t * Py.Object.t

Calculates the T-test on TWO RELATED samples of scores, a and b.

Parameters ---------- a, b : array_like The arrays must have the same shape. axis : int or None, optional Axis along which to compute test. If None, compute over the whole arrays, `a`, and `b`.

Returns ------- statistic : float or array t-statistic pvalue : float or array two-tailed p-value

Notes ----- For more details on `ttest_rel`, see `stats.ttest_rel`.

val tvar : ?limits:Py.Object.t -> ?inclusive:Py.Object.t -> ?axis:[ `I of int | `None ] -> ?ddof:int -> a:[> `Ndarray ] Np.Obj.t -> unit -> float

Compute the trimmed variance

This function computes the sample variance of an array of values, while ignoring values which are outside of given `limits`.

Parameters ---------- a : array_like Array of values. limits : None or (lower limit, upper limit), optional Values in the input array less than the lower limit or greater than the upper limit will be ignored. When limits is None, then all values are used. Either of the limit values in the tuple can also be None representing a half-open interval. The default value is None. inclusive : (bool, bool), optional A tuple consisting of the (lower flag, upper flag). These flags determine whether values exactly equal to the lower or upper limits are included. The default value is (True, True). axis : int or None, optional Axis along which to operate. If None, compute over the whole array. Default is zero. ddof : int, optional Delta degrees of freedom. Default is 1.

Returns ------- tvar : float Trimmed variance.

Notes ----- For more details on `tvar`, see `stats.tvar`.

val variation : ?axis:[ `I of int | `None ] -> a:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Computes the coefficient of variation, the ratio of the biased standard deviation to the mean.

Parameters ---------- a : array_like Input array. axis : int or None, optional Axis along which to calculate the coefficient of variation. Default is 0. If None, compute over the whole array `a`.

Returns ------- variation : ndarray The calculated variation along the requested axis.

Notes ----- For more details about `variation`, see `stats.variation`.

Examples -------- >>> from scipy.stats.mstats import variation >>> a = np.array(2,8,4) >>> variation(a) 0.5345224838248487 >>> b = np.array(2,8,3,4) >>> c = np.ma.masked_array(b, mask=0,0,1,0) >>> variation(c) 0.5345224838248487

In the example above, it can be seen that this works the same as `stats.variation` except 'stats.mstats.variation' ignores masked array elements.

val winsorize : ?limits:Py.Object.t -> ?inclusive:Py.Object.t -> ?inplace:bool -> ?axis:int -> a:Py.Object.t -> unit -> Py.Object.t

Returns a Winsorized version of the input array.

The (limits0)th lowest values are set to the (limits0)th percentile, and the (limits1)th highest values are set to the (1 - limits1)th percentile. Masked values are skipped.

Parameters ---------- a : sequence Input array. limits : None, tuple of float, optional Tuple of the percentages to cut on each side of the array, with respect to the number of unmasked data, as floats between 0. and 1. Noting n the number of unmasked data before trimming, the (n*limits0)th smallest data and the (n*limits1)th largest data are masked, and the total number of unmasked data after trimming is n*(1.-sum(limits)) The value of one limit can be set to None to indicate an open interval. inclusive : (True, True) tuple, optional Tuple indicating whether the number of data being masked on each side should be truncated (True) or rounded (False). inplace : False, True, optional Whether to winsorize in place (True) or to use a copy (False) axis : None, int, optional Axis along which to trim. If None, the whole array is trimmed, but its shape is maintained.

Notes ----- This function is applied to reduce the effect of possibly spurious outliers by limiting the extreme values.

Examples -------- >>> from scipy.stats.mstats import winsorize

A shuffled array contains integers from 1 to 10.

>>> a = np.array(10, 4, 9, 8, 5, 3, 7, 2, 1, 6)

The 10% of the lowest value (i.e., `1`) and the 20% of the highest values (i.e., `9` and `10`) are replaced.

>>> winsorize(a, limits=0.1, 0.2) masked_array(data=8, 4, 8, 8, 5, 3, 7, 2, 2, 6, mask=False, fill_value=999999)

val zmap : ?axis:[ `I of int | `None ] -> ?ddof:int -> scores:[> `Ndarray ] Np.Obj.t -> compare:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Calculate the relative z-scores.

Return an array of z-scores, i.e., scores that are standardized to zero mean and unit variance, where mean and variance are calculated from the comparison array.

Parameters ---------- scores : array_like The input for which z-scores are calculated. compare : array_like The input from which the mean and standard deviation of the normalization are taken; assumed to have the same dimension as `scores`. axis : int or None, optional Axis over which mean and variance of `compare` are calculated. Default is 0. If None, compute over the whole array `scores`. ddof : int, optional Degrees of freedom correction in the calculation of the standard deviation. Default is 0.

Returns ------- zscore : array_like Z-scores, in the same shape as `scores`.

Notes ----- This function preserves ndarray subclasses, and works also with matrices and masked arrays (it uses `asanyarray` instead of `asarray` for parameters).

Examples -------- >>> from scipy.stats import zmap >>> a = 0.5, 2.0, 2.5, 3 >>> b = 0, 1, 2, 3, 4 >>> zmap(a, b) array(-1.06066017, 0. , 0.35355339, 0.70710678)

val zscore : ?axis:[ `I of int | `None ] -> ?ddof:int -> ?nan_policy:[ `Propagate | `Raise | `Omit ] -> a:[> `Ndarray ] Np.Obj.t -> unit -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Compute the z score.

Compute the z score of each value in the sample, relative to the sample mean and standard deviation.

Parameters ---------- a : array_like An array like object containing the sample data. axis : int or None, optional Axis along which to operate. Default is 0. If None, compute over the whole array `a`. ddof : int, optional Degrees of freedom correction in the calculation of the standard deviation. Default is 0. nan_policy : 'propagate', 'raise', 'omit', optional Defines how to handle when input contains nan. 'propagate' returns nan, 'raise' throws an error, 'omit' performs the calculations ignoring nan values. Default is 'propagate'.

Returns ------- zscore : array_like The z-scores, standardized by mean and standard deviation of input array `a`.

Notes ----- This function preserves ndarray subclasses, and works also with matrices and masked arrays (it uses `asanyarray` instead of `asarray` for parameters).

Examples -------- >>> a = np.array( 0.7972, 0.0767, 0.4383, 0.7866, 0.8091, ... 0.1954, 0.6307, 0.6599, 0.1065, 0.0508) >>> from scipy import stats >>> stats.zscore(a) array( 1.1273, -1.247 , -0.0552, 1.0923, 1.1664, -0.8559, 0.5786, 0.6748, -1.1488, -1.3324)

Computing along a specified axis, using n-1 degrees of freedom (``ddof=1``) to calculate the standard deviation:

>>> b = np.array([ 0.3148, 0.0478, 0.6243, 0.4608], ... [ 0.7149, 0.0775, 0.6072, 0.9656], ... [ 0.6341, 0.1403, 0.9759, 0.4064], ... [ 0.5918, 0.6948, 0.904 , 0.3721], ... [ 0.0921, 0.2481, 0.1188, 0.1366]) >>> stats.zscore(b, axis=1, ddof=1) array([-0.19264823, -1.28415119, 1.07259584, 0.40420358], [ 0.33048416, -1.37380874, 0.04251374, 1.00081084], [ 0.26796377, -1.12598418, 1.23283094, -0.37481053], [-0.22095197, 0.24468594, 1.19042819, -1.21416216], [-0.82780366, 1.4457416 , -0.43867764, -0.1792603 ])

OCaml

Innovation. Community. Security.