mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-31 07:38:32 +00:00
Stabilize F distribution CDF at extreme degrees
This commit is contained in:
1 parent
fea4c03ca2
commit
cca8a58bfa
2 files changed
+4
No files matched your search
@@ -48,6 +48,9 @@ fn f_cdf(x: f64, d1: f64, d2: f64) -> f64 {
|
||||
if x <= 0.0 {
|
||||
return 0.0;
|
||||
}
|
||||
if d1 >= 1e8 && d2 / d1 <= 1e-8 {
|
||||
return 1.0 - f_upper(x, d1, d2);
|
||||
}
|
||||
reg_inc_beta(d1 * x / (d1 * x + d2), d1 / 2.0, d2 / 2.0)
|
||||
}
|
||||
|
||||
|
||||
@@ -408,6 +408,7 @@ 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(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);
|
||||
is_err(ev("F.DIST.RT", vec![n(0.0), n(10_000_000_001.0), n(1.0)]), CellError::Num);
|
||||
|
||||
Reference in new issue
Block a user