7018
|
1 @c Copyright (C) 1996, 1997, 1999, 2000, 2002, 2004, 2005, 2006, |
|
2 @c 2007 John W. Eaton |
|
3 @c |
|
4 @c This file is part of Octave. |
|
5 @c |
|
6 @c Octave is free software; you can redistribute it and/or modify it |
|
7 @c under the terms of the GNU General Public License as published by the |
|
8 @c Free Software Foundation; either version 3 of the License, or (at |
|
9 @c your option) any later version. |
|
10 @c |
|
11 @c Octave is distributed in the hope that it will be useful, but WITHOUT |
|
12 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 @c for more details. |
|
15 @c |
|
16 @c You should have received a copy of the GNU General Public License |
|
17 @c along with Octave; see the file COPYING. If not, see |
|
18 @c <http://www.gnu.org/licenses/>. |
3294
|
19 |
4167
|
20 @node Statistics |
3294
|
21 @chapter Statistics |
|
22 |
6754
|
23 Octave has support for various statistical methods. This includes |
|
24 basic descriptive statistics, statistical tests, random number generation, |
|
25 and much more. |
|
26 |
|
27 The functions that analyze data all assume that multidimensional data |
|
28 is arranged in a matrix where each row is an observation, and each |
|
29 column is a variable. So, the matrix defined by |
|
30 |
|
31 @example |
|
32 a = [ 0.9, 0.7; |
|
33 0.1, 0.1; |
|
34 0.5, 0.4 ]; |
|
35 @end example |
|
36 |
|
37 @noindent |
|
38 contains three observations from a two-dimensional distribution. |
|
39 While this is the default data arrangement, most functions support |
|
40 different arrangements. |
|
41 |
6939
|
42 It should be noted that the statistics functions don't handle data |
|
43 containing NaN, NA, or Inf. Such values need to be handled explicitly. |
6754
|
44 |
3453
|
45 @menu |
6754
|
46 * Descriptive Statistics:: |
|
47 * Basic Statistical Functions:: |
|
48 * Statistical Plots:: |
3454
|
49 * Tests:: |
3453
|
50 * Models:: |
6754
|
51 * Distributions:: |
|
52 * Random Number Generation:: |
3453
|
53 @end menu |
|
54 |
6754
|
55 @node Descriptive Statistics |
|
56 @section Descriptive Statistics |
|
57 |
|
58 Octave can compute various statistics such as the moments of a data set. |
3453
|
59 |
3367
|
60 @DOCSTRING(mean) |
3294
|
61 |
3367
|
62 @DOCSTRING(median) |
3294
|
63 |
6754
|
64 @DOCSTRING(meansq) |
|
65 |
3367
|
66 @DOCSTRING(std) |
3294
|
67 |
6754
|
68 @DOCSTRING(var) |
|
69 |
6863
|
70 @DOCSTRING(mode) |
|
71 |
3367
|
72 @DOCSTRING(cov) |
3294
|
73 |
6754
|
74 @DOCSTRING(cor) |
|
75 |
3367
|
76 @DOCSTRING(corrcoef) |
3294
|
77 |
3367
|
78 @DOCSTRING(kurtosis) |
3294
|
79 |
6754
|
80 @DOCSTRING(skewness) |
|
81 |
|
82 @DOCSTRING(statistics) |
|
83 |
|
84 @DOCSTRING(moment) |
|
85 |
|
86 @node Basic Statistical Functions |
|
87 @section Basic Statistical Functions |
|
88 |
|
89 Octave also supports various helpful statistical functions. |
|
90 |
3367
|
91 @DOCSTRING(mahalanobis) |
3294
|
92 |
6754
|
93 @DOCSTRING(center) |
3453
|
94 |
6754
|
95 @DOCSTRING(studentize) |
3453
|
96 |
6550
|
97 @DOCSTRING(nchoosek) |
|
98 |
|
99 @DOCSTRING(perms) |
|
100 |
3453
|
101 @DOCSTRING(values) |
|
102 |
|
103 @DOCSTRING(table) |
|
104 |
|
105 @DOCSTRING(spearman) |
|
106 |
|
107 @DOCSTRING(run_count) |
|
108 |
|
109 @DOCSTRING(ranks) |
|
110 |
|
111 @DOCSTRING(range) |
|
112 |
|
113 @DOCSTRING(probit) |
|
114 |
6754
|
115 @DOCSTRING(logit) |
3453
|
116 |
6754
|
117 @DOCSTRING(cloglog) |
3453
|
118 |
|
119 @DOCSTRING(kendall) |
|
120 |
|
121 @DOCSTRING(iqr) |
|
122 |
|
123 @DOCSTRING(cut) |
|
124 |
6754
|
125 @node Statistical Plots |
|
126 @section Statistical Plots |
|
127 |
|
128 @c Should hist be moved to here, or perhaps the qqplot and ppplot |
|
129 @c functions should be moved to the Plotting Chapter? |
3453
|
130 |
6754
|
131 Octave can create Quantile Plots (QQ-Plots), and Probability Plots |
|
132 (PP-Plots). These are simple graphical tests for determining if a |
|
133 data set comes from a certain distribution. |
3453
|
134 |
6754
|
135 It is worth noticing that Octave can also show histograms of data |
|
136 using the @code{hist} function as described in |
6888
|
137 @ref{Two-Dimensional Plots}. |
6754
|
138 |
|
139 @DOCSTRING(qqplot) |
|
140 |
|
141 @DOCSTRING(ppplot) |
3453
|
142 |
4167
|
143 @node Tests |
3453
|
144 @section Tests |
|
145 |
6754
|
146 Octave can perform several different statistical tests. The following |
|
147 table summarizes the available tests. |
|
148 |
|
149 @multitable @columnfractions .4 .5 |
|
150 @item @strong{Hypothesis} |
|
151 @tab @strong{Test Functions} |
|
152 @item Equal mean values |
|
153 @tab @code{anova}, @code{hotelling_test2}, @code{t_test_2}, |
|
154 @code{welch_test}, @code{wilcoxon_test}, @code{z_test_2} |
|
155 @item Equal medians |
|
156 @tab @code{kruskal_wallis_test}, @code{sign_test} |
|
157 @item Equal variances |
|
158 @tab @code{bartlett_test}, @code{manova}, @code{var_test} |
|
159 @item Equal distributions |
|
160 @tab @code{chisquare_test_homogeneity}, @code{kolmogorov_smirnov_test_2}, |
|
161 @code{u_test} |
|
162 @item Equal marginal frequencies |
|
163 @tab @code{mcnemar_test} |
|
164 @item Equal success probabilities |
|
165 @tab @code{prop_test_2} |
|
166 @item Independent observations |
|
167 @tab @code{chisquare_test_independence}, @code{run_test} |
|
168 @item Uncorrelated observations |
|
169 @tab @code{cor_test} |
|
170 @item Given mean value |
|
171 @tab @code{hotelling_test}, @code{t_test}, @code{z_test} |
|
172 @item Observations from given distribution |
|
173 @tab @code{kolmogorov_smirnov_test} |
|
174 @item Regression |
|
175 @tab @code{f_test_regression}, @code{t_test_regression} |
|
176 @end multitable |
|
177 |
|
178 The tests return a p-value that describes the outcome of the test. |
|
179 Assuming that the test hypothesis is true, the p-value is the probability |
6939
|
180 of obtaining a worse result than the observed one. So large p-values |
6754
|
181 corresponds to a successful test. Usually a test hypothesis is accepted |
|
182 if the p-value exceeds @math{0.05}. |
|
183 |
3454
|
184 @DOCSTRING(anova) |
|
185 |
|
186 @DOCSTRING(bartlett_test) |
|
187 |
|
188 @DOCSTRING(chisquare_test_homogeneity) |
|
189 |
|
190 @DOCSTRING(chisquare_test_independence) |
|
191 |
|
192 @DOCSTRING(cor_test) |
|
193 |
|
194 @DOCSTRING(f_test_regression) |
|
195 |
|
196 @DOCSTRING(hotelling_test) |
|
197 |
|
198 @DOCSTRING(hotelling_test_2) |
|
199 |
|
200 @DOCSTRING(kolmogorov_smirnov_test) |
|
201 |
|
202 @DOCSTRING(kolmogorov_smirnov_test_2) |
|
203 |
|
204 @DOCSTRING(kruskal_wallis_test) |
|
205 |
|
206 @DOCSTRING(manova) |
|
207 |
|
208 @DOCSTRING(mcnemar_test) |
|
209 |
|
210 @DOCSTRING(prop_test_2) |
|
211 |
|
212 @DOCSTRING(run_test) |
|
213 |
|
214 @DOCSTRING(sign_test) |
|
215 |
|
216 @DOCSTRING(t_test) |
|
217 |
|
218 @DOCSTRING(t_test_2) |
|
219 |
|
220 @DOCSTRING(t_test_regression) |
|
221 |
|
222 @DOCSTRING(u_test) |
|
223 |
|
224 @DOCSTRING(var_test) |
|
225 |
|
226 @DOCSTRING(welch_test) |
|
227 |
|
228 @DOCSTRING(wilcoxon_test) |
|
229 |
|
230 @DOCSTRING(z_test) |
|
231 |
|
232 @DOCSTRING(z_test_2) |
|
233 |
4167
|
234 @node Models |
3453
|
235 @section Models |
|
236 |
3454
|
237 @DOCSTRING(logistic_regression) |
|
238 |
4167
|
239 @node Distributions |
3453
|
240 @section Distributions |
3456
|
241 |
6754
|
242 Octave has functions for computing the Probability Density Function |
|
243 (PDF), the Cumulative Distribution function (CDF), and the quantile |
|
244 (the inverse of the CDF) of a large number of distributions. |
|
245 |
|
246 The following table summarizes the supported distributions (in |
|
247 alphabetical order). |
|
248 |
|
249 @multitable @columnfractions .4 .2 .2 .2 |
|
250 @item @strong{Distribution} |
|
251 @tab @strong{PDF} |
|
252 @tab @strong{CDF} |
|
253 @tab @strong{Quantile} |
|
254 @item Beta Distribution |
|
255 @tab @code{betapdf} |
|
256 @tab @code{betacdf} |
|
257 @tab @code{betainv} |
|
258 @item Binomial Distribution |
|
259 @tab @code{binopdf} |
|
260 @tab @code{binocdf} |
|
261 @tab @code{binoinv} |
|
262 @item Cauchy Distribution |
|
263 @tab @code{cauchy_pdf} |
|
264 @tab @code{cauchy_cdf} |
|
265 @tab @code{cauchy_inv} |
|
266 @item Chi-Square Distribution |
|
267 @tab @code{chi2pdf} |
|
268 @tab @code{chi2cdf} |
|
269 @tab @code{chi2inv} |
|
270 @item Univariate Discrete Distribution |
|
271 @tab @code{discrete_pdf} |
|
272 @tab @code{discrete_cdf} |
|
273 @tab @code{discrete_inv} |
|
274 @item Empirical Distribution |
|
275 @tab @code{empirical_pdf} |
|
276 @tab @code{empirical_cdf} |
|
277 @tab @code{empirical_inv} |
|
278 @item Exponential Distribution |
|
279 @tab @code{exppdf} |
|
280 @tab @code{expcdf} |
|
281 @tab @code{expinv} |
|
282 @item F Distribution |
|
283 @tab @code{fpdf} |
|
284 @tab @code{fcdf} |
|
285 @tab @code{finv} |
|
286 @item Gamma Distribution |
|
287 @tab @code{gampdf} |
|
288 @tab @code{gamcdf} |
|
289 @tab @code{gaminv} |
|
290 @item Geometric Distribution |
|
291 @tab @code{geopdf} |
|
292 @tab @code{geocdf} |
|
293 @tab @code{geoinv} |
|
294 @item Hypergeometric Distribution |
|
295 @tab @code{hygepdf} |
|
296 @tab @code{hygecdf} |
|
297 @tab @code{hygeinv} |
|
298 @item Kolmogorov Smirnov Distribution |
|
299 @tab @emph{Not Available} |
|
300 @tab @code{kolmogorov_smirnov_cdf} |
|
301 @tab @emph{Not Available} |
|
302 @item Laplace Distribution |
|
303 @tab @code{laplace_pdf} |
|
304 @tab @code{laplace_cdf} |
|
305 @tab @code{laplace_inv} |
|
306 @item Logistic Distribution |
|
307 @tab @code{logistic_pdf} |
|
308 @tab @code{logistic_cdf} |
|
309 @tab @code{logistic_inv} |
|
310 @item Log-Normal Distribution |
|
311 @tab @code{lognpdf} |
|
312 @tab @code{logncdf} |
|
313 @tab @code{logninv} |
|
314 @item Pascal Distribution |
|
315 @tab @code{nbinpdf} |
|
316 @tab @code{nbincdf} |
|
317 @tab @code{nbininv} |
|
318 @item Univariate Normal Distribution |
|
319 @tab @code{normpdf} |
|
320 @tab @code{normcdf} |
|
321 @tab @code{norminv} |
|
322 @item Poisson Distribution |
|
323 @tab @code{poisspdf} |
|
324 @tab @code{poisscdf} |
|
325 @tab @code{poissinv} |
|
326 @item t (Student) Distribution |
|
327 @tab @code{tpdf} |
|
328 @tab @code{tcdf} |
|
329 @tab @code{tinv} |
|
330 @item Univariate Discrete Distribution |
|
331 @tab @code{unidpdf} |
|
332 @tab @code{unidcdf} |
|
333 @tab @code{unidinv} |
|
334 @item Uniform Distribution |
|
335 @tab @code{unifpdf} |
|
336 @tab @code{unifcdf} |
|
337 @tab @code{unifinv} |
|
338 @item Weibull Distribution |
|
339 @tab @code{wblpdf} |
|
340 @tab @code{wblcdf} |
|
341 @tab @code{wblinv} |
|
342 @end multitable |
|
343 |
5412
|
344 @DOCSTRING(betacdf) |
3456
|
345 |
5412
|
346 @DOCSTRING(betainv) |
3456
|
347 |
5412
|
348 @DOCSTRING(betapdf) |
3456
|
349 |
5412
|
350 @DOCSTRING(binocdf) |
3456
|
351 |
5412
|
352 @DOCSTRING(binoinv) |
3456
|
353 |
5412
|
354 @DOCSTRING(binopdf) |
3456
|
355 |
|
356 @DOCSTRING(cauchy_cdf) |
|
357 |
|
358 @DOCSTRING(cauchy_inv) |
|
359 |
|
360 @DOCSTRING(cauchy_pdf) |
|
361 |
5412
|
362 @DOCSTRING(chi2cdf) |
3456
|
363 |
5412
|
364 @DOCSTRING(chi2inv) |
3456
|
365 |
5412
|
366 @DOCSTRING(chi2pdf) |
3456
|
367 |
|
368 @DOCSTRING(discrete_cdf) |
|
369 |
|
370 @DOCSTRING(discrete_inv) |
|
371 |
|
372 @DOCSTRING(discrete_pdf) |
|
373 |
|
374 @DOCSTRING(empirical_cdf) |
|
375 |
|
376 @DOCSTRING(empirical_inv) |
|
377 |
|
378 @DOCSTRING(empirical_pdf) |
|
379 |
5412
|
380 @DOCSTRING(expcdf) |
3456
|
381 |
5412
|
382 @DOCSTRING(expinv) |
3456
|
383 |
5412
|
384 @DOCSTRING(exppdf) |
3456
|
385 |
5412
|
386 @DOCSTRING(fcdf) |
3456
|
387 |
5412
|
388 @DOCSTRING(finv) |
3456
|
389 |
5412
|
390 @DOCSTRING(fpdf) |
3456
|
391 |
5412
|
392 @DOCSTRING(gamcdf) |
3456
|
393 |
5412
|
394 @DOCSTRING(gaminv) |
3456
|
395 |
5412
|
396 @DOCSTRING(gampdf) |
3456
|
397 |
5412
|
398 @DOCSTRING(geocdf) |
3456
|
399 |
5412
|
400 @DOCSTRING(geoinv) |
3456
|
401 |
5412
|
402 @DOCSTRING(geopdf) |
3456
|
403 |
5412
|
404 @DOCSTRING(hygecdf) |
3456
|
405 |
5412
|
406 @DOCSTRING(hygeinv) |
3456
|
407 |
5412
|
408 @DOCSTRING(hygepdf) |
3456
|
409 |
|
410 @DOCSTRING(kolmogorov_smirnov_cdf) |
|
411 |
|
412 @DOCSTRING(laplace_cdf) |
|
413 |
|
414 @DOCSTRING(laplace_inv) |
|
415 |
|
416 @DOCSTRING(laplace_pdf) |
|
417 |
|
418 @DOCSTRING(logistic_cdf) |
|
419 |
|
420 @DOCSTRING(logistic_inv) |
|
421 |
|
422 @DOCSTRING(logistic_pdf) |
|
423 |
5412
|
424 @DOCSTRING(logncdf) |
3456
|
425 |
5412
|
426 @DOCSTRING(logninv) |
3456
|
427 |
5412
|
428 @DOCSTRING(lognpdf) |
3456
|
429 |
6502
|
430 @DOCSTRING(nbincdf) |
|
431 |
|
432 @DOCSTRING(nbininv) |
|
433 |
|
434 @DOCSTRING(nbinpdf) |
|
435 |
5412
|
436 @DOCSTRING(normcdf) |
3456
|
437 |
5412
|
438 @DOCSTRING(norminv) |
3456
|
439 |
5412
|
440 @DOCSTRING(normpdf) |
3456
|
441 |
5412
|
442 @DOCSTRING(poisscdf) |
3456
|
443 |
5412
|
444 @DOCSTRING(poissinv) |
3456
|
445 |
5412
|
446 @DOCSTRING(poisspdf) |
3456
|
447 |
5412
|
448 @DOCSTRING(tcdf) |
3456
|
449 |
5412
|
450 @DOCSTRING(tinv) |
3456
|
451 |
5412
|
452 @DOCSTRING(tpdf) |
3456
|
453 |
6502
|
454 @DOCSTRING(unidcdf) |
|
455 |
|
456 @DOCSTRING(unidinv) |
|
457 |
|
458 @DOCSTRING(unidpdf) |
|
459 |
5412
|
460 @DOCSTRING(unifcdf) |
3456
|
461 |
5412
|
462 @DOCSTRING(unifinv) |
3456
|
463 |
5412
|
464 @DOCSTRING(unifpdf) |
3456
|
465 |
6502
|
466 @DOCSTRING(wblcdf) |
3456
|
467 |
6502
|
468 @DOCSTRING(wblinv) |
3456
|
469 |
6502
|
470 @DOCSTRING(wblpdf) |
3456
|
471 |
6754
|
472 @node Random Number Generation |
|
473 @section Random Number Generation |
|
474 |
|
475 Octave can generate random numbers from a large number of distributions. |
|
476 The random number generators are based on the random number generators |
|
477 described in @ref{Special Utility Matrices}. |
|
478 @c Should rand, randn, rande, randp, and randg be moved to here? |
|
479 |
|
480 The following table summarizes the available random number generators |
|
481 (in alphabetical order). |
|
482 |
|
483 @multitable @columnfractions .4 .3 |
|
484 @item @strong{Distribution} @tab @strong{Function} |
|
485 @item Beta Distribution @tab @code{betarnd} |
|
486 @item Binomial Distribution @tab @code{binornd} |
|
487 @item Cauchy Distribution @tab @code{cauchy_rnd} |
|
488 @item Chi-Square Distribution @tab @code{chi2rnd} |
|
489 @item Univariate Discrete Distribution @tab @code{discrete_rnd} |
|
490 @item Empirical Distribution @tab @code{empirical_rnd} |
|
491 @item Exponential Distribution @tab @code{exprnd} |
|
492 @item F Distribution @tab @code{frnd} |
|
493 @item Gamma Distribution @tab @code{gamrnd} |
|
494 @item Geometric Distribution @tab @code{geornd} |
|
495 @item Hypergeometric Distribution @tab @code{hygernd} |
|
496 @item Laplace Distribution @tab @code{laplace_rnd} |
|
497 @item Logistic Distribution @tab @code{logistic_rnd} |
|
498 @item Log-Normal Distribution @tab @code{lognrnd} |
|
499 @item Pascal Distribution @tab @code{nbinrnd} |
|
500 @item Univariate Normal Distribution @tab @code{normrnd} |
|
501 @item Poisson Distribution @tab @code{poissrnd} |
|
502 @item t (Student) Distribution @tab @code{trnd} |
|
503 @item Univariate Discrete Distribution @tab @code{unidrnd} |
|
504 @item Uniform Distribution @tab @code{unifrnd} |
|
505 @item Weibull Distribution @tab @code{wblrnd} |
|
506 @item Wiener Process @tab @code{wienrnd} |
|
507 @end multitable |
|
508 |
|
509 @DOCSTRING(betarnd) |
|
510 |
|
511 @DOCSTRING(binornd) |
|
512 |
|
513 @DOCSTRING(cauchy_rnd) |
|
514 |
|
515 @DOCSTRING(chi2rnd) |
|
516 |
|
517 @DOCSTRING(discrete_rnd) |
|
518 |
|
519 @DOCSTRING(empirical_rnd) |
|
520 |
|
521 @DOCSTRING(exprnd) |
|
522 |
|
523 @DOCSTRING(frnd) |
|
524 |
|
525 @DOCSTRING(gamrnd) |
|
526 |
|
527 @DOCSTRING(geornd) |
|
528 |
|
529 @DOCSTRING(hygernd) |
|
530 |
|
531 @DOCSTRING(laplace_rnd) |
|
532 |
|
533 @DOCSTRING(logistic_rnd) |
|
534 |
|
535 @DOCSTRING(lognrnd) |
|
536 |
|
537 @DOCSTRING(nbinrnd) |
|
538 |
|
539 @DOCSTRING(normrnd) |
|
540 |
|
541 @DOCSTRING(poissrnd) |
|
542 |
|
543 @DOCSTRING(trnd) |
|
544 |
|
545 @DOCSTRING(unidrnd) |
|
546 |
|
547 @DOCSTRING(unifrnd) |
|
548 |
6502
|
549 @DOCSTRING(wblrnd) |
3456
|
550 |
5412
|
551 @DOCSTRING(wienrnd) |
6754
|
552 |