Skip to content

Testing of distributions #357

Closed
Closed

Description

@pitdicker

We should add some testing for distributions. Unfortunately since distribution samples are random, this is inherently difficult. Original issue dhardy#72.

See for some direction rust-lang/rust#10084, and the random-tests.

Activity

  1. vks commented on Mar 30, 2018

    @vks
    Contributor

    Also see #290.

  2. dhardy commented on Aug 4, 2018

    @dhardy
    Member

    @vks has some plans for histogram-based testing, though possibly only after PDFs are added.

    Separately, we should add some tests of value-stability.

  3. vks commented on Aug 4, 2018

    @vks
    Contributor

    @vks has some plans for histogram-based testing, though possibly only after PDFs are added.

    See tests/uniformity.rs, which could be generalized to arbitrary distributions (with given PDFs).

  4. dhardy commented on Nov 6, 2019

    @dhardy
    Member

    @vks could I interest you (or potentially someone else) in adding at utility to rand_distr (perhaps an example) which plots histograms of each distribution from actual samples (not PDFs)? This would at least let us eye-ball that distributions are doing roughly the right thing.

  5. vks commented on Nov 6, 2019

    @vks
    Contributor

    I was thinking about using sparklines for that. I'm interested, but I can't make promises that I'll get to it before the end of the year.

  6. vks commented on May 15, 2021

    @vks
    Contributor

    Resolving this issue was started in #1121, more work is needed to extend it to the other distributions.

  7. vks commented on Apr 26, 2024

    @vks
    Contributor

    I think we should either make this issue more actionable or close it.

    For which distributions do we want histogram tests? Sometimes, calculating the PDF is non-trivial and requires special functions.

  8. dhardy commented on Apr 27, 2024

    @dhardy
    Member

    I suggest the following approach:

    1. Pick a representative parameter set (or possibly a small number of parametrisations).
    2. Generate a histogram with this parametrisation and manually verify that the result looks reasonable.
    3. Potentially lower the number of buckets and samples used by the histogram, and check the result is still similar. (We want tests to be reasonably fast to run.)
    4. The test should enforce exact reproduction of this histogram.

    This should allow fast and robust testing (within the limits of reproducibility), with the caveat that any value-breaking change must again be visually confirmed.

    It should be applicable to all distributions, though may be hard to visualise for multi-dimensional outputs.

    It cannot confirm perfect accuracy, especially in degenerate cases.

  9. jambochen commented on Sep 30, 2024

    @jambochen
    Contributor

    I am a university student with a background in statistics and would love to contribute to this repository. I have a few questions regarding this issue. I noticed that histograms are used in the tests for visual inspection by comparing the expected curve with the sample curve.

    Would it be possible to use a chi-square test for validation? The process should be similar, but hypothesis testing might provide more convincing results.

    I wrote a simple test for this: https://github.com/JamboChen/distr_test. The code is rough, and I'm unsure if this is the right approach to use here, I'd appreciate any feedback.

  10. dhardy commented on Sep 30, 2024

    @dhardy
    Member

    @jambochen feel free to take a look at #1494 by @benjamin-lieser implementing a Kolmogorov-Smirnov test.

  11. dhardy commented on Oct 17, 2024

    @dhardy
    Member

    Implemented in #1504 thanks to @jambochen and @benjamin-lieser.

    Failure cases:

  12. dhardy commented on Nov 13, 2024

    @dhardy
    Member

    We have a PR for the hypergeo issue and #1515 for the Poisson issue, so this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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