comparison scripts/statistics/tests/var_test.m @ 19833: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
comparison
equal deleted inserted replaced
19832:a1acca0c2216 19833:9fc020886ae9
41 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> 41 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
42 ## Description: F test to compare two variances 42 ## Description: F test to compare two variances
43 43
44 function [pval, f, df_num, df_den] = var_test (x, y, alt) 44 function [pval, f, df_num, df_den] = var_test (x, y, alt)
45 45
46 if ((nargin < 2) || (nargin > 3)) 46 if (nargin < 2 || nargin > 3)
47 print_usage (); 47 print_usage ();
48 endif 48 endif
49 49
50 if (! (isvector (x) && isvector (y))) 50 if (! (isvector (x) && isvector (y)))
51 error ("var_test: both X and Y must be vectors"); 51 error ("var_test: both X and Y must be vectors");
55 df_den = length (y) - 1; 55 df_den = length (y) - 1;
56 f = var (x) / var (y); 56 f = var (x) / var (y);
57 cdf = fcdf (f, df_num, df_den); 57 cdf = fcdf (f, df_num, df_den);
58 58
59 if (nargin == 2) 59 if (nargin == 2)
60 alt = "!="; 60 alt = "!=";
61 endif 61 endif
62 62
63 if (! ischar (alt)) 63 if (! ischar (alt))
64 error ("var_test: ALT must be a string"); 64 error ("var_test: ALT must be a string");
65 endif 65 endif