Statistics
**********

Octave has support for various statistical methods.  This includes basic descriptive statistics, probability distributions, statistical tests, random number generation, and much more.

The functions that analyze data all assume that multi-dimensional data is arranged in a matrix where each row is an observation, and each column is a variable.  Thus, the matrix defined by

     a = [ 0.9, 0.7;
           0.1, 0.1;
           0.5, 0.4 ];

contains three observations from a two-dimensional distribution. While this is the default data arrangement, most functions support different arrangements.

It should be noted that the statistics functions don't test for data containing NaN, NA, or Inf.  These values need to be detected and dealt with explicitly.  See isnan, isna, isinf, isfinite.

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)

(median)

(mode)

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.

(range)

(iqr)

(meansq)

(std)

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)

(skewness)

(kurtosis)

(moment)

(quantile)

(prctile)

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

(statistics)

Basic Statistical Functions
===========================

Octave supports various helpful statistical functions.  Many are useful as initial steps to prepare a data set for further analysis.  Others provide different measures from those of the basic descriptive statistics.

(center)

(zscore)

(histc)

(nchoosek)

(perms)

(ranks)

(run_count)

(runlength)

(probit)

(logit)

(cloglog)

(mahalanobis)

(table)

Statistical Plots
=================

Octave can create Quantile Plots (QQ-Plots), and Probability Plots (PP-Plots).  These are simple graphical tests for determining if a data set comes from a certain distribution.

Note that Octave can also show histograms of data using the hist function as described in Two-Dimensional Plots.

(qqplot)

(ppplot)

Correlation and Regression Analysis
===================================

(cov)

(corr)

(spearman)

(kendall)

(logistic_regression)

Distributions
=============

Octave has functions for computing the Probability Density Function (PDF), the Cumulative Distribution function (CDF), and the quantile (the inverse of the CDF) for a large number of distributions.

The following table summarizes the supported distributions (in alphabetical order).

Distribution
PDF
CDF
Quantile
Beta Distribution
betapdf
betacdf
betainv
Binomial Distribution
binopdf
binocdf
binoinv
Cauchy Distribution
cauchy_pdf
cauchy_cdf
cauchy_inv
Chi-Square Distribution
chi2pdf
chi2cdf
chi2inv
Univariate Discrete Distribution
discrete_pdf
discrete_cdf
discrete_inv
Empirical Distribution
empirical_pdf
empirical_cdf
empirical_inv
Exponential Distribution
exppdf
expcdf
expinv
F Distribution
fpdf
fcdf
finv
Gamma Distribution
gampdf
gamcdf
gaminv
Geometric Distribution
geopdf
geocdf
geoinv
Hypergeometric Distribution
hygepdf
hygecdf
hygeinv
Kolmogorov Smirnov Distribution
Not Available
kolmogorov_smirnov_cdf
Not Available
Laplace Distribution
laplace_pdf
laplace_cdf
laplace_inv
Logistic Distribution
logistic_pdf
logistic_cdf
logistic_inv
Log-Normal Distribution
lognpdf
logncdf
logninv
Univariate Normal Distribution
normpdf
normcdf
norminv
Pascal Distribution
nbinpdf
nbincdf
nbininv
Poisson Distribution
poisspdf
poisscdf
poissinv
Standard Normal Distribution
stdnormal_pdf
stdnormal_cdf
stdnormal_inv
t (Student) Distribution
tpdf
tcdf
tinv
Univariate Discrete Distribution
unidpdf
unidcdf
unidinv
Uniform Distribution
unifpdf
unifcdf
unifinv
Weibull Distribution
wblpdf
wblcdf
wblinv

(betapdf)

(betacdf)

(betainv)

(binopdf)

(binocdf)

(binoinv)

(cauchy_pdf)

(cauchy_cdf)

(cauchy_inv)

(chi2pdf)

(chi2cdf)

(chi2inv)

(discrete_pdf)

(discrete_cdf)

(discrete_inv)

(empirical_pdf)

(empirical_cdf)

(empirical_inv)

(exppdf)

(expcdf)

(expinv)

(fpdf)

(fcdf)

(finv)

(gampdf)

(gamcdf)

(gaminv)

(geopdf)

(geocdf)

(geoinv)

(hygepdf)

(hygecdf)

(hygeinv)

(kolmogorov_smirnov_cdf)

(laplace_pdf)

(laplace_cdf)

(laplace_inv)

(logistic_pdf)

(logistic_cdf)

(logistic_inv)

(lognpdf)

(logncdf)

(logninv)

(nbinpdf)

(nbincdf)

(nbininv)

(normpdf)

(normcdf)

(norminv)

(poisspdf)

(poisscdf)

(poissinv)

(stdnormal_pdf)

(stdnormal_cdf)

(stdnormal_inv)

(tpdf)

(tcdf)

(tinv)

(unidpdf)

(unidcdf)

(unidinv)

(unifpdf)

(unifcdf)

(unifinv)

(wblpdf)

(wblcdf)

(wblinv)

Tests
=====

Octave can perform many different statistical tests.  The following table summarizes the available tests.

Hypothesis
Test Functions
Equal mean values
anova, hotelling_test2, t_test_2,
welch_test, wilcoxon_test, z_test_2
Equal medians
kruskal_wallis_test, sign_test
Equal variances
bartlett_test, manova, var_test
Equal distributions
chisquare_test_homogeneity, kolmogorov_smirnov_test_2,
u_test
Equal marginal frequencies
mcnemar_test
Equal success probabilities
prop_test_2
Independent observations
chisquare_test_independence, run_test
Uncorrelated observations
cor_test
Given mean value
hotelling_test, t_test, z_test
Observations from given distribution
kolmogorov_smirnov_test
Regression
f_test_regression, t_test_regression

The tests return a p-value that describes the outcome of the test. Assuming that the test hypothesis is true, the p-value is the probability of obtaining a worse result than the observed one.  So large p-values corresponds to a successful test.  Usually a test hypothesis is accepted if the p-value exceeds 0.05.

(anova)

(bartlett_test)

(chisquare_test_homogeneity)

(chisquare_test_independence)

(cor_test)

(f_test_regression)

(hotelling_test)

(hotelling_test_2)

(kolmogorov_smirnov_test)

(kolmogorov_smirnov_test_2)

(kruskal_wallis_test)

(manova)

(mcnemar_test)

(prop_test_2)

(run_test)

(sign_test)

(t_test)

(t_test_2)

(t_test_regression)

(u_test)

(var_test)

(welch_test)

(wilcoxon_test)

(z_test)

(z_test_2)

Random Number Generation
========================

Octave can generate random numbers from a large number of distributions. The random number generators are based on the random number generators described in Special Utility Matrices.

The following table summarizes the available random number generators (in alphabetical order).

Distribution                    Function
Beta Distribution                   betarnd
Binomial Distribution               binornd
Cauchy Distribution                 cauchy_rnd
Chi-Square Distribution             chi2rnd
Univariate Discrete Distribution    discrete_rnd
Empirical Distribution              empirical_rnd
Exponential Distribution            exprnd
F Distribution                      frnd
Gamma Distribution                  gamrnd
Geometric Distribution              geornd
Hypergeometric Distribution         hygernd
Laplace Distribution                laplace_rnd
Logistic Distribution               logistic_rnd
Log-Normal Distribution             lognrnd
Pascal Distribution                 nbinrnd
Univariate Normal Distribution      normrnd
Poisson Distribution                poissrnd
Standard Normal Distribution        stdnormal_rnd
t (Student) Distribution            trnd
Univariate Discrete Distribution    unidrnd
Uniform Distribution                unifrnd
Weibull Distribution                wblrnd
Wiener Process                      wienrnd

(betarnd)

(binornd)

(cauchy_rnd)

(chi2rnd)

(discrete_rnd)

(empirical_rnd)

(exprnd)

(frnd)

(gamrnd)

(geornd)

(hygernd)

(laplace_rnd)

(logistic_rnd)

(lognrnd)

(nbinrnd)

(normrnd)

(poissrnd)

(stdnormal_rnd)

(trnd)

(unidrnd)

(unifrnd)

(wblrnd)

(wienrnd)