Mercurial > octave-nkf
comparison scripts/plot/hist.m @ 14613:e7c8e31f8e5d
hist.m: Add test to check for correct NaN normalising
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Wed, 09 May 2012 18:44:58 -0400 |
parents | 545580e7ebfa |
children | 5d3a684236b0 |
comparison
equal
deleted
inserted
replaced
14612:545580e7ebfa | 14613:e7c8e31f8e5d |
---|---|
147 freq = diff (chist); | 147 freq = diff (chist); |
148 | 148 |
149 if (nargin > 2 && ! ischar (varargin{iarg})) | 149 if (nargin > 2 && ! ischar (varargin{iarg})) |
150 ## Normalise the histogram. | 150 ## Normalise the histogram. |
151 norm = varargin{iarg++}; | 151 norm = varargin{iarg++}; |
152 freq = freq / sum(! isnan (y)) * norm; | 152 freq = freq / sum(! isnan (y)) * norm; |
153 endif | 153 endif |
154 | 154 |
155 if (nargout > 0) | 155 if (nargout > 0) |
156 if (arg_is_vector) | 156 if (arg_is_vector) |
157 nn = freq'; | 157 nn = freq'; |
180 %!test | 180 %!test |
181 %! [nn,xx] = hist ([1 1 1 NaN NaN NaN 2 2 3],[1 2 3]); | 181 %! [nn,xx] = hist ([1 1 1 NaN NaN NaN 2 2 3],[1 2 3]); |
182 %! assert (xx, [1,2,3]); | 182 %! assert (xx, [1,2,3]); |
183 %! assert (nn, [3,2,1]); | 183 %! assert (nn, [3,2,1]); |
184 %!test | 184 %!test |
185 %! [nn,xx] = hist ([1 1 1 NaN NaN NaN 2 2 3],[1 2 3], 6); | |
186 %! assert (xx, [1,2,3]); | |
187 %! assert (nn, [3,2,1]); | |
188 %!test | |
185 %! [nn,xx] = hist ([[1:4]', [1:4]'], 3); | 189 %! [nn,xx] = hist ([[1:4]', [1:4]'], 3); |
186 %! assert (xx, [1.5;2.5;3.5]); | 190 %! assert (xx, [1.5;2.5;3.5]); |
187 %! assert (nn, [[2,1,1]',[2,1,1]']); | 191 %! assert (nn, [[2,1,1]',[2,1,1]']); |
188 %!test | 192 %!test |
189 %! for n = [10, 30, 100, 1000] | 193 %! for n = [10, 30, 100, 1000] |