Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

precision is inconsistently designed for testing #322

Open
YeungOnion opened this issue Jan 30, 2025 · 1 comment · May be fixed by #325
Open

precision is inconsistently designed for testing #322

YeungOnion opened this issue Jan 30, 2025 · 1 comment · May be fixed by #325

Comments

@YeungOnion
Copy link
Contributor

iirc @FreezyLemon went about and changed most of existing at-the-time tests to not use exact precision and to also rely on approx crate where suitable. By also adding a boiler for macro generation of test suites, it places a default tolerance on most of the tests, but the macro is designed to make it more ergonomic to write tests for parametrized distributions. This added significant consistency across testing precision, especially when not requiring the use of special functions.

That default precision is not used in the special functions testing. The default was set to crate::consts::ACC which is set at 1e-10.

There's still some usage of the statrs::prec module, and erf has some regions where it tests within 1e-9. This affects the cdf for Normal and for sufficiently large dof, StudentsT. I wish to change all instances of float comparison to use approx and to have clearly denoted defaults.


Further, it means we have to reduce the default precision on the tests to pass them or change some of the special function implementation.

regarding alternatives

  • erf is a GCC builtin that GSL binds to, which means not pure rust and linking to system libs.
  • rust-lang/libm uses a MUSL implementation that passes our tests at higher precision, we could perhaps think of delegating special function work to another crate, perhaps special since it uses libm
  • spec_math is a direct CEPHES rewrite, CEPHES is MIT Licensed.
@FreezyLemon
Copy link
Contributor

I wish to change all instances of float comparison to use approx and to have clearly denoted defaults.

I think this makes sense, but I would create a pub(crate) wrapper around approx (like statrs::prec) to do this. This would be helpful in case approx changes default values or if a switch away from approx is wanted for whatever reason.

@YeungOnion YeungOnion linked a pull request Feb 4, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants