Sysquake Pro – Table of Contents
Sysquake for LaTeX – Table of Contents
Library - stat
stat is a library which adds to LME advanced statistical functions.
The following statement makes available functions defined in stat:
use stat
Functions
bootstrp
Bootstrap estimate.
Syntax
use stat (stats, samples) = bootstrp(n, fun, D1, ...)
Description
bootstrp(n,fun,D) picks random observations from the rows of matrix (or column vector) D to form n sets which have all the same size as D; then it applies function fun (a function name or reference or an inline function) to each set and returns the results in the columns of stats. Up to three different set of data can be provided.
bootstrp gives an idea of the robustness of the estimate with respect to the choice of the observations.
Example
use stat D = rand(1000, 1); bootstrp(5, @std, D) 0.2938 0.2878 0.2793 0.2859 0.2844
geomean
Geometric mean of a set of values.
Syntax
use stat m = geomean(A) m = geomean(A, dim)
Description
geomean(A) gives the geometric mean of the columns of array A or of the row vector A. The dimension along which geomean proceeds may be specified with a second argument.
The geometric mean of vector v of length n
is defined as
Example
use stat geomean(1:10) 4.5287 mean(1:10) 5.5 exp(mean(log(1:10))) 4.5287
See also
harmmean
Harmonic mean of a set of values.
Syntax
use stat m = harmmean(A) m = harmmean(A, dim)
Description
harmmean(A) gives the harmonic mean of the columns of array A or of the row vector A. The dimension along which harmmean proceeds may be specified with a second argument.
The inverse of the harmonic mean is the arithmetic mean of the inverse of the observations.
Example
use stat harmmean(1:10) 3.4142 mean(1:10) 5.5
See also
iqr
Interquartile range.
Syntax
use stat m = iqr(A) m = iqr(A, dim)
Description
iqr(A) gives the interquartile range of the columns of array A or of the row vector A. The dimension along which iqr proceeds may be specified with a second argument.
The interquartile range is the difference between the 75th percentile and the 25th percentile.
Example
use stat iqr(rand(1,1000)) 0.5158
See also
mad
Mean absolute deviation.
Syntax
use stat m = mad(A) m = mad(A, dim)
Description
mad(A) gives the mean absolute deviation of the columns of array A or of the row vector A. The dimension along which mad proceeds may be specified with a second argument.
The mean absolute deviation is the mean of the absolute value of the deviation between each observation and the arithmetic mean.
Example
use stat mad(rand(1,1000)) 0.2446
See also
nancorrcoef
Correlation coefficients after discarding NaNs.
Syntax
use stat S = nancorrcoef(X) S = nancorrcoef(X1, X2)
Description
nancorrcoef(X) calculates the correlation coefficients of the columns of the m-by-n matrix X. NaN values are ignored. The result is a square n-by-n matrix whose diagonal is 1.
nancorrcoef(X1,X2) calculates the correlation coefficients of X1 and X2 and returns a 2-by-2 matrix, ignoring NaN values. It is equivalent to nancorrcoef([X1(:),X2(:)]).
See also
nanmean, nanstd, nancov, corrcoef
nancov
Covariance after discarding NaNs.
Syntax
use stat M = nancov(data) M = nancov(data, 0) M = nancov(data, 1)
Description
nancov(data) returns the best unbiased estimate m-by-m covariance matrix of the n-by-m matrix data for a normal distribution. NaN values are ignored. Each row of data is an observation where n quantities were measured. nancov(data,0) is the same as nancov(data).
nancov(data,1) returns the m-by-m covariance matrix of the n-by-m matrix data which contains the whole population; NaN values are ignored.
See also
nanmean, nanstd, nancorrcoef, cov
nanmean
Mean after discarding NaNs.
Syntax
use stat y = nanmean(A) y = nanmean(A, dim)
Description
nanmean(v) returns the arithmetic mean of the elements of vector v. nanmean(A) returns a row vector whose elements are the means of the corresponding columns of array A. nanmean(A,dim) returns the mean of array A along dimension dim; the result is a row vector if dim is 1, or a column vector if dim is 2. In all cases, NaN values are ignored.
Examples
use stat nanmean([1,2,nan;nan,6,7]) 1 4 7 nanmean([1,2,nan;nan,6,7],2) 1.5 6.5 nanmean([nan,nan]) nan
See also
nanmedian
Median after discarding NaNs.
Syntax
use stat y = nanmedian(A) y = nanmedian(A, dim)
Description
nanmedian(v) gives the median of vector v, i.e. the value x such that half of the elements of v are smaller and half of the elements are larger. NaN values are ignored.
nanmedian(A) gives a row vector which contains the median of the columns of A. With a second argument, nanmedian(A,dim) operates along dimension dim.
See also
nanstd
Standard deviation after discarding NaNs.
Syntax
use stat y = nanstd(A) y = nanstd(A, p) y = nanstd(A, p, dim)
Description
nanstd(v) returns the standard deviation of vector v with NaN values ignored, normalized by one less than the number of non-NaN values. With a second argument, nanstd(v,p) normalizes by one less than the number of non-NaN values if p is true, or by the number of non-NaN values if p is false.
nanstd(M) gives a row vector which contains the standard deviation of the columns of M. With a third argument, nanstd(M,p,dim) operates along dimension dim. In all cases, NaN values are ignored.
Example
use stat nanstd([1,2,nan;nan,6,7;10,11,12]) 6.3640 4.5092 3.5355
See also
nansum
Sum after discarding NaNs.
Syntax
use stat y = nansum(A) y = nansum(A, dim)
Description
nansum(v) returns the sum of the elements of vector v. NaN values are ignored. nansum(A) returns a row vector whose elements are the sums of the corresponding columns of array A. nansum(A,dim) returns the sum of array A along dimension dim; the result is a row vector if dim is 1, or a column vector if dim is 2.
See also
pdist
Pairwise distance between observations.
Syntax
use stat d = pdist(M) d = pdist(M, metric) d = pdist(M, metric, p)
Description
pdist calculates the distance between pairs of rows of the observation matrix M. The result is a column vector which contains the distances between rows i and j with i<j. It can be reshaped into a square matrix with squareform.
By default, the metric used to calculate the distance is the euclidean distance; but it can be specified with a second argument:
Metric | Description |
---|---|
'euclid' | euclidean distance |
'seuclid' | standardized euclidean distance |
'mahal' | Mahalanobis distance |
'cityblock' | sum of absolute values |
'minkowski' | Minkowski metric with parameter p |
The standardized euclidean distance is the euclidean distance after each column of M has been divided by its standard deviation. The Minkowski metric is based on the p-norm of vector differences.
Examples
use stat pdist((1:3)') 1 2 1 squareform(pdist((1:3)')) 0 1 2 1 0 1 2 1 0 squareform(pdist([1,2,6; 3,1,7;6,1,2])) 0 2.4495 6.4807 2.4495 0 5.831 6.4807 5.831 0
See also
prctile
Percentile.
Syntax
use stat m = prctile(A, prc) m = prctile(A, prc, dim)
Description
prctile(A,prc) gives the smallest values larger than prc percent of the elements of each column of array A or of the row vector A. The dimension along which prctile proceeds may be specified with a third argument.
Example
prctile(rand(1,1000),90) 0.8966
See also
range
Data range.
Syntax
use stat m = range(A) m = range(A, dim)
Description
range(A) gives the differences between the maximum and minimum values of the columns of array A or of the row vector A. The dimension along which range proceeds may be specified with a second argument.
Example
range(rand(1,100)) 0.9602
See also
squareform
Reshape a vector of pairwise distances into a square matrix.
Syntax
use stat D = squareform(d)
Description
squareform(d) reshapes d, which should be the output of pdist, into a symmetric square matrix D, so that the distance between observations i and j is D(i,j).
See also
trimmean
Trimmed mean of a set of values.
Syntax
use stat m = trimmean(A, prc) m = trimmean(A, prc, dim)
Description
trimmean(A,prc) gives the arithmetic mean of the columns of array A or of the row vector A once prc/2 percent of the values have been removed from each end. The dimension along which trimmean proceeds may be specified with a third argument.
trimmean is less sensitive to outliers than the regular arithmetic mean.
See also
prctile, geomean, median, mean
zscore
Z score (normalized deviation).
Syntax
use stat Y = zscore(X) Y = zscore(X, dim)
Description
zscore(X) normalizes the columns of array X or the row vector X by subtracting their mean and dividing by their standard deviation. The dimension along which zscore proceeds may be specified with a second argument.