pub struct Beta;Expand description
A module containing functions to work with the Beta Functions.
Implementations§
Source§impl Beta
impl Beta
Sourcepub fn lnbeta(z1: f64, z2: f64) -> f64
pub fn lnbeta(z1: f64, z2: f64) -> f64
Calculates the natural logarithm of the Beta function using the definition of the Beta function.
The Beta function, B(z1, z2), is defined as B(z1, z2) = Γ(z1) * Γ(z2) / Γ(z1 + z2), where Γ represents the gamma function.
§Parameters
z1: The first parameter of the Beta function.z2: The second parameter of the Beta function.
§Returns
The natural logarithm of the Beta function.
§Example
use numerilib::special::Beta;
let z1 = 1_f64;
let z2 = 2_f64;
let lnbeta = Beta::lnbeta(z1, z2);
println!("Natural Logarithm of Beta({}, {}) is: {}", z1, z2, lnbeta);Sourcepub fn beta(z1: f64, z2: f64) -> f64
pub fn beta(z1: f64, z2: f64) -> f64
Calculates the Beta function using the natural logarithm of the Beta function.
The Beta function, B(z1, z2), is defined as B(z1, z2) = Γ(z1) * Γ(z2) / Γ(z1 + z2), where Γ represents the gamma function.
§Parameters
z1: The first parameter of the Beta function.z2: The second parameter of the Beta function.
§Returns
The value of the Beta function.
§Example
use numerilib::special::Beta;
let z1 = 8_f64;
let z2 = 7_f64;
let beta = Beta::beta(z1, z2);
println!("Beta({}, {}) is: {}", z1, z2, beta);Sourcepub fn incbeta(z1: f64, z2: f64, x: f64) -> f64
pub fn incbeta(z1: f64, z2: f64, x: f64) -> f64
Calculates the Incomplete Beta function (I_x(z1, z2)).
§Parameters
x: The upper limit of integration.z1: The first parameter of the Beta function.z2: The second parameter of the Beta function.
§Returns
The value of the regularized incomplete Beta function.
§Example
use numerilib::special::Beta;
let x = 0.2_f64;
let z1 = 2.0_f64;
let z2 = 3.0_f64;
let incbeta = Beta::incbeta(x, z1, z2);
println!("Incomplete Beta({}, {}, {}) is: {}", x, z1, z2, incbeta);Sourcepub fn regincbeta(z1: f64, z2: f64, x: f64) -> f64
pub fn regincbeta(z1: f64, z2: f64, x: f64) -> f64
Calculates the regularized incomplete Beta function using a series definition.
The regularized incomplete Beta function, I_x(z1, z2), is defined as (1/B(z1, z2)) * ∫[0 to x] t^(z1-1) * (1-t)^(z2-1) dt, where B represents the Beta function.
§Parameters
z1: The first parameter of the Beta function.z2: The second parameter of the Beta function.x: The upper limit of integration.
§Returns
The value of the regularized incomplete Beta function.
§Example
use numerilib::special::Beta;
let x = 1_f64 / 7_f64;
let z1 = 1_f64 / 2_f64;
let z2 = 3_f64;
let regincbeta = Beta::regincbeta(z1, z2, x);
println!("Regularized Incomplete Beta({}, {}, {}) is: {}", z1, z2, x, regincbeta);Sourcepub fn invregincbeta(z1: f64, z2: f64, x: f64) -> f64
pub fn invregincbeta(z1: f64, z2: f64, x: f64) -> f64
Approximates the inverse of the regularized incomplete Beta function.
The regularized incomplete Beta function, I_x(z1, z2), is defined as (1/B(z1, z2)) * ∫[0 to x] t^(z1-1) * (1-t)^(z2-1) dt, where B represents the Beta function.
§Parameters
z1: The first parameter of the Beta function.z2: The second parameter of the Beta function.x: The target probability, typically a value between 0 and 1.
§Returns
An approximation of the inverse of the regularized incomplete Beta function.
§Example
use numerilib::special::Beta;
let z1 = 1_f64;
let z2 = 2_f64;
let x = 0.590401_f64;
let inverse = Beta::invregincbeta(z1, z2, x);
println!("Inverse Regularized Incomplete Beta({}, {}, {}) is: {}", z1, z2, x, inverse);