Mercurial > hg > octave-nkf
comparison scripts/statistics/tests/sign_test.m @ 20038: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
20037:a1acca0c2216 | 20038:9fc020886ae9 |
---|---|
42 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> | 42 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
43 ## Description: Sign test | 43 ## Description: Sign test |
44 | 44 |
45 function [pval, b, n] = sign_test (x, y, alt) | 45 function [pval, b, n] = sign_test (x, y, alt) |
46 | 46 |
47 if ((nargin < 2) || (nargin > 3)) | 47 if (nargin < 2 || nargin > 3) |
48 print_usage (); | 48 print_usage (); |
49 endif | 49 endif |
50 | 50 |
51 if (! (isvector (x) && isvector (y) && (length (x) == length (y)))) | 51 if (! (isvector (x) && isvector (y) && (length (x) == length (y)))) |
52 error ("sign_test: X and Y must be vectors of the same length"); | 52 error ("sign_test: X and Y must be vectors of the same length"); |
58 n = sum (x != y); | 58 n = sum (x != y); |
59 b = sum (x > y); | 59 b = sum (x > y); |
60 cdf = binocdf (b, n, 1/2); | 60 cdf = binocdf (b, n, 1/2); |
61 | 61 |
62 if (nargin == 2) | 62 if (nargin == 2) |
63 alt = "!="; | 63 alt = "!="; |
64 endif | 64 endif |
65 | 65 |
66 if (! ischar (alt)) | 66 if (! ischar (alt)) |
67 error ("sign_test: ALT must be a string"); | 67 error ("sign_test: ALT must be a string"); |
68 endif | 68 endif |