comparison scripts/statistics/base/statistics.m @ 18956:ab5983dc0587 stable

statistics.m: Fix regression caused by change in skewness, kurtosis functions. * statistics.m: Call skewness and kurtosis functions with an empty matrix (use default) for the flag argument. Add %!test to check correct behavior.
author Rik <rik@octave.org>
date Thu, 24 Jul 2014 11:11:57 -0700
parents d63878346099
children
comparison
equal deleted inserted replaced
18953:bcbd309bf272 18956:ab5983dc0587
59 endif 59 endif
60 60
61 emp_inv = quantile (x, [0.25; 0.5; 0.75], dim, 7); 61 emp_inv = quantile (x, [0.25; 0.5; 0.75], dim, 7);
62 62
63 stats = cat (dim, min (x, [], dim), emp_inv, max (x, [], dim), mean (x, dim), 63 stats = cat (dim, min (x, [], dim), emp_inv, max (x, [], dim), mean (x, dim),
64 std (x, [], dim), skewness (x, dim), kurtosis (x, dim)); 64 std (x, [], dim), skewness (x, [], dim), kurtosis (x, [], dim));
65 65
66 endfunction 66 endfunction
67 67
68 68
69 %!test 69 %!test
75 %! assert (mean (x), s(6,:), eps); 75 %! assert (mean (x), s(6,:), eps);
76 %! assert (std (x), s(7,:), eps); 76 %! assert (std (x), s(7,:), eps);
77 %! assert (skewness (x), s(8,:), eps); 77 %! assert (skewness (x), s(8,:), eps);
78 %! assert (kurtosis (x), s(9,:), eps); 78 %! assert (kurtosis (x), s(9,:), eps);
79 79
80 %! x = rand (7,5);
81 %! s = statistics (x, 2);
82 %! assert (min (x, [], 2), s(:,1), eps);
83 %! assert (median (x, 2), s(:,3), eps);
84 %! assert (max (x, [], 2), s(:,5), eps);
85 %! assert (mean (x, 2), s(:,6), eps);
86 %! assert (std (x, [], 2), s(:,7), eps);
87 %! assert (skewness (x, [], 2), s(:,8), eps);
88 %! assert (kurtosis (x, [], 2), s(:,9), eps);
89
80 %% Test input validation 90 %% Test input validation
81 %!error statistics () 91 %!error statistics ()
82 %!error statistics (1, 2, 3) 92 %!error statistics (1, 2, 3)
83 %!error statistics (['A'; 'B']) 93 %!error statistics (['A'; 'B'])
84 %!error statistics (1, ones (2,2)) 94 %!error statistics (1, ones (2,2))