Mercurial > octave-nkf
comparison scripts/statistics/distributions/tpdf.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 |
---|---|
31 | 31 |
32 if (nargin != 2) | 32 if (nargin != 2) |
33 print_usage (); | 33 print_usage (); |
34 endif | 34 endif |
35 | 35 |
36 if (!isscalar (n)) | 36 if (! isscalar (n)) |
37 [retval, x, n] = common_size (x, n); | 37 [retval, x, n] = common_size (x, n); |
38 if (retval > 0) | 38 if (retval > 0) |
39 error ("tpdf: X and N must be of common size or scalars"); | 39 error ("tpdf: X and N must be of common size or scalars"); |
40 endif | 40 endif |
41 endif | 41 endif |
75 %! y = 1./(pi * (1 + x.^2)); | 75 %! y = 1./(pi * (1 + x.^2)); |
76 %!assert (tpdf (x, ones (1,5)), y, eps) | 76 %!assert (tpdf (x, ones (1,5)), y, eps) |
77 %!assert (tpdf (x, 1), y, eps) | 77 %!assert (tpdf (x, 1), y, eps) |
78 %!assert (tpdf (x, [0 NaN 1 1 1]), [NaN NaN y(3:5)], eps) | 78 %!assert (tpdf (x, [0 NaN 1 1 1]), [NaN NaN y(3:5)], eps) |
79 | 79 |
80 %% Test class of input preserved | 80 ## Test class of input preserved |
81 %!assert (tpdf ([x, NaN], 1), [y, NaN], eps) | 81 %!assert (tpdf ([x, NaN], 1), [y, NaN], eps) |
82 %!assert (tpdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) | 82 %!assert (tpdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) |
83 %!assert (tpdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) | 83 %!assert (tpdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) |
84 | 84 |
85 %% Test input validation | 85 ## Test input validation |
86 %!error tpdf () | 86 %!error tpdf () |
87 %!error tpdf (1) | 87 %!error tpdf (1) |
88 %!error tpdf (1,2,3) | 88 %!error tpdf (1,2,3) |
89 %!error tpdf (ones (3), ones (2)) | 89 %!error tpdf (ones (3), ones (2)) |
90 %!error tpdf (ones (2), ones (3)) | 90 %!error tpdf (ones (2), ones (3)) |