# HG changeset patch # User jwe # Date 1182792707 0 # Node ID 451b346d8c2f0c70aac957039149764ade0d2772 # Parent a5c64dad5b936e61ef12dd922e85028aebe9d371 [project @ 2007-06-25 17:31:46 by jwe] diff -r a5c64dad5b93 -r 451b346d8c2f doc/ChangeLog --- a/doc/ChangeLog Mon Jun 25 17:05:58 2007 +0000 +++ b/doc/ChangeLog Mon Jun 25 17:31:47 2007 +0000 @@ -1,3 +1,9 @@ +2007-06-25 John W. Eaton + + * interpreter/stats.txi: Reorganize sections and add introductory text. + + * interpreter/octave.texi: Update to reflect changes in stats.txi. + 2007-06-18 David Bateman * interpreter/interpimages.m: Simpler images to demonstrate diff -r a5c64dad5b93 -r 451b346d8c2f doc/interpreter/contributors.in --- a/doc/interpreter/contributors.in Mon Jun 25 17:05:58 2007 +0000 +++ b/doc/interpreter/contributors.in Mon Jun 25 17:31:47 2007 +0000 @@ -80,6 +80,7 @@ Atsushi Kajita Mohamed Kamoun Lute Kamstra +Joel Keay Mumit Khan Paul Kienzle Aaron A. King diff -r a5c64dad5b93 -r 451b346d8c2f doc/interpreter/octave.texi --- a/doc/interpreter/octave.texi Mon Jun 25 17:05:58 2007 +0000 +++ b/doc/interpreter/octave.texi Mon Jun 25 17:31:47 2007 +0000 @@ -432,10 +432,13 @@ Statistics -* Basic Statistical Functions:: +* Descriptive Statistics:: +* Basic Statistical Functions:: +* Statistical Plots:: * Tests:: * Models:: -* Distributions:: +* Distributions:: +* Random Number Generation:: Sets diff -r a5c64dad5b93 -r 451b346d8c2f doc/interpreter/sparse.txi --- a/doc/interpreter/sparse.txi Mon Jun 25 17:05:58 2007 +0000 +++ b/doc/interpreter/sparse.txi Mon Jun 25 17:31:47 2007 +0000 @@ -473,7 +473,7 @@ @dfn{dmperm}, @dfn{symamd}, @dfn{randperm}, @dfn{symrcm} @item Linear algebra: - @dfn{matrix\_type}, @dfn{spchol}, @dfn{cpcholinv}, + @dfn{matrix_type}, @dfn{spchol}, @dfn{cpcholinv}, @dfn{spchol2inv}, @dfn{spdet}, @dfn{spinv}, @dfn{spkron}, @dfn{splchol}, @dfn{splu}, @dfn{spqr}, @dfn{normest}, @dfn{sprank} diff -r a5c64dad5b93 -r 451b346d8c2f doc/interpreter/stats.txi --- a/doc/interpreter/stats.txi Mon Jun 25 17:05:58 2007 +0000 +++ b/doc/interpreter/stats.txi Mon Jun 25 17:31:47 2007 +0000 @@ -5,33 +5,77 @@ @node Statistics @chapter Statistics +Octave has support for various statistical methods. This includes +basic descriptive statistics, statistical tests, random number generation, +and much more. + +The functions that analyze data all assume that multidimensional data +is arranged in a matrix where each row is an observation, and each +column is a variable. So, the matrix defined by + +@example +a = [ 0.9, 0.7; + 0.1, 0.1; + 0.5, 0.4 ]; +@end example + +@noindent +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 doesn't handle data +containing NaN, NA, or Inf. Such values needs to be handled explicitly. + @menu -* Basic Statistical Functions:: +* Descriptive Statistics:: +* Basic Statistical Functions:: +* Statistical Plots:: * Tests:: * Models:: -* Distributions:: +* Distributions:: +* Random Number Generation:: @end menu -@node Basic Statistical Functions -@section Basic Statistical Functions +@node Descriptive Statistics +@section Descriptive Statistics + +Octave can compute various statistics such as the moments of a data set. @DOCSTRING(mean) @DOCSTRING(median) +@DOCSTRING(meansq) + @DOCSTRING(std) +@DOCSTRING(var) + @DOCSTRING(cov) +@DOCSTRING(cor) + @DOCSTRING(corrcoef) @DOCSTRING(kurtosis) +@DOCSTRING(skewness) + +@DOCSTRING(statistics) + +@DOCSTRING(moment) + +@node Basic Statistical Functions +@section Basic Statistical Functions + +Octave also supports various helpful statistical functions. + @DOCSTRING(mahalanobis) -@DOCSTRING(skewness) +@DOCSTRING(center) -@c FIXME -- these need to be organized. +@DOCSTRING(studentize) @DOCSTRING(nchoosek) @@ -39,14 +83,8 @@ @DOCSTRING(values) -@DOCSTRING(var) - @DOCSTRING(table) -@DOCSTRING(studentize) - -@DOCSTRING(statistics) - @DOCSTRING(spearman) @DOCSTRING(run_count) @@ -55,17 +93,11 @@ @DOCSTRING(range) -@DOCSTRING(qqplot) - @DOCSTRING(probit) -@DOCSTRING(ppplot) - -@DOCSTRING(moment) +@DOCSTRING(logit) -@DOCSTRING(meansq) - -@DOCSTRING(logit) +@DOCSTRING(cloglog) @DOCSTRING(kendall) @@ -73,15 +105,65 @@ @DOCSTRING(cut) -@DOCSTRING(cor) +@node Statistical Plots +@section Statistical Plots + +@c Should hist be moved to here, or perhaps the qqplot and ppplot +@c functions should be moved to the Plotting Chapter? -@DOCSTRING(cloglog) +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. -@DOCSTRING(center) +It is worth noticing that Octave can also show histograms of data +using the @code{hist} function as described in +@ref{Specialized Two-Dimensional Plots}. + +@DOCSTRING(qqplot) + +@DOCSTRING(ppplot) @node Tests @section Tests +Octave can perform several different statistical tests. The following +table summarizes the available tests. + +@multitable @columnfractions .4 .5 +@item @strong{Hypothesis} + @tab @strong{Test Functions} +@item Equal mean values + @tab @code{anova}, @code{hotelling_test2}, @code{t_test_2}, + @code{welch_test}, @code{wilcoxon_test}, @code{z_test_2} +@item Equal medians + @tab @code{kruskal_wallis_test}, @code{sign_test} +@item Equal variances + @tab @code{bartlett_test}, @code{manova}, @code{var_test} +@item Equal distributions + @tab @code{chisquare_test_homogeneity}, @code{kolmogorov_smirnov_test_2}, + @code{u_test} +@item Equal marginal frequencies + @tab @code{mcnemar_test} +@item Equal success probabilities + @tab @code{prop_test_2} +@item Independent observations + @tab @code{chisquare_test_independence}, @code{run_test} +@item Uncorrelated observations + @tab @code{cor_test} +@item Given mean value + @tab @code{hotelling_test}, @code{t_test}, @code{z_test} +@item Observations from given distribution + @tab @code{kolmogorov_smirnov_test} +@item Regression + @tab @code{f_test_regression}, @code{t_test_regression} +@end multitable + +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 then the observed one. So large p-values +corresponds to a successful test. Usually a test hypothesis is accepted +if the p-value exceeds @math{0.05}. + @DOCSTRING(anova) @DOCSTRING(bartlett_test) @@ -140,94 +222,174 @@ @node Distributions @section Distributions +Octave has functions for computing the Probability Density Function +(PDF), the Cumulative Distribution function (CDF), and the quantile +(the inverse of the CDF) of a large number of distributions. + +The following table summarizes the supported distributions (in +alphabetical order). + +@multitable @columnfractions .4 .2 .2 .2 +@item @strong{Distribution} + @tab @strong{PDF} + @tab @strong{CDF} + @tab @strong{Quantile} +@item Beta Distribution + @tab @code{betapdf} + @tab @code{betacdf} + @tab @code{betainv} +@item Binomial Distribution + @tab @code{binopdf} + @tab @code{binocdf} + @tab @code{binoinv} +@item Cauchy Distribution + @tab @code{cauchy_pdf} + @tab @code{cauchy_cdf} + @tab @code{cauchy_inv} +@item Chi-Square Distribution + @tab @code{chi2pdf} + @tab @code{chi2cdf} + @tab @code{chi2inv} +@item Univariate Discrete Distribution + @tab @code{discrete_pdf} + @tab @code{discrete_cdf} + @tab @code{discrete_inv} +@item Empirical Distribution + @tab @code{empirical_pdf} + @tab @code{empirical_cdf} + @tab @code{empirical_inv} +@item Exponential Distribution + @tab @code{exppdf} + @tab @code{expcdf} + @tab @code{expinv} +@item F Distribution + @tab @code{fpdf} + @tab @code{fcdf} + @tab @code{finv} +@item Gamma Distribution + @tab @code{gampdf} + @tab @code{gamcdf} + @tab @code{gaminv} +@item Geometric Distribution + @tab @code{geopdf} + @tab @code{geocdf} + @tab @code{geoinv} +@item Hypergeometric Distribution + @tab @code{hygepdf} + @tab @code{hygecdf} + @tab @code{hygeinv} +@item Kolmogorov Smirnov Distribution + @tab @emph{Not Available} + @tab @code{kolmogorov_smirnov_cdf} + @tab @emph{Not Available} +@item Laplace Distribution + @tab @code{laplace_pdf} + @tab @code{laplace_cdf} + @tab @code{laplace_inv} +@item Logistic Distribution + @tab @code{logistic_pdf} + @tab @code{logistic_cdf} + @tab @code{logistic_inv} +@item Log-Normal Distribution + @tab @code{lognpdf} + @tab @code{logncdf} + @tab @code{logninv} +@item Pascal Distribution + @tab @code{nbinpdf} + @tab @code{nbincdf} + @tab @code{nbininv} +@item Univariate Normal Distribution + @tab @code{normpdf} + @tab @code{normcdf} + @tab @code{norminv} +@item Poisson Distribution + @tab @code{poisspdf} + @tab @code{poisscdf} + @tab @code{poissinv} +@item t (Student) Distribution + @tab @code{tpdf} + @tab @code{tcdf} + @tab @code{tinv} +@item Univariate Discrete Distribution + @tab @code{unidpdf} + @tab @code{unidcdf} + @tab @code{unidinv} +@item Uniform Distribution + @tab @code{unifpdf} + @tab @code{unifcdf} + @tab @code{unifinv} +@item Weibull Distribution + @tab @code{wblpdf} + @tab @code{wblcdf} + @tab @code{wblinv} +@end multitable + @DOCSTRING(betacdf) @DOCSTRING(betainv) @DOCSTRING(betapdf) -@DOCSTRING(betarnd) - @DOCSTRING(binocdf) @DOCSTRING(binoinv) @DOCSTRING(binopdf) -@DOCSTRING(binornd) - @DOCSTRING(cauchy_cdf) @DOCSTRING(cauchy_inv) @DOCSTRING(cauchy_pdf) -@DOCSTRING(cauchy_rnd) - @DOCSTRING(chi2cdf) @DOCSTRING(chi2inv) @DOCSTRING(chi2pdf) -@DOCSTRING(chi2rnd) - @DOCSTRING(discrete_cdf) @DOCSTRING(discrete_inv) @DOCSTRING(discrete_pdf) -@DOCSTRING(discrete_rnd) - @DOCSTRING(empirical_cdf) @DOCSTRING(empirical_inv) @DOCSTRING(empirical_pdf) -@DOCSTRING(empirical_rnd) - @DOCSTRING(expcdf) @DOCSTRING(expinv) @DOCSTRING(exppdf) -@DOCSTRING(exprnd) - @DOCSTRING(fcdf) @DOCSTRING(finv) @DOCSTRING(fpdf) -@DOCSTRING(frnd) - @DOCSTRING(gamcdf) @DOCSTRING(gaminv) @DOCSTRING(gampdf) -@DOCSTRING(gamrnd) - @DOCSTRING(geocdf) @DOCSTRING(geoinv) @DOCSTRING(geopdf) -@DOCSTRING(geornd) - @DOCSTRING(hygecdf) @DOCSTRING(hygeinv) @DOCSTRING(hygepdf) -@DOCSTRING(hygernd) - @DOCSTRING(kolmogorov_smirnov_cdf) @DOCSTRING(laplace_cdf) @@ -236,78 +398,138 @@ @DOCSTRING(laplace_pdf) -@DOCSTRING(laplace_rnd) - @DOCSTRING(logistic_cdf) @DOCSTRING(logistic_inv) @DOCSTRING(logistic_pdf) -@DOCSTRING(logistic_rnd) - @DOCSTRING(logncdf) @DOCSTRING(logninv) @DOCSTRING(lognpdf) -@DOCSTRING(lognrnd) - @DOCSTRING(nbincdf) @DOCSTRING(nbininv) @DOCSTRING(nbinpdf) -@DOCSTRING(nbinrnd) - @DOCSTRING(normcdf) @DOCSTRING(norminv) @DOCSTRING(normpdf) -@DOCSTRING(normrnd) - @DOCSTRING(poisscdf) @DOCSTRING(poissinv) @DOCSTRING(poisspdf) -@DOCSTRING(poissrnd) - @DOCSTRING(tcdf) @DOCSTRING(tinv) @DOCSTRING(tpdf) -@DOCSTRING(trnd) - @DOCSTRING(unidcdf) @DOCSTRING(unidinv) @DOCSTRING(unidpdf) -@DOCSTRING(unidrnd) - @DOCSTRING(unifcdf) @DOCSTRING(unifinv) @DOCSTRING(unifpdf) -@DOCSTRING(unifrnd) - @DOCSTRING(wblcdf) @DOCSTRING(wblinv) @DOCSTRING(wblpdf) +@node Random Number Generation +@section 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 @ref{Special Utility Matrices}. +@c Should rand, randn, rande, randp, and randg be moved to here? + +The following table summarizes the available random number generators +(in alphabetical order). + +@multitable @columnfractions .4 .3 +@item @strong{Distribution} @tab @strong{Function} +@item Beta Distribution @tab @code{betarnd} +@item Binomial Distribution @tab @code{binornd} +@item Cauchy Distribution @tab @code{cauchy_rnd} +@item Chi-Square Distribution @tab @code{chi2rnd} +@item Univariate Discrete Distribution @tab @code{discrete_rnd} +@item Empirical Distribution @tab @code{empirical_rnd} +@item Exponential Distribution @tab @code{exprnd} +@item F Distribution @tab @code{frnd} +@item Gamma Distribution @tab @code{gamrnd} +@item Geometric Distribution @tab @code{geornd} +@item Hypergeometric Distribution @tab @code{hygernd} +@item Laplace Distribution @tab @code{laplace_rnd} +@item Logistic Distribution @tab @code{logistic_rnd} +@item Log-Normal Distribution @tab @code{lognrnd} +@item Pascal Distribution @tab @code{nbinrnd} +@item Univariate Normal Distribution @tab @code{normrnd} +@item Poisson Distribution @tab @code{poissrnd} +@item t (Student) Distribution @tab @code{trnd} +@item Univariate Discrete Distribution @tab @code{unidrnd} +@item Uniform Distribution @tab @code{unifrnd} +@item Weibull Distribution @tab @code{wblrnd} +@item Wiener Process @tab @code{wienrnd} +@end multitable + +@DOCSTRING(betarnd) + +@DOCSTRING(binornd) + +@DOCSTRING(cauchy_rnd) + +@DOCSTRING(chi2rnd) + +@DOCSTRING(discrete_rnd) + +@DOCSTRING(empirical_rnd) + +@DOCSTRING(exprnd) + +@DOCSTRING(frnd) + +@DOCSTRING(gamrnd) + +@DOCSTRING(geornd) + +@DOCSTRING(hygernd) + +@DOCSTRING(laplace_rnd) + +@DOCSTRING(logistic_rnd) + +@DOCSTRING(lognrnd) + +@DOCSTRING(nbinrnd) + +@DOCSTRING(normrnd) + +@DOCSTRING(poissrnd) + +@DOCSTRING(trnd) + +@DOCSTRING(unidrnd) + +@DOCSTRING(unifrnd) + @DOCSTRING(wblrnd) @DOCSTRING(wienrnd) + diff -r a5c64dad5b93 -r 451b346d8c2f scripts/ChangeLog --- a/scripts/ChangeLog Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/ChangeLog Mon Jun 25 17:31:47 2007 +0000 @@ -1,3 +1,58 @@ +2007-06-25 Joel Keay + + * plot/drawnow.m: Handle GNUTERM=aqua if DISPLAY is not set. + +2007-06-25 Søren Hauberg + + * statistics/base/median.m: Update help text to mention 'dim' + argument, and note that the data should be sorted for the + definition of the median to be correct. + + * statistics/base/std.m: Add missing square to definition of + standard deviation. + + * statistics/base/cov.m: Add definition of covariance to the help text. + + * statistics/base/kurtosis.m, statistics/base/skewness.m, + statistics/base/std.m: + Note that \bar{x} is the mean value of x in the help text. + + * specfun/nchoosek.m: Add alternative definition of the binomial + coefficient to the help text. + + * specfun/perms.m, statistics/base/values.m: Add example in help text. + + * statistics/base/var.m: Put N in @math in help text. + + * statistics/base/qqplot.m, statistics/base/ppplot.m, + statistics/tests/kolmogorov_smirnov_test.m: + Write about possible values of 'dist' in help text. + + * statistics/base/corrcoef.m, statistics/base/cor.m: + Add definition of correlation to the help text. + + * statistics/base/logit.m, statistics/base/kendall.m, + statistics/base/cloglog.m, statistics/tests/hotelling_test_2.m, + statistics/distributions/wblcdf.m, statistics/distributions/wblpdf.m: + TeXification of help text. + + * statistics/tests/hotelling_test.m: Write T^2 in @math in help text. + + * statistics/tests/var_test.m, statistics/tests/welch_test.m: + Add missing @var's to help text. + + * statistics/models/logistic_regression.m: Fix typos in help text. + + * statistics/distributions/kolmogorov_smirnov_cdf.m: Fix TeX part + of help text. + + * statistics/distributions/unidinv.m: Add a missing 'discrete' to + help text. + + * statistics/distributions/unidpdf.m, + statistics/distributions/discrete_pdf.m: + Replace 'pDF' with 'PDF' in help text. + 2007-06-25 John W. Eaton * strings/substr.m: Use offset consistently in code and doc string. @@ -1635,7 +1690,7 @@ * image/__img_via_file__.m: New function. * image/image.m: Use image_viewer to determine which program to use for image viewing. - * scripts/image/__img__.m: Silently accept more than 3 args. + * image/__img__.m: Silently accept more than 3 args. 2006-11-14 John W. Eaton @@ -1661,17 +1716,13 @@ 2006-11-13 Søren Hauberg - * scripts/general/bicubic.m, scripts/general/cart2pol.m - scripts/general/cart2sph.m, scripts/plot/contour.m, - scripts/linear-algebra/cross.m, scripts/general/cumtrapz.m, - scripts/linear-algebra/dot.m, scripts/image/imshow.m, - scripts/general/interp2.m, scripts/general/mod.m, - scripts/plot/plot3.m, scripts/plot/__plr2__.m, - scripts/plot/__plr__.m, scripts/general/pol2cart.m, - scripts/general/polyarea.m, scripts/polynomial/polyfit.m, - scripts/general/rem.m, scripts/image/rgb2ind.m, - scripts/general/sph2cart.m, scripts/general/trapz.m, - scripts/miscellaneous/xor.m: Use size_equal + * general/bicubic.m, general/cart2pol.m, general/cart2sph.m, + plot/contour.m, linear-algebra/cross.m, general/cumtrapz.m, + linear-algebra/dot.m, image/imshow.m, general/interp2.m, + general/mod.m, plot/plot3.m, plot/__plr2__.m, plot/__plr__.m, + general/pol2cart.m, general/polyarea.m, polynomial/polyfit.m, + general/rem.m, image/rgb2ind.m, general/sph2cart.m, + general/trapz.m, miscellaneous/xor.m: Use size_equal. 2006-11-13 John W. Eaton @@ -1741,7 +1792,7 @@ * strings/index.m: New arg, direction. Simplify and speed up. * strings/rindex.m: Implement using index (..., "last"); - * scripts/blanks.m, scripts/strcat.m: Simplify. Add tests. + * blanks.m, strcat.m: Simplify. Add tests. 2006-11-01 Bill Denney @@ -2389,19 +2440,16 @@ 2006-05-22 John W. Eaton - * scripts/general/lookup.m: New file from Octave Forge. + * general/lookup.m: New file from Octave Forge. 2006-05-22 David Bateman - * scripts/general/nthroot.m, scripts/linear-algebra/rref.m, - scripts/specfun/isprime.m, scripts/specfun/primes.m, - scripts/specfun/factor.m, scripts/specfun/nchoosek.m, - scripts/specfun/legendre.m, scripts/specfun/perms.m, - scripts/special-matrix/rosser.m, - scripts/special-matrix/wilkinson.m, - scripts/special-matrix/pascal.m, scripts/special-matrix/magic.m, - scripts/special-matrix/hadamard.m, scripts/strings/strtok.m: - New files from Octave Forge. + * general/nthroot.m, linear-algebra/rref.m, specfun/isprime.m, + specfun/primes.m, specfun/factor.m, specfun/nchoosek.m, + specfun/legendre.m, specfun/perms.m, special-matrix/rosser.m, + special-matrix/wilkinson.m, special-matrix/pascal.m, + special-matrix/magic.m, special-matrix/hadamard.m, + strings/strtok.m: New files from Octave Forge. 2006-05-19 David Bateman @@ -2470,7 +2518,7 @@ 2006-05-03 Bob Weigel - * scripts/set/setdiff.m: New arg, byrows. New tests. + * set/setdiff.m: New arg, byrows. New tests. 2006-04-29 John W. Eaton @@ -2503,7 +2551,7 @@ 2006-04-04 Bob Weigel - * scripts/set/unique.m: Properly handle single column input when + * set/unique.m: Properly handle single column input when "rows" is specified. 2006-04-04 John W. Eaton @@ -3484,7 +3532,7 @@ * statistics/Makefile.in (bin-dist): Delete target. (BINDISTSUBDIRS): Delete variable. - * scripts/control/Makefile.in: Likewise. + * control/Makefile.in: Likewise. * audio/Makefile.in (bin-dist): Delete target. (BINDISTFILES): Delete variable. diff -r a5c64dad5b93 -r 451b346d8c2f scripts/plot/drawnow.m --- a/scripts/plot/drawnow.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/plot/drawnow.m Mon Jun 25 17:31:47 2007 +0000 @@ -110,7 +110,11 @@ fprintf (plot_stream, "set terminal %s\n;", term); fprintf (plot_stream, "set output \"%s\"\n;", file); elseif (isunix () && isempty (getenv ("DISPLAY"))) - fprintf (plot_stream, "set terminal dumb\n;"); + if (strcmp (getenv ("GNUTERM"), "aqua")) + fprintf (plot_stream, "set terminal aqua title \"Figure %d\";\n", h); + else + fprintf (plot_stream, "set terminal dumb\n;"); + endif elseif (! isempty (h) && strcmp (getenv ("GNUTERM"), "wxt")) fprintf (plot_stream, "set terminal wxt title \"Figure %d\";\n", h); endif diff -r a5c64dad5b93 -r 451b346d8c2f scripts/specfun/nchoosek.m --- a/scripts/specfun/nchoosek.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/specfun/nchoosek.m Mon Jun 25 17:31:47 2007 +0000 @@ -28,6 +28,7 @@ ## @tex ## $$ ## {n \choose k} = {n (n-1) (n-2) \cdots (n-k+1) \over k!} +## = {n! \over k! (n-k)!} ## $$ ## @end tex ## @end iftex @@ -36,9 +37,9 @@ ## @example ## @group ## / \ -## | n | n (n-1) (n-2) ... (n-k+1) -## | | = ------------------------- -## | k | k! +## | n | n (n-1) (n-2) ... (n-k+1) n! +## | | = ------------------------- = --------- +## | k | k! k! (n-k)! ## \ / ## @end group ## @end example diff -r a5c64dad5b93 -r 451b346d8c2f scripts/specfun/perms.m --- a/scripts/specfun/perms.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/specfun/perms.m Mon Jun 25 17:31:47 2007 +0000 @@ -24,6 +24,15 @@ ## result has size @code{factorial (@var{n}) * @var{n}}, where @var{n} ## is the length of @var{v}. ## +## As an example, @code{perms([1, 2, 3])} returns the matrix +## @example +## 1 2 3 +## 2 1 3 +## 1 3 2 +## 2 3 1 +## 3 1 2 +## 3 2 1 +## @end example ## @end deftypefn function A = perms (v) diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/cloglog.m --- a/scripts/statistics/base/cloglog.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/cloglog.m Mon Jun 25 17:31:47 2007 +0000 @@ -21,9 +21,18 @@ ## @deftypefn {Function File} {} cloglog (@var{x}) ## Return the complementary log-log function of @var{x}, defined as ## +## @iftex +## @tex +## $$ +## {\rm cloglog}(x) = - \log (- \log (x)) +## $$ +## @end tex +## @end iftex +## @ifnottex ## @example -## - log (- log (@var{x})) +## cloglog(x) = - log (- log (@var{x})) ## @end example +## @end ifnottex ## @end deftypefn ## Author: KH @@ -37,4 +46,4 @@ y = - log (- log (x)); -endfunction \ No newline at end of file +endfunction diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/cor.m --- a/scripts/statistics/base/cor.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/cor.m Mon Jun 25 17:31:47 2007 +0000 @@ -19,14 +19,31 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} cor (@var{x}, @var{y}) +## Compute correlation. +## ## The (@var{i}, @var{j})-th entry of @code{cor (@var{x}, @var{y})} is ## the correlation between the @var{i}-th variable in @var{x} and the ## @var{j}-th variable in @var{y}. ## +## @iftex +## @tex +## $$ +## {\rm corrcoef}(x,y) = {{\rm cov}(x,y) \over {\rm std}(x) {\rm std}(y)} +## $$ +## @end tex +## @end iftex +## @ifnottex +## @example +## corrcoef(x,y) = cov(x,y)/(std(x)*std(y)) +## @end example +## @end ifnottex +## ## For matrices, each row is an observation and each column a variable; ## vectors are always observations and may be row or column vectors. ## ## @code{cor (@var{x})} is equivalent to @code{cor (@var{x}, @var{x})}. +## +## Note that the @code{corrcoef} function does the same as @code{cor}. ## @end deftypefn ## Author: KH diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/corrcoef.m --- a/scripts/statistics/base/corrcoef.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/corrcoef.m Mon Jun 25 17:31:47 2007 +0000 @@ -19,10 +19,26 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} corrcoef (@var{x}, @var{y}) +## Compute correlation. +## ## If each row of @var{x} and @var{y} is an observation and each column is ## a variable, the (@var{i}, @var{j})-th entry of ## @code{corrcoef (@var{x}, @var{y})} is the correlation between the ## @var{i}-th variable in @var{x} and the @var{j}-th variable in @var{y}. +## +## @iftex +## @tex +## $$ +## {\rm corrcoef}(x,y) = {{\rm cov}(x,y) \over {\rm std}(x) {\rm std}(y)} +## $$ +## @end tex +## @end iftex +## @ifnottex +## @example +## corrcoef(x,y) = cov(x,y)/(std(x)*std(y)) +## @end example +## @end ifnottex +## ## If called with one argument, compute @code{corrcoef (@var{x}, @var{x})}. ## @end deftypefn diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/cov.m --- a/scripts/statistics/base/cov.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/cov.m Mon Jun 25 17:31:47 2007 +0000 @@ -19,11 +19,21 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} cov (@var{x}, @var{y}) +## Compute covariance. +## ## If each row of @var{x} and @var{y} is an observation and each column is ## a variable, the (@var{i}, @var{j})-th entry of ## @code{cov (@var{x}, @var{y})} is the covariance between the @var{i}-th -## variable in @var{x} and the @var{j}-th variable in @var{y}. If called -## with one argument, compute @code{cov (@var{x}, @var{x})}. +## variable in @var{x} and the @var{j}-th variable in @var{y}. +## @iftex +## @tex +## $$ +## \sigma_{ij} = {1 \over N-1} \sum_{i=1}^N (x_i - \bar{x})(y_i - \bar{y}) +## $$ +## where $\bar{x}$ and $\bar{y}$ are the mean values of $x$ and $y$. +## @end tex +## @end iftex +## If called with one argument, compute @code{cov (@var{x}, @var{x})}. ## @end deftypefn ## Author: KH diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/kendall.m --- a/scripts/statistics/base/kendall.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/kendall.m Mon Jun 25 17:31:47 2007 +0000 @@ -61,7 +61,14 @@ ## ## If @var{x} and @var{y} are drawn from independent distributions, ## Kendall's @var{tau} is asymptotically normal with mean 0 and variance +## @iftex +## @tex +## ${2 (2n+5) \over 9n(n-1)}$. +## @end tex +## @end iftex +## @ifnottex ## @code{(2 * (2@var{n}+5)) / (9 * @var{n} * (@var{n}-1))}. +## @end ifnottex ## @end deftypefn ## Author: KH @@ -97,4 +104,4 @@ tau = tau (1 : c, (c + 1) : columns (x)); endif -endfunction \ No newline at end of file +endfunction diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/kurtosis.m --- a/scripts/statistics/base/kurtosis.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/kurtosis.m Mon Jun 25 17:31:47 2007 +0000 @@ -25,6 +25,7 @@ ## $$ ## {\rm kurtosis} (x) = {1\over N \sigma(x)^4} \sum_{i=1}^N (x_i-\bar{x})^4 - 3 ## $$ +## where $\bar{x}$ is the mean value of $x$. ## @end tex ## @end iftex ## @ifinfo diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/logit.m --- a/scripts/statistics/base/logit.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/logit.m Mon Jun 25 17:31:47 2007 +0000 @@ -19,8 +19,18 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} logit (@var{p}) -## For each component of @var{p}, return the logit @code{log (@var{p} / -## (1-@var{p}))} of @var{p}. +## For each component of @var{p}, return the logit of @var{p} defined as +## @iftex +## @tex +## $$ +## {\rm logit}(p) = \log\Big({p \over 1-p}\Big) +## $$ +## @end tex +## @ifnottex +## @example +## logit(@var{p}) = log (@var{p} / (1-@var{p})) +## @end example +## @end ifnottex ## @end deftypefn ## Author: KH @@ -34,4 +44,4 @@ print_usage (); endif -endfunction \ No newline at end of file +endfunction diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/median.m --- a/scripts/statistics/base/median.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/median.m Mon Jun 25 17:31:47 2007 +0000 @@ -18,9 +18,10 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} median (@var{x}) +## @deftypefn {Function File} {} median (@var{x}, @var{dim}) ## If @var{x} is a vector, compute the median value of the elements of -## @var{x}. +## @var{x}. If the elements of @var{x} are sorted, the median is defined +## as ## @iftex ## @tex ## $$ @@ -41,7 +42,8 @@ ## @end example ## @end ifinfo ## If @var{x} is a matrix, compute the median value for each -## column and return them in a row vector. +## column and return them in a row vector. If the optional @var{dim} +## argument is given, operate along this dimension. ## @seealso{std, mean} ## @end deftypefn diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/ppplot.m --- a/scripts/statistics/base/ppplot.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/ppplot.m Mon Jun 25 17:31:47 2007 +0000 @@ -37,6 +37,10 @@ ## ppplot (x, "uniform", 2, 4) ## @end example ## +## @noindent +## @var{dist} can be any string for which a function @var{dist_cdf} +## that calculates the CDF of distribution @var{dist} exists. +## ## If no output arguments are given, the data are plotted directly. ## @end deftypefn diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/qqplot.m --- a/scripts/statistics/base/qqplot.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/qqplot.m Mon Jun 25 17:31:47 2007 +0000 @@ -39,6 +39,10 @@ ## qqplot (x, "uniform", 2, 4) ## @end example ## +## @noindent +## @var{dist} can be any string for which a function @var{dist_inv} +## that calculates the inverse CDF of distribution @var{dist} exists. +## ## If no output arguments are given, the data are plotted directly. ## @end deftypefn diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/skewness.m --- a/scripts/statistics/base/skewness.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/skewness.m Mon Jun 25 17:31:47 2007 +0000 @@ -25,6 +25,7 @@ ## $$ ## {\rm skewness} (x) = {1\over N \sigma(x)^3} \sum_{i=1}^N (x_i-\bar{x})^3 ## $$ +## where $\bar{x}$ is the mean value of $x$. ## @end tex ## @end iftex ## @ifinfo diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/std.m --- a/scripts/statistics/base/std.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/std.m Mon Jun 25 17:31:47 2007 +0000 @@ -26,18 +26,19 @@ ## @iftex ## @tex ## $$ -## {\rm std} (x) = \sigma (x) = \sqrt{{\sum_{i=1}^N (x_i - \bar{x}) \over N - 1}} +## {\rm std} (x) = \sigma (x) = \sqrt{{\sum_{i=1}^N (x_i - \bar{x})^2 \over N - 1}} ## $$ +## where $\bar{x}$ is the mean value of $x$. ## @end tex ## @end iftex -## @ifinfo +## @ifnottex ## ## @example ## @group ## std (x) = sqrt (sumsq (x - mean (x)) / (n - 1)) ## @end group ## @end example -## @end ifinfo +## @end ifnottex ## If @var{x} is a matrix, compute the standard deviation for ## each column and return them in a row vector. ## @@ -46,10 +47,10 @@ ## ## @table @asis ## @item 0: -## normalizes with N-1, provides the square root of best unbiased estimator of +## normalizes with @math{N-1}, provides the square root of best unbiased estimator of ## the variance [default] ## @item 1: -## normalizes with N, this provides the square root of the second moment around +## normalizes with @math{N}, this provides the square root of the second moment around ## the mean ## @end table ## diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/values.m --- a/scripts/statistics/base/values.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/values.m Mon Jun 25 17:31:47 2007 +0000 @@ -21,6 +21,9 @@ ## @deftypefn {Function File} {} values (@var{x}) ## Return the different values in a column vector, arranged in ascending ## order. +## +## As an example, @code{values([1, 2, 3, 1])} returns the vector +## @code{[1, 2, 3]}. ## @end deftypefn ## Author: KH diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/base/var.m --- a/scripts/statistics/base/var.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/base/var.m Mon Jun 25 17:31:47 2007 +0000 @@ -28,10 +28,10 @@ ## ## @table @asis ## @item 0: -## Normalizes with N-1, provides the best unbiased estimator of the +## Normalizes with @math{N-1}, provides the best unbiased estimator of the ## variance [default]. ## @item 1: -## Normalizes with N, this provides the second moment around the mean. +## Normalizes with @math{N}, this provides the second moment around the mean. ## @end table ## ## The third argument @var{dim} determines the dimension along which the diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/distributions/discrete_pdf.m --- a/scripts/statistics/distributions/discrete_pdf.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/distributions/discrete_pdf.m Mon Jun 25 17:31:47 2007 +0000 @@ -20,7 +20,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} discrete_pdf (@var{x}, @var{v}, @var{p}) ## For each element of @var{x}, compute the probability density function -## (pDF) at @var{x} of a univariate discrete distribution which assumes +## (PDF) at @var{x} of a univariate discrete distribution which assumes ## the values in @var{v} with probabilities @var{p}. ## @end deftypefn diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/distributions/kolmogorov_smirnov_cdf.m --- a/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m Mon Jun 25 17:31:47 2007 +0000 @@ -22,7 +22,7 @@ ## Return the CDF at @var{x} of the Kolmogorov-Smirnov distribution, ## @iftex ## @tex -## $$ Q(x) = sum_{k=-\infty}^\infty (-1)^k exp(-2 k^2 x^2) $$ +## $$ Q(x) = \sum_{k=-\infty}^\infty (-1)^k \exp(-2 k^2 x^2) $$ ## @end tex ## @end iftex ## @ifinfo diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/distributions/unidinv.m --- a/scripts/statistics/distributions/unidinv.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/distributions/unidinv.m Mon Jun 25 17:31:47 2007 +0000 @@ -20,7 +20,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} unidinv (@var{x}, @var{v}) ## For each component of @var{x}, compute the quantile (the inverse of -## the CDF) at @var{x} of the univariate distribution which assumes the +## the CDF) at @var{x} of the univariate discrete distribution which assumes the ## values in @var{v} with equal probability ## @end deftypefn diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/distributions/unidpdf.m --- a/scripts/statistics/distributions/unidpdf.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/distributions/unidpdf.m Mon Jun 25 17:31:47 2007 +0000 @@ -20,7 +20,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} unidpdf (@var{x}, @var{v}) ## For each element of @var{x}, compute the probability density function -## (pDF) at @var{x} of a univariate discrete distribution which assumes +## (PDF) at @var{x} of a univariate discrete distribution which assumes ## the values in @var{v} with equal probability. ## @end deftypefn diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/distributions/wblcdf.m --- a/scripts/statistics/distributions/wblcdf.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/distributions/wblcdf.m Mon Jun 25 17:31:47 2007 +0000 @@ -23,12 +23,18 @@ ## Weibull distribution with shape parameter @var{scale} and scale ## parameter @var{shape}, which is ## +## @iftex +## @tex +## $$ 1 - \exp(-(x/shape)^{scale}) $$ +## for $x\geq 0$. +## @end tex +## @end iftex +## @ifnottex ## @example ## 1 - exp(-(x/shape)^scale) ## @end example -## -## @noindent ## for @var{x} >= 0. +## @end ifnottex ## @end deftypefn ## Author: KH diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/distributions/wblpdf.m --- a/scripts/statistics/distributions/wblpdf.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/distributions/wblpdf.m Mon Jun 25 17:31:47 2007 +0000 @@ -23,9 +23,16 @@ ## Weibull distribution with shape parameter @var{scale} and scale ## parameter @var{shape} which is given by ## +## @iftex +## @tex +## $$ scale \cdot shape^{-scale} x^{scale-1} \exp(-(x/shape)^{scale}) $$ +## @end tex +## @end iftex +## @ifnottex ## @example ## scale * shape^(-scale) * x^(scale-1) * exp(-(x/shape)^scale) ## @end example +## @end ifnottex ## ## @noindent ## for @var{x} > 0. diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/models/logistic_regression.m --- a/scripts/statistics/models/logistic_regression.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/models/logistic_regression.m Mon Jun 25 17:31:47 2007 +0000 @@ -18,7 +18,7 @@ ## 02110-1301, USA. ## -*- texinfo -*- -## @deftypefn {Functio File} {[@var{theta}, @var{beta}, @var{dev}, @var{dl}, @var{d2l}, @var{p}] =} logistic_regression (@var{y}, @var{x}, @var{print}, @var{theta}, @var{beta}) +## @deftypefn {Function File} {[@var{theta}, @var{beta}, @var{dev}, @var{dl}, @var{d2l}, @var{p}] =} logistic_regression (@var{y}, @var{x}, @var{print}, @var{theta}, @var{beta}) ## Perform ordinal logistic regression. ## ## Suppose @var{y} takes values in @var{k} ordered categories, and let @@ -56,7 +56,7 @@ ## in which all output arguments and all input arguments except @var{y} ## are optional. ## -## Stting @var{print} to 1 requests summary information about the fitted +## Setting @var{print} to 1 requests summary information about the fitted ## model to be displayed. Setting @var{print} to 2 requests information ## about convergence at each iteration. Other values request no ## information to be displayed. The input arguments @var{theta} and diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/tests/hotelling_test.m --- a/scripts/statistics/tests/hotelling_test.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/tests/hotelling_test.m Mon Jun 25 17:31:47 2007 +0000 @@ -23,7 +23,7 @@ ## mean and covariance matrix, test the null hypothesis that @code{mean ## (@var{x}) == @var{m}}. ## -## Hotelling's T^2 is returned in @var{tsq}. Under the null, +## Hotelling's @math{T^2} is returned in @var{tsq}. Under the null, ## @math{(n-p) T^2 / (p(n-1))} has an F distribution with @math{p} and ## @math{n-p} degrees of freedom, where @math{n} and @math{p} are the ## numbers of samples and variables, respectively. diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/tests/hotelling_test_2.m --- a/scripts/statistics/tests/hotelling_test_2.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/tests/hotelling_test_2.m Mon Jun 25 17:31:47 2007 +0000 @@ -24,11 +24,20 @@ ## equal covariance matrices, test the null hypothesis @code{mean ## (@var{x}) == mean (@var{y})}. ## -## Hotelling's two-sample T^2 is returned in @var{tsq}. Under the null, +## Hotelling's two-sample @math{T^2} is returned in @var{tsq}. Under the null, ## +## @iftex +## @tex +## $$ +## {n_x+n_y-p-1) T^2 \over p(n_x+n_y-2)} +## $$ +## @end tex +## @end iftex +## @ifnottex ## @example ## (n_x+n_y-p-1) T^2 / (p(n_x+n_y-2)) ## @end example +## @end ifnottex ## ## @noindent ## has an F distribution with @math{p} and @math{n_x+n_y-p-1} degrees of @@ -77,4 +86,4 @@ printf (" pval: %g\n", pval); endif -endfunction \ No newline at end of file +endfunction diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/tests/kolmogorov_smirnov_test.m --- a/scripts/statistics/tests/kolmogorov_smirnov_test.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/tests/kolmogorov_smirnov_test.m Mon Jun 25 17:31:47 2007 +0000 @@ -32,6 +32,10 @@ ## kolmogorov_smirnov_test(x, "uniform", 2, 4) ## @end example ## +## @noindent +## @var{dist} can be any string for which a function @var{dist_cdf} +## that calculates the CDF of distribution @var{dist} exists. +## ## With the optional argument string @var{alt}, the alternative of ## interest can be selected. If @var{alt} is @code{"!="} or ## @code{"<>"}, the null is tested against the two-sided alternative F diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/tests/var_test.m --- a/scripts/statistics/tests/var_test.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/tests/var_test.m Mon Jun 25 17:31:47 2007 +0000 @@ -21,8 +21,9 @@ ## @deftypefn {Function File} {[@var{pval}, @var{f}, @var{df_num}, @var{df_den}] =} var_test (@var{x}, @var{y}, @var{alt}) ## For two samples @var{x} and @var{y} from normal distributions with ## unknown means and unknown variances, perform an F-test of the null -## hypothesis of equal variances. Under the null, the test statistic f -## follows an F-distribution with df_num and df_den degrees of freedom. +## hypothesis of equal variances. Under the null, the test statistic +## @var{f} follows an F-distribution with @var{df_num} and @var{df_den} +## degrees of freedom. ## ## With the optional argument string @var{alt}, the alternative of ## interest can be selected. If @var{alt} is @code{"!="} or diff -r a5c64dad5b93 -r 451b346d8c2f scripts/statistics/tests/welch_test.m --- a/scripts/statistics/tests/welch_test.m Mon Jun 25 17:05:58 2007 +0000 +++ b/scripts/statistics/tests/welch_test.m Mon Jun 25 17:31:47 2007 +0000 @@ -22,8 +22,8 @@ ## For two samples @var{x} and @var{y} from normal distributions with ## unknown means and unknown and not necessarily equal variances, ## perform a Welch test of the null hypothesis of equal means. -## Under the null, the test statistic t approximately follows a Student -## distribution with df degrees of freedom. +## Under the null, the test statistic @var{t} approximately follows a +## Student distribution with @var{df} degrees of freedom. ## ## With the optional argument string @var{alt}, the alternative of ## interest can be selected. If @var{alt} is @code{"!="} or