Skip to content

FisherSnedecor::cdf and sf do not sum to 1 for a small first degree of freedom #462

Description

@DRMacIver
use statrs::distribution::{ContinuousCDF, FisherSnedecor};

fn main() {
    for (d1, d2) in [(0.001, 1000.0), (10.0, 10.0)] {
        let f = FisherSnedecor::new(d1, d2).unwrap();
        for x in [1e-20, 1e-15, 0.1] {
            println!("F({d1}, {d2}) at x = {x:e}: cdf + sf = {}", f.cdf(x) + f.sf(x));
        }
    }
}

Output:

F(0.001, 1000) at x = 1e-20: cdf + sf = 1.9738106489735783
F(0.001, 1000) at x = 1e-15: cdf + sf = 1.9794325192018662
F(0.001, 1000) at x = 1e-1: cdf + sf = 1.0000000000002767
F(10, 10) at x = 1e-20: cdf + sf = 1
F(10, 10) at x = 1e-15: cdf + sf = 1
F(10, 10) at x = 1e-1: cdf + sf = 1

They should sum to 1, as they do at F(10, 10). sf returns exactly 1 at both small x while cdf is already 0.97.

Same failure as #432 (Beta::sf returning exactly 1 for tiny x), which #438 fixed for Beta only.

Tested on statrs 0.19.1 and current main (50fcf4d).

(This was another bug found using hegel.)

Activity

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

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