Mercurial > octave-nkf
comparison scripts/statistics/base/ols.m @ 14342:2cd56a5e3a66 stable
new tests
* ols.m: New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 07 Feb 2012 11:41:33 -0500 |
parents | 71efccec5936 |
children | f3d52523cde1 |
comparison
equal
deleted
inserted
replaced
14341:71efccec5936 | 14342:2cd56a5e3a66 |
---|---|
139 %! x = [1:5]'; | 139 %! x = [1:5]'; |
140 %! y = 3*x + 2; | 140 %! y = 3*x + 2; |
141 %! x = [x, ones(5,1)]; | 141 %! x = [x, ones(5,1)]; |
142 %! assert (ols(y,x), [3; 2], 50*eps) | 142 %! assert (ols(y,x), [3; 2], 50*eps) |
143 | 143 |
144 %!test | |
145 %! x = [1, 2; 3, 4]; | |
146 %! y = [1; 2]; | |
147 %! [b, s, r] = ols (x, y); | |
148 %! assert (b, [1.4, 2], 2*eps); | |
149 %! assert (s, [0.2, 0; 0, 0], 2*eps); | |
150 %! assert (r, [-0.4, 0; 0.2, 0], 2*eps); | |
151 | |
152 %!test | |
153 %! x = [1, 2; 3, 4]; | |
154 %! y = [1; 2]; | |
155 %! [b, s] = ols (x, y); | |
156 %! assert (b, [1.4, 2], 2*eps); | |
157 %! assert (s, [0.2, 0; 0, 0], 2*eps); | |
158 | |
159 %!test | |
160 %! x = [1, 2; 3, 4]; | |
161 %! y = [1; 2]; | |
162 %! b = ols (x, y); | |
163 %! assert (b, [1.4, 2], 2*eps); | |
164 | |
144 %% Test input validation | 165 %% Test input validation |
145 %!error ols (); | 166 %!error ols (); |
146 %!error ols (1); | 167 %!error ols (1); |
147 %!error ols (1, 2, 3); | 168 %!error ols (1, 2, 3); |
148 %!error ols ([true, true], [1, 2]); | 169 %!error ols ([true, true], [1, 2]); |