3294
|
1 @c Copyright (C) 1996, 1997 John W. Eaton |
|
2 @c This is part of the Octave manual. |
|
3 @c For copying conditions, see the file gpl.texi. |
|
4 |
|
5 @node Statistics, Sets, Optimization, Top |
|
6 @chapter Statistics |
|
7 |
|
8 I hope that someday Octave will include more statistics functions. If |
|
9 you would like to help improve Octave in this area, please contact |
|
10 @email{bug-octave@@bevo.che.wisc.edu}. |
|
11 |
|
12 @deftypefn {Function File} {} mean (@var{x}) |
|
13 If @var{x} is a vector, compute the mean of the elements of @var{x} |
|
14 @iftex |
|
15 @tex |
|
16 $$ {\rm mean}(x) = \bar{x} = {1\over N} \sum_{i=1}^N x_i $$ |
|
17 @end tex |
|
18 @end iftex |
|
19 @ifinfo |
|
20 |
|
21 @example |
|
22 mean (x) = SUM_i x(i) / N |
|
23 @end example |
|
24 @end ifinfo |
|
25 If @var{x} is a matrix, compute the mean for each column and return them |
|
26 in a row vector. |
|
27 @end deftypefn |
|
28 |
|
29 @deftypefn {Function File} {} median (@var{x}) |
|
30 If @var{x} is a vector, compute the median value of the elements of |
|
31 @var{x}. |
|
32 @iftex |
|
33 @tex |
|
34 $$ |
|
35 {\rm median} (x) = |
|
36 \cases{x(\lceil N/2\rceil), & $N$ odd;\cr |
|
37 (x(N/2)+x(N/2+1))/2, & $N$ even.} |
|
38 $$ |
|
39 @end tex |
|
40 @end iftex |
|
41 @ifinfo |
|
42 |
|
43 @example |
|
44 @group |
|
45 x(ceil(N/2)), N odd |
|
46 median(x) = |
|
47 (x(N/2) + x((N/2)+1))/2, N even |
|
48 @end group |
|
49 @end example |
|
50 @end ifinfo |
|
51 If @var{x} is a matrix, compute the median value for each |
|
52 column and return them in a row vector. |
|
53 @end deftypefn |
|
54 |
|
55 @deftypefn {Function File} {} std (@var{x}) |
|
56 If @var{x} is a vector, compute the standard deviation of the elements |
|
57 of @var{x}. |
|
58 @iftex |
|
59 @tex |
|
60 $$ |
|
61 {\rm std} (x) = \sigma (x) = \sqrt{{\sum_{i=1}^N (x_i - \bar{x}) \over N - 1}} |
|
62 $$ |
|
63 @end tex |
|
64 @end iftex |
|
65 @ifinfo |
|
66 |
|
67 @example |
|
68 @group |
|
69 std (x) = sqrt (sumsq (x - mean (x)) / (n - 1)) |
|
70 @end group |
|
71 @end example |
|
72 @end ifinfo |
|
73 If @var{x} is a matrix, compute the standard deviation for |
|
74 each column and return them in a row vector. |
|
75 @end deftypefn |
|
76 |
|
77 @deftypefn {Function File} {} cov (@var{x}, @var{y}) |
|
78 If each row of @var{x} and @var{y} is an observation and each column is |
|
79 a variable, the (@var{i},@var{j})-th entry of |
|
80 @code{cov (@var{x}, @var{y})} is the covariance between the @var{i}-th |
|
81 variable in @var{x} and the @var{j}-th variable in @var{y}. If called |
|
82 with one argument, compute @code{cov (@var{x}, @var{x})}. |
|
83 @end deftypefn |
|
84 |
|
85 @deftypefn {Function File} {} corrcoef (@var{x}, @var{y}) |
|
86 If each row of @var{x} and @var{y} is an observation and each column is |
|
87 a variable, the (@var{i},@var{j})-th entry of |
|
88 @code{corrcoef (@var{x}, @var{y})} is the correlation between the |
|
89 @var{i}-th variable in @var{x} and the @var{j}-th variable in @var{y}. |
|
90 If called with one argument, compute @code{corrcoef (@var{x}, @var{x})}. |
|
91 @end deftypefn |
|
92 |
|
93 @deftypefn {Function File} {} kurtosis (@var{x}) |
|
94 If @var{x} is a vector of length @var{N}, return the kurtosis |
|
95 @iftex |
|
96 @tex |
|
97 $$ |
|
98 {\rm kurtosis} (x) = {1\over N \sigma(x)^4} \sum_{i=1}^N (x_i-\bar{x})^4 - 3 |
|
99 $$ |
|
100 @end tex |
|
101 @end iftex |
|
102 @ifinfo |
|
103 |
|
104 @example |
|
105 kurtosis (x) = N^(-1) std(x)^(-4) sum ((x - mean(x)).^4) - 3 |
|
106 @end example |
|
107 @end ifinfo |
|
108 |
|
109 @noindent |
|
110 of @var{x}. If @var{x} is a matrix, return the row vector containing |
|
111 the kurtosis of each column. |
|
112 @end deftypefn |
|
113 |
|
114 @deftypefn {Function File} {} mahalanobis (@var{x}, @var{y}) |
|
115 Return the Mahalanobis' D-square distance between the multivariate |
|
116 samples @var{x} and @var{y}, which must have the same number of |
|
117 components (columns), but may have a different number of observations |
|
118 (rows). |
|
119 @end deftypefn |
|
120 |
|
121 @deftypefn {Function File} {} skewness (@var{x}) |
|
122 If @var{x} is a vector of length @var{N}, return the skewness |
|
123 @iftex |
|
124 @tex |
|
125 $$ |
|
126 {\rm skewness} (x) = {1\over N \sigma(x)^3} \sum_{i=1}^N (x_i-\bar{x})^3 |
|
127 $$ |
|
128 @end tex |
|
129 @end iftex |
|
130 @ifinfo |
|
131 |
|
132 @example |
|
133 skewness (x) = N^(-1) std(x)^(-3) sum ((x - mean(x)).^3) |
|
134 @end example |
|
135 @end ifinfo |
|
136 |
|
137 @noindent |
|
138 of @var{x}. If @var{x} is a matrix, return the row vector containing |
|
139 the skewness of each column. |
|
140 @end deftypefn |