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
38
39
//! Beta function and log-beta via lgamma.
use crateFloatScalar;
use lgamma;
/// Beta function B(a, b) = Γ(a)·Γ(b) / Γ(a+b).
///
/// Computed as `exp(lbeta(a, b))` to avoid overflow for large arguments.
///
/// # Example
///
/// ```
/// use numeris::special::beta;
///
/// // B(1, 1) = 1
/// assert!((beta(1.0_f64, 1.0) - 1.0).abs() < 1e-14);
///
/// // B(2, 3) = 1/12
/// assert!((beta(2.0_f64, 3.0) - 1.0 / 12.0).abs() < 1e-14);
/// ```
/// Natural logarithm of the beta function, ln B(a, b).
///
/// Computed as `lgamma(a) + lgamma(b) − lgamma(a+b)`.
///
/// # Example
///
/// ```
/// use numeris::special::lbeta;
///
/// // ln B(1, 1) = 0
/// assert!(lbeta(1.0_f64, 1.0).abs() < 1e-14);
/// ```