Skip to content

Commit

Permalink
add tolerance to certain tests, issue #150
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0m1th3as committed Aug 27, 2024
1 parent 64e87b4 commit bc9331d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion inst/dist_fun/bvncdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
%! 0.9722897881414742, 0.9788150170059926, ...
%! 0.9813597788804785, 0.9821977956568989, ...
%! 0.9824283794464095, 0.9824809345614861]';
%! assert (p([616:625]), p_out, 2e-16);
%! assert (p([616:625]), p_out, 3e-16);
%!error bvncdf (randn (25,3), [], [1, 1; 1, 1]);
%!error bvncdf (randn (25,2), [], [1, 1; 1, 1]);
%!error bvncdf (randn (25,2), [], ones (3, 2));
8 changes: 4 additions & 4 deletions inst/dist_fun/expcdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@
%!shared x, p
%! x = [-1 0 0.5 1 Inf];
%! p = [0, 1 - exp(-x(2:end)/2)];
%!assert (expcdf (x, 2*ones (1,5)), p)
%!assert (expcdf (x, 2), p)
%!assert (expcdf (x, 2*[1 0 NaN 1 1]), [0 NaN NaN p(4:5)])
%!assert (expcdf (x, 2 * ones (1, 5)), p, 1e-16)
%!assert (expcdf (x, 2), p, 1e-16)
%!assert (expcdf (x, 2 * [1, 0, NaN, 1, 1]), [0, NaN, NaN, p(4:5)], 1e-16)
%!assert (expcdf ([x, NaN], 2), [p, NaN], 1e-16)
## Test class of input preserved
%!assert (expcdf ([x, NaN], 2), [p, NaN])
%!assert (expcdf (single ([x, NaN]), 2), single ([p, NaN]))
%!assert (expcdf ([x, NaN], single (2)), single ([p, NaN]))

Expand Down
10 changes: 5 additions & 5 deletions inst/dist_fun/mvncdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -470,23 +470,23 @@
%! 0.9722897881414742, 0.9788150170059926, ...
%! 0.9813597788804785, 0.9821977956568989, ...
%! 0.9824283794464095, 0.9824809345614861]';
%! assert (p([616:625]), p_out, 2e-16);
%! assert (p([616:625]), p_out, 3e-16);
%!test
%! mu = [0, 0];
%! Sigma = [0.25, 0.3; 0.3, 1];
%! [p, err] = mvncdf ([0 0], [1 1], mu, Sigma);
%! [p, err] = mvncdf ([0, 0], [1, 1], mu, Sigma);
%! assert (p, 0.2097424404755626, 1e-16);
%! assert (err, 1e-08);
%!test
%! x = [1 2];
%! mu = [0.5 1.5];
%! sigma = [1.0 0.5; 0.5 1.0];
%! sigma = [1.0, 0.5; 0.5, 1.0];
%! p = mvncdf (x, mu, sigma);
%! assert (p, 0.546244443857090, 1e-15);
%!test
%! x = [1 2];
%! mu = [0.5 1.5];
%! sigma = [1.0 0.5; 0.5 1.0];
%! sigma = [1.0, 0.5; 0.5, 1.0];
%! a = [-inf 0];
%! p = mvncdf (a, x, mu, sigma);
%! assert (p, 0.482672935215631, 1e-15);
Expand All @@ -495,4 +495,4 @@
%!error p = mvncdf (randn (25,4), randn (25,5), [], eye (4));
%!error p = mvncdf (randn (25,4), randn (25,4), [2, 3; 2, 3], eye (4));
%!error p = mvncdf (randn (25,4), randn (25,4), ones (1, 5), eye (4));
%!error p = mvncdf ([-inf 0], [1, 2], [0.5 1.5], [1.0 0.5; 0.5 1.0], option);
%!error p = mvncdf ([-inf, 0], [1, 2], [0.5, 1.5], [1.0, 0.5; 0.5, 1.0], option)
8 changes: 4 additions & 4 deletions inst/dist_fun/wblcdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@
%!shared x, y
%! x = [-1 0 0.5 1 Inf];
%! y = [0, 1-exp(-x(2:4)), 1];
%!assert (wblcdf (x, ones (1,5), ones (1,5)), y)
%!assert (wblcdf (x, ones (1,5), ones (1,5)), y, 1e-16)
%!assert (wblcdf (x, ones (1,5), ones (1,5), "upper"), 1 - y)
%!assert (wblcdf (x, "upper"), 1 - y)
%!assert (wblcdf (x, 1, ones (1,5)), y)
%!assert (wblcdf (x, ones (1,5), 1), y)
%!assert (wblcdf (x, 1, ones (1,5)), y, 1e-16)
%!assert (wblcdf (x, ones (1,5), 1), y, 1e-16)
%!assert (wblcdf (x, [0 1 NaN Inf 1], 1), [NaN 0 NaN 0 1])
%!assert (wblcdf (x, [0 1 NaN Inf 1], 1, "upper"), 1 - [NaN 0 NaN 0 1])
%!assert (wblcdf (x, 1, [0 1 NaN Inf 1]), [NaN 0 NaN y(4:5)])
Expand All @@ -211,7 +211,7 @@
%!assert (wblcdf ([x(1:2) NaN x(4:5)], 1, 1, "upper"), 1 - [y(1:2) NaN y(4:5)])

## Test class of input preserved
%!assert (wblcdf ([x, NaN], 1, 1), [y, NaN])
%!assert (wblcdf ([x, NaN], 1, 1), [y, NaN], 1e-16)
%!assert (wblcdf (single ([x, NaN]), 1, 1), single ([y, NaN]))
%!assert (wblcdf ([x, NaN], single (1), 1), single ([y, NaN]))
%!assert (wblcdf ([x, NaN], 1, single (1)), single ([y, NaN]))
Expand Down
4 changes: 2 additions & 2 deletions inst/dist_obj/NormalDistribution.m
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,9 @@ function checkparams (mu, sigma)
%!assert (iqr (pd), 1.3490, 1e-4);
%!assert (iqr (t), 1.2782, 1e-4);
%!assert (mean (pd), 0);
%!assert (mean (t), 0, eps);
%!assert (mean (t), 0, 3e-16);
%!assert (median (pd), 0);
%!assert (median (t), 0);
%!assert (median (t), 0, 3e-16);
%!assert (pdf (pd, [0:5]), [0.3989, 0.2420, 0.0540, 0.0044, 0.0001, 0], 1e-4);
%!assert (pdf (t, [0:5]), [0.4180, 0.2535, 0.0566, 0, 0, 0], 1e-4);
%!assert (pdf (pd, [-1, 1:4, NaN]), [0.2420, 0.2420, 0.0540, 0.0044, 0.0001, NaN], 1e-4);
Expand Down

0 comments on commit bc9331d

Please sign in to comment.