Mercurial > octave-nkf
diff scripts/statistics/tests/z_test.m @ 19340:314b4de4bb6d
Add BIST tests for subspace, t_test, z_test.
* subspace.m, t_test.m, z_test.m: Add BIST tests.
* contributors.in: Add Pooja Rao to list of contributors.
author | Pooja Rao <poojarao12@gmail.com> |
---|---|
date | Fri, 14 Mar 2014 02:04:09 -0400 |
parents | d63878346099 |
children | 4197fc428c7d |
line wrap: on
line diff
--- a/scripts/statistics/tests/z_test.m Tue Nov 04 20:18:15 2014 -0800 +++ b/scripts/statistics/tests/z_test.m Fri Mar 14 02:04:09 2014 -0400 @@ -86,3 +86,33 @@ endfunction + +%!test +%! ## Two-sided (also the default option) +%! x = rand (10,1); n = length (x); +%! u0 = 0.5; v = 1/12; # true mean, var +%! pval = z_test (x, u0, v, "!="); +%! if (mean (x) >= u0) +%! zval = abs (norminv (0.5*pval)); +%! else +%! zval = -abs (norminv (0.5*pval)); +%! endif +%! unew = zval * sqrt (v/n) + u0; +%! assert (mean (x), unew, 100*eps); + +%!test +%! x = rand (10,1); n = length (x); +%! u0 = 0.5; v = 1/12; +%! pval = z_test (x, u0, v, ">"); +%! zval = norminv (1-pval); +%! unew = zval * sqrt (v/n) + u0; +%! assert (mean (x), unew, 100*eps); + +%!test +%! x = rand (10,1); n = length (x); +%! u0 = 0.5; v = 1/12; +%! pval = z_test (x, u0, v, "<"); +%! zval = norminv (pval); +%! unew = zval * sqrt (v/n) + u0; +%! assert (mean (x), unew, 100*eps); +