다음: , 상위 문서: Statistics   [차례][찾아보기]


26.1 Descriptive Statistics

One principal goal of descriptive statistics is to represent the essence of a large data set concisely. Octave provides the mean, median, and mode functions which all summarize a data set with just a single number corresponding to the central tendency of the data.

mean (가로)
mean (가로, dim)
mean (가로, opt)
mean (가로, dim, opt)
mean (…, outtype)

Compute the mean of the elements of the vector 가로.

The mean is defined as

mean (가로) = SUM_i 가로(i) / N

where N is the length of the 가로 vector.

If 가로 is a matrix, compute the mean for each column and return them in a row vector.

If the optional argument dim is given, operate along this dimension.

The optional argument opt selects the type of mean to compute. The following options are recognized:

"a"

Compute the (ordinary) arithmetic mean. [default]

"g"

Compute the geometric mean.

"h"

Compute the harmonic mean.

The optional argument outtype selects the data type of the output value. The following options are recognized:

"default"

Output will be of class double unless 가로 is of class single, in which case the output will also be single.

"double"

Output will be of class double.

"native"

Output will be the same class as 가로 unless 가로 is of class logical in which case it returns of class double.

Both dim and opt are optional. If both are supplied, either may appear first.

같이 보기: median, mode.

median (가로)
median (가로, dim)

Compute the median value of the elements of the vector 가로.

When the elements of 가로 are sorted, say s = sort (가로), the median is defined as

             |  s(ceil(N/2))           N odd
median (가로) = |
             | (s(N/2) + s(N/2+1))/2   N even

If 가로 is of a discrete type such as integer or logical, then the case of even N rounds up (or toward true).

If 가로 is a matrix, compute the median value for each column and return them in a row vector.

If the optional dim argument is given, operate along this dimension.

같이 보기: mean, mode.

mode (가로)
mode (가로, dim)
[m, f, c] = mode (…)

Compute the most frequently occurring value in a dataset (mode).

mode determines the frequency of values along the first non-singleton dimension and returns the value with the highest frequency. If two, or more, values have the same frequency mode returns the smallest.

If the optional argument dim is given, operate along this dimension.

The return variable f is the number of occurrences of the mode in the dataset.

The cell array c contains all of the elements with the maximum frequency.

같이 보기: mean, median.

Using just one number, such as the mean, to represent an entire data set may not give an accurate picture of the data. One way to characterize the fit is to measure the dispersion of the data. Octave provides several functions for measuring dispersion.

[s, l] = bounds (가로)
[s, l] = bounds (가로, dim)
[s, l] = bounds (…, "nanflag")

Return the smallest and largest values of the input data 가로.

If 가로 is a vector, the bounds are calculated over the elements of 가로. If 가로 is a matrix, the bounds are calculated for each column. For a multi-dimensional array, the bounds are calculated over the first non-singleton dimension.

If the optional argument dim is given, operate along this dimension.

The optional argument "nanflag" defaults to "omitnan" which does not include NaN values in the result. If the argument "includenan" is given, and there is a NaN present, then the result for both smallest (s) and largest (l) elements will be NaN.

The bounds are a quickly computed measure of the dispersion of a data set, but are less accurate than iqr if there are outlying data points.

같이 보기: range, iqr, mad, std.

range (가로)
range (가로, dim)

Return the range, i.e., the difference between the maximum and the minimum of the input data.

If 가로 is a vector, the range is calculated over the elements of 가로. If 가로 is a matrix, the range is calculated over each column of 가로.

If the optional argument dim is given, operate along this dimension.

The range is a quickly computed measure of the dispersion of a data set, but is less accurate than iqr if there are outlying data points.

같이 보기: bounds, iqr, mad, std.

iqr (가로)
iqr (가로, dim)

Return the interquartile range, i.e., the difference between the upper and lower quartile of the input data.

If 가로 is a matrix, do the above for first non-singleton dimension of 가로.

If the optional argument dim is given, operate along this dimension.

As a measure of dispersion, the interquartile range is less affected by outliers than either range or std.

같이 보기: bounds, mad, range, std.

mad (가로)
mad (가로, opt)
mad (가로, opt, dim)

Compute the mean or median absolute deviation of the elements of 가로.

The mean absolute deviation is defined as

mad = mean (abs (가로 - mean (가로)))

The median absolute deviation is defined as

mad = median (abs (가로 - median (가로)))

If 가로 is a matrix, compute mad for each column and return results in a row vector. For a multi-dimensional array, the calculation is done over the first non-singleton dimension.

The optional argument opt determines whether mean or median absolute deviation is calculated. The default is 0 which corresponds to mean absolute deviation; A value of 1 corresponds to median absolute deviation.

If the optional argument dim is given, operate along this dimension.

As a measure of dispersion, mad is less affected by outliers than std.

같이 보기: bounds, range, iqr, std, mean, median.

meansq (가로)
meansq (가로, dim)

Compute the mean square of the elements of the vector 가로.

The mean square is defined as

meansq (가로) = 1/N SUM_i 가로(i)^2

where N is the length of the 가로 vector.

If 가로 is a matrix, return a row vector containing the mean square of each column.

If the optional argument dim is given, operate along this dimension.

같이 보기: var, std, moment.

std (가로)
std (가로, opt)
std (가로, opt, dim)

Compute the standard deviation of the elements of the vector 가로.

The standard deviation is defined as

std (가로) = sqrt ( 1/(N-1) SUM_i (가로(i) - mean(가로))^2 )

where N is the number of elements of the 가로 vector.

If 가로 is a matrix, compute the standard deviation for each column and return them in a row vector.

The argument opt determines the type of normalization to use. Valid values are

0:

normalize with N-1, provides the square root of the best unbiased estimator of the variance [default]

1:

normalize with N, this provides the square root of the second moment around the mean

If the optional argument dim is given, operate along this dimension.

같이 보기: var, bounds, mad, range, iqr, mean, median.

In addition to knowing the size of a dispersion it is useful to know the shape of the data set. For example, are data points massed to the left or right of the mean? Octave provides several common measures to describe the shape of the data set. Octave can also calculate moments allowing arbitrary shape measures to be developed.

var (가로)
var (가로, opt)
var (가로, opt, dim)

Compute the variance of the elements of the vector 가로.

The variance is defined as

var (가로) = 1/(N-1) SUM_i (가로(i) - mean(가로))^2

where N is the length of the 가로 vector.

If 가로 is a matrix, compute the variance for each column and return them in a row vector.

The argument opt determines the type of normalization to use. Valid values are

0:

normalize with N-1, provides the best unbiased estimator of the variance [default]

1:

normalizes with N, this provides the second moment around the mean

If N is equal to 1 the value of opt is ignored and normalization by N is used.

If the optional argument dim is given, operate along this dimension.

같이 보기: cov, std, skewness, kurtosis, moment.

skewness (가로)
skewness (가로, flag)
skewness (가로, flag, dim)

Compute the sample skewness of the elements of 가로.

The sample skewness is defined as

               mean ((가로 - mean (가로)).^3)
skewness (가로) = ------------------------.
                      std (가로).^3

The optional argument flag controls which normalization is used. If flag is equal to 1 (default value, used when flag is omitted or empty), return the sample skewness as defined above. If flag is equal to 0, return the adjusted skewness coefficient instead:

                  sqrt (N*(N-1))   mean ((가로 - mean (가로)).^3)
skewness (가로, 0) = -------------- * ------------------------.
                      (N - 2)             std (가로).^3

where N is the length of the 가로 vector.

The adjusted skewness coefficient is obtained by replacing the sample second and third central moments by their bias-corrected versions.

If 가로 is a matrix, or more generally a multi-dimensional array, return the skewness along the first non-singleton dimension. If the optional dim argument is given, operate along this dimension.

같이 보기: var, kurtosis, moment.

kurtosis (가로)
kurtosis (가로, flag)
kurtosis (가로, flag, dim)

Compute the sample kurtosis of the elements of 가로.

The sample kurtosis is defined as

     mean ((가로 - mean (가로)).^4)
k1 = ------------------------
            std (가로).^4

The optional argument flag controls which normalization is used. If flag is equal to 1 (default value, used when flag is omitted or empty), return the sample kurtosis as defined above. If flag is equal to 0, return the "bias-corrected" kurtosis coefficient instead:

              N - 1
k0 = 3 + -------------- * ((N + 1) * k1 - 3 * (N - 1))
         (N - 2)(N - 3)

where N is the length of the 가로 vector.

The bias-corrected kurtosis coefficient is obtained by replacing the sample second and fourth central moments by their unbiased versions. It is an unbiased estimate of the population kurtosis for normal populations.

If 가로 is a matrix, or more generally a multi-dimensional array, return the kurtosis along the first non-singleton dimension. If the optional dim argument is given, operate along this dimension.

같이 보기: var, skewness, moment.

moment (가로, p)
moment (가로, p, type)
moment (가로, p, dim)
moment (가로, p, type, dim)
moment (가로, p, dim, type)

Compute the p-th central moment of the vector 가로.

The p-th central moment of 가로 is defined as:

1/N SUM_i (가로(i) - mean(가로))^p

where N is the length of the 가로 vector.

If 가로 is a matrix, return the row vector containing the p-th central moment of each column.

If the optional argument dim is given, operate along this dimension.

The optional string type specifies the type of moment to be computed. Valid options are:

"c"

Central Moment (default).

"a"
"ac"

Absolute Central Moment. The moment about the mean ignoring sign defined as

1/N SUM_i (abs (가로(i) - mean(가로)))^p
"r"

Raw Moment. The moment about zero defined as

moment (가로) = 1/N SUM_i 가로(i)^p
"ar"

Absolute Raw Moment. The moment about zero ignoring sign defined as

1/N SUM_i ( abs (가로(i)) )^p

If both type and dim are given they may appear in any order.

같이 보기: var, skewness, kurtosis.

q = quantile (가로)
q = quantile (가로, p)
q = quantile (가로, p, dim)
q = quantile (가로, p, dim, method)

For a sample, 가로, calculate the quantiles, q, corresponding to the cumulative probability values in p. All non-numeric values (NaNs) of 가로 are ignored.

If 가로 is a matrix, compute the quantiles for each column and return them in a matrix, such that the i-th row of q contains the p(i)th quantiles of each column of 가로.

If p is unspecified, return the quantiles for [0.00 0.25 0.50 0.75 1.00]. The optional argument dim determines the dimension along which the quantiles are calculated. If dim is omitted it defaults to the first non-singleton dimension.

The methods available to calculate sample quantiles are the nine methods used by R (https://www.r-project.org/). The default value is method = 5.

Discontinuous sample quantile methods 1, 2, and 3

  1. Method 1: Inverse of empirical distribution function.
  2. Method 2: Similar to method 1 but with averaging at discontinuities.
  3. Method 3: SAS definition: nearest even order statistic.

Continuous sample quantile methods 4 through 9, where p(k) is the linear interpolation function respecting each method’s representative cdf.

  1. Method 4: p(k) = k / N. That is, linear interpolation of the empirical cdf, where N is the length of P.
  2. Method 5: p(k) = (k - 0.5) / N. That is, a piecewise linear function where the knots are the values midway through the steps of the empirical cdf.
  3. Method 6: p(k) = k / (N + 1).
  4. Method 7: p(k) = (k - 1) / (N - 1).
  5. Method 8: p(k) = (k - 1/3) / (N + 1/3). The resulting quantile estimates are approximately median-unbiased regardless of the distribution of 가로.
  6. Method 9: p(k) = (k - 3/8) / (N + 1/4). The resulting quantile estimates are approximately unbiased for the expected order statistics if 가로 is normally distributed.

Hyndman and Fan (1996) recommend method 8. Maxima, S, and R (versions prior to 2.0.0) use 7 as their default. Minitab and SPSS use method 6. 매트랩 uses method 5.

References:

Examples:

x = randi (1000, [10, 1]);  # Create empirical data in range 1-1000
q = quantile (x, [0, 1]);   # Return minimum, maximum of distribution
q = quantile (x, [0.25 0.5 0.75]); # Return quartiles of distribution

같이 보기: prctile.

q = prctile (가로)
q = prctile (가로, p)
q = prctile (가로, p, dim)

For a sample 가로, compute the quantiles, q, corresponding to the cumulative probability values, p, in percent.

If 가로 is a matrix, compute the percentiles for each column and return them in a matrix, such that the i-th row of q contains the p(i)th percentiles of each column of 가로.

If p is unspecified, return the quantiles for [0 25 50 75 100].

The optional argument dim determines the dimension along which the percentiles are calculated. If dim is omitted it defaults to the first non-singleton dimension.

Programming Note: All non-numeric values (NaNs) of 가로 are ignored.

같이 보기: quantile.

A summary view of a data set can be generated quickly with the statistics function.

statistics (가로)
statistics (가로, dim)

Return a vector with the minimum, first quartile, median, third quartile, maximum, mean, standard deviation, skewness, and kurtosis of the elements of the vector 가로.

If 가로 is a matrix, calculate statistics over the first non-singleton dimension.

If the optional argument dim is given, operate along this dimension.

같이 보기: min, max, median, mean, std, skewness, kurtosis.


다음: , 상위 문서: Statistics   [차례][찾아보기]