mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-31 07:38:32 +00:00
Preserve F distribution tail accuracy
This commit is contained in:
1 parent
a04629576d
commit
006b7962bd
2 files changed
+6
-1
No files matched your search
@@ -51,8 +51,11 @@ fn f_cdf(x: f64, d1: f64, d2: f64) -> f64 {
|
||||
if x <= 0.0 {
|
||||
return 0.0;
|
||||
}
|
||||
if x == 1.0 && d1 == d2 {
|
||||
return 0.5;
|
||||
}
|
||||
if d1 >= 1e8 && d2 / d1 <= 1e-8 {
|
||||
return 1.0 - f_upper(x, d1, d2);
|
||||
return reg_gamma_q(d2 / 2.0, d2 / (2.0 * (x + d2 / d1)));
|
||||
}
|
||||
reg_inc_beta(d1 * x / (d1 * x + d2), d1 / 2.0, d2 / 2.0)
|
||||
}
|
||||
|
||||
@@ -409,6 +409,8 @@ fn t_chi_f() {
|
||||
fn f_distributions_accept_ten_billion_degrees() {
|
||||
close_tol(ev("F.DIST", vec![n(0.0), n(10_000_000_000.0), n(1.0), b(false)]), 0.0, 0.0);
|
||||
close_tol(ev("F.DIST.RT", vec![n(0.0), n(1.0), n(10_000_000_000.0)]), 1.0, 0.0);
|
||||
close_tol(ev("F.DIST", vec![n(0.01), n(1_000_000_000.0), n(1.0), b(true)]), 1.52397e-23, 1e-28);
|
||||
close_tol(ev("F.DIST", vec![n(1.0), n(10_000_000_000.0), n(10_000_000_000.0), b(true)]), 0.5, 0.0);
|
||||
close_tol(ev("F.DIST", vec![n(1_000_000.0), n(10_000_000_000.0), n(1.0), b(true)]), 0.999202115, 1e-8);
|
||||
close_tol(ev("F.INV", vec![n(0.5), n(10_000_000_000.0), n(1.0)]), 2.198110953542527, 2e-6);
|
||||
close_tol(ev("F.DIST.RT", vec![n(0.0), n(9_999_999_999.0), n(1.0)]), 1.0, 0.0);
|
||||
|
||||
Reference in new issue
Block a user