Skip to content

Commit

Permalink
fix precision errors in BISTs, issue #167
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0m1th3as committed Feb 1, 2025
1 parent 7e617b5 commit 88e82d7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
38 changes: 19 additions & 19 deletions inst/dist_fun/hygepdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,32 +161,32 @@
%!shared x, y
%! x = [-1 0 1 2 3];
%! y = [0 1/6 4/6 1/6 0];
%!assert (hygepdf (x, 4*ones (1,5), 2, 2), y, eps)
%!assert (hygepdf (x, 4, 2*ones (1,5), 2), y, eps)
%!assert (hygepdf (x, 4, 2, 2*ones (1,5)), y, eps)
%!assert (hygepdf (x, 4*[1 -1 NaN 1.1 1], 2, 2), [0 NaN NaN NaN 0], eps)
%!assert (hygepdf (x, 4, 2*[1 -1 NaN 1.1 1], 2), [0 NaN NaN NaN 0], eps)
%!assert (hygepdf (x, 4, 5, 2), [NaN NaN NaN NaN NaN], eps)
%!assert (hygepdf (x, 4, 2, 2*[1 -1 NaN 1.1 1]), [0 NaN NaN NaN 0], eps)
%!assert (hygepdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN], eps)
%!assert (hygepdf ([x, NaN], 4, 2, 2), [y, NaN], eps)
%!assert (hygepdf (x, 4 * ones (1, 5), 2, 2), y, 3 * eps)
%!assert (hygepdf (x, 4, 2 * ones (1, 5), 2), y, 3 * eps)
%!assert (hygepdf (x, 4, 2, 2 * ones (1, 5)), y, 3 * eps)
%!assert (hygepdf (x, 4 * [1, -1, NaN, 1.1, 1], 2, 2), [0, NaN, NaN, NaN, 0])
%!assert (hygepdf (x, 4, 2 * [1, -1, NaN, 1.1, 1], 2), [0, NaN, NaN, NaN, 0])
%!assert (hygepdf (x, 4, 5, 2), [NaN, NaN, NaN, NaN, NaN], 3 * eps)
%!assert (hygepdf (x, 4, 2, 2 * [1, -1, NaN, 1.1, 1]), [0, NaN, NaN, NaN, 0])
%!assert (hygepdf (x, 4, 2, 5), [NaN, NaN, NaN, NaN, NaN], 3 * eps)
%!assert (hygepdf ([x, NaN], 4, 2, 2), [y, NaN], 3 * eps)

## Test class of input preserved
%!assert (hygepdf (single ([x, NaN]), 4, 2, 2), single ([y, NaN]), eps("single"))
%!assert (hygepdf ([x, NaN], single (4), 2, 2), single ([y, NaN]), eps("single"))
%!assert (hygepdf ([x, NaN], 4, single (2), 2), single ([y, NaN]), eps("single"))
%!assert (hygepdf ([x, NaN], 4, 2, single (2)), single ([y, NaN]), eps("single"))
%!assert (hygepdf (single ([x, NaN]), 4, 2, 2), single ([y, NaN]), eps ("single"))
%!assert (hygepdf ([x, NaN], single (4), 2, 2), single ([y, NaN]), eps ("single"))
%!assert (hygepdf ([x, NaN], 4, single (2), 2), single ([y, NaN]), eps ("single"))
%!assert (hygepdf ([x, NaN], 4, 2, single (2)), single ([y, NaN]), eps ("single"))

## Test vector expansion
%!test
%! z = zeros(3,5);
%! z([4,5,6,8,9,12]) = [1, 0.5, 1/6, 0.5, 2/3, 1/6];
%! assert (hygepdf (x, 4, [0, 1, 2], 2, "vectorexpand"), z, eps);
%! assert (hygepdf (x, 4, [0, 1, 2]', 2, "vectorexpand"), z, eps);
%! assert (hygepdf (x', 4, [0, 1, 2], 2, "vectorexpand"), z, eps);
%! assert (hygepdf (2, 4, [0 ,1, 2], 2, "vectorexpand"), z(:,4), eps);
%! assert (hygepdf (x, 4, 1, 2, "vectorexpand"), z(2,:), eps);
%! assert (hygepdf ([NaN, x], 4, [0 1 2]', 2, "vectorexpand"), [NaN(3,1), z], eps);
%! assert (hygepdf (x, 4, [0, 1, 2], 2, "vectorexpand"), z, 3 * eps);
%! assert (hygepdf (x, 4, [0, 1, 2]', 2, "vectorexpand"), z, 3 * eps);
%! assert (hygepdf (x', 4, [0, 1, 2], 2, "vectorexpand"), z, 3 * eps);
%! assert (hygepdf (2, 4, [0 ,1, 2], 2, "vectorexpand"), z(:,4), 3 * eps);
%! assert (hygepdf (x, 4, 1, 2, "vectorexpand"), z(2,:), 3 *eps);
%! assert (hygepdf ([NaN, x], 4, [0 1 2]', 2, "vectorexpand"), [NaN(3, 1), z], 3 * eps);

## Test input validation
%!error<hygepdf: function called with too few input arguments.> hygepdf ()
Expand Down
2 changes: 1 addition & 1 deletion inst/dist_fun/ncfinv.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
%! x = [1.6090, 1.8113, 1.9215, 1.9911, NaN, 2.0742];
%! assert (ncfinv (0.05, 1, [1, 2, 3, 4, -1, 6], 10), x, 1e-4);
%!test
%! assert (ncfinv (0.996, 3, 5, 8), 58.0912074080671, 2e-13);
%! assert (ncfinv (0.996, 3, 5, 8), 58.0912074080671, 4e-12);

## Test input validation
%!error<ncfinv: function called with too few input arguments.> ncfinv ()
Expand Down
2 changes: 1 addition & 1 deletion inst/dist_fun/ncx2inv.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
%! x = [1.3941, 1.6824, 2.0103, 2.3760, NaN, 3.2087];
%! assert (ncx2inv (0.05, 5, [1, 2, 3, 4, -1, 6]), x, 1e-4);
%!test
%! assert (ncx2inv (0.996, 5, 8), 35.51298862765576, 2e-13);
%! assert (ncx2inv (0.996, 5, 8), 35.51298862765576, 3e-13);

## Test input validation
%!error<ncx2inv: function called with too few input arguments.> ncx2inv ()
Expand Down

0 comments on commit 88e82d7

Please sign in to comment.