comparison scripts/statistics/distributions/nbincdf.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
38 38
39 if (nargin != 3) 39 if (nargin != 3)
40 print_usage (); 40 print_usage ();
41 endif 41 endif
42 42
43 if (!isscalar (n) || !isscalar (p)) 43 if (! isscalar (n) || ! isscalar (p))
44 [retval, x, n, p] = common_size (x, n, p); 44 [retval, x, n, p] = common_size (x, n, p);
45 if (retval > 0) 45 if (retval > 0)
46 error ("nbincdf: X, N, and P must be of common size or scalars"); 46 error ("nbincdf: X, N, and P must be of common size or scalars");
47 endif 47 endif
48 endif 48 endif
83 %!assert (nbincdf (x, ones (1,5), 0.5), y) 83 %!assert (nbincdf (x, ones (1,5), 0.5), y)
84 %!assert (nbincdf ([x(1:3) 0 x(5)], [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN nbinpdf(0,1.5,0.5) NaN], eps) 84 %!assert (nbincdf ([x(1:3) 0 x(5)], [0 1 NaN 1.5 Inf], 0.5), [NaN 1/2 NaN nbinpdf(0,1.5,0.5) NaN], eps)
85 %!assert (nbincdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)]) 85 %!assert (nbincdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)])
86 %!assert (nbincdf ([x(1:2) NaN x(4:5)], 1, 0.5), [y(1:2) NaN y(4:5)]) 86 %!assert (nbincdf ([x(1:2) NaN x(4:5)], 1, 0.5), [y(1:2) NaN y(4:5)])
87 87
88 %% Test class of input preserved 88 ## Test class of input preserved
89 %!assert (nbincdf ([x, NaN], 1, 0.5), [y, NaN]) 89 %!assert (nbincdf ([x, NaN], 1, 0.5), [y, NaN])
90 %!assert (nbincdf (single ([x, NaN]), 1, 0.5), single ([y, NaN])) 90 %!assert (nbincdf (single ([x, NaN]), 1, 0.5), single ([y, NaN]))
91 %!assert (nbincdf ([x, NaN], single (1), 0.5), single ([y, NaN])) 91 %!assert (nbincdf ([x, NaN], single (1), 0.5), single ([y, NaN]))
92 %!assert (nbincdf ([x, NaN], 1, single (0.5)), single ([y, NaN])) 92 %!assert (nbincdf ([x, NaN], 1, single (0.5)), single ([y, NaN]))
93 93
94 %% Test input validation 94 ## Test input validation
95 %!error nbincdf () 95 %!error nbincdf ()
96 %!error nbincdf (1) 96 %!error nbincdf (1)
97 %!error nbincdf (1,2) 97 %!error nbincdf (1,2)
98 %!error nbincdf (1,2,3,4) 98 %!error nbincdf (1,2,3,4)
99 %!error nbincdf (ones (3), ones (2), ones (2)) 99 %!error nbincdf (ones (3), ones (2), ones (2))