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