Mercurial > octave-nkf
comparison scripts/statistics/distributions/normcdf.m @ 19867:9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Try to trim long lines to < 80 chars.
Use '##' for single line comments.
Use '(...)' around tests for if/elseif/switch/while.
Abut cell indexing operator '{' next to variable.
Abut array indexing operator '(' next to variable.
Use space between negation operator '!' and following expression.
Use two newlines between endfunction and start of %!test or %!demo code.
Remove unnecessary parens grouping between short-circuit operators.
Remove stray extra spaces (typos) between variables and assignment operators.
Remove stray extra spaces from ends of lines.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 23 Feb 2015 14:54:39 -0800 |
parents | 4197fc428c7d |
children | d9341b422488 |
comparison
equal
deleted
inserted
replaced
19866:a1acca0c2216 | 19867:9fc020886ae9 |
---|---|
34 | 34 |
35 if (nargin != 1 && nargin != 3) | 35 if (nargin != 1 && nargin != 3) |
36 print_usage (); | 36 print_usage (); |
37 endif | 37 endif |
38 | 38 |
39 if (!isscalar (mu) || !isscalar (sigma)) | 39 if (! isscalar (mu) || ! isscalar (sigma)) |
40 [retval, x, mu, sigma] = common_size (x, mu, sigma); | 40 [retval, x, mu, sigma] = common_size (x, mu, sigma); |
41 if (retval > 0) | 41 if (retval > 0) |
42 error ("normcdf: X, MU, and SIGMA must be of common size or scalars"); | 42 error ("normcdf: X, MU, and SIGMA must be of common size or scalars"); |
43 endif | 43 endif |
44 endif | 44 endif |
78 %!assert (normcdf (x, ones (1,4), 1), y) | 78 %!assert (normcdf (x, ones (1,4), 1), y) |
79 %!assert (normcdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN]) | 79 %!assert (normcdf (x, [0 -Inf NaN Inf], 1), [y(1) NaN NaN NaN]) |
80 %!assert (normcdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]) | 80 %!assert (normcdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]) |
81 %!assert (normcdf ([x(1:2) NaN x(4)], 1, 1), [y(1:2) NaN y(4)]) | 81 %!assert (normcdf ([x(1:2) NaN x(4)], 1, 1), [y(1:2) NaN y(4)]) |
82 | 82 |
83 %% Test class of input preserved | 83 ## Test class of input preserved |
84 %!assert (normcdf ([x, NaN], 1, 1), [y, NaN]) | 84 %!assert (normcdf ([x, NaN], 1, 1), [y, NaN]) |
85 %!assert (normcdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single")) | 85 %!assert (normcdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single")) |
86 %!assert (normcdf ([x, NaN], single (1), 1), single ([y, NaN]), eps ("single")) | 86 %!assert (normcdf ([x, NaN], single (1), 1), single ([y, NaN]), eps ("single")) |
87 %!assert (normcdf ([x, NaN], 1, single (1)), single ([y, NaN]), eps ("single")) | 87 %!assert (normcdf ([x, NaN], 1, single (1)), single ([y, NaN]), eps ("single")) |
88 | 88 |
89 %% Test input validation | 89 ## Test input validation |
90 %!error normcdf () | 90 %!error normcdf () |
91 %!error normcdf (1,2) | 91 %!error normcdf (1,2) |
92 %!error normcdf (1,2,3,4) | 92 %!error normcdf (1,2,3,4) |
93 %!error normcdf (ones (3), ones (2), ones (2)) | 93 %!error normcdf (ones (3), ones (2), ones (2)) |
94 %!error normcdf (ones (2), ones (3), ones (2)) | 94 %!error normcdf (ones (2), ones (3), ones (2)) |