-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbetainc.jule
More file actions
37 lines (33 loc) · 1.16 KB
/
Copy pathbetainc.jule
File metadata and controls
37 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2025 mertcandav.
// Use of this source code is governed by a BSD 3-Clause
// license that can be found in the LICENSE file.
// Implementation derived from the gonum.
//
// Copyright ©2016 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
use "std/math"
// Returns the value of the regularized incomplete beta function
// I(x;a,b). It is defined as
//
// I(x;a,b) = B(x;a,b) / B(a,b)
// = Γ(a+b) / (Γ(a)*Γ(b)) * int_0^x u^(a-1) * (1-u)^(b-1) du.
//
// The domain of definition is 0 <= x <= 1, and the parameters a and b must be positive.
// For other values of x, a, and b, it will panic.
fn RegIncBeta(a: f64, b: f64, x: f64): f64 {
return incbet(a, b, x)
}
// Computes the inverse of the regularized incomplete beta function.
// It returns the x for which
//
// y = I(x;a,b)
//
// The domain of definition is 0 <= y <= 1, and the parameters a and b must be
// positive. For other values of x, a, and b, it will panic.
fn InvRegIncBeta(a: f64, b: f64, y: f64): f64 {
if y < 0 || 1 < y {
panic("julenum: parameter out of range")
}
return incbi(a, b, y)
}