Skip to content

precision is inconsistently designed for testing #322

@YeungOnion

Description

@YeungOnion

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions