Beta

Struct Beta 

Source
pub struct Beta;
Expand description

A module containing functions to work with the Beta Functions.

Implementations§

Source§

impl Beta

Source

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);

Source

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);

Source

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);

Source

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);

Source

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);

Auto Trait Implementations§

§

impl Freeze for Beta

§

impl RefUnwindSafe for Beta

§

impl Send for Beta

§

impl Sync for Beta

§

impl Unpin for Beta

§

impl UnwindSafe for Beta

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.