pub fn beta_simd<F>(a: &ArrayView1<'_, F>, b: &ArrayView1<'_, F>) -> Array1<F>where
F: Float + SimdUnifiedOps,Expand description
Compute the Beta function B(a, b) using SIMD operations
The Beta function is defined as: B(a, b) = Γ(a)Γ(b) / Γ(a+b)
This function computes B(a[i], b[i]) for each pair of elements.
The Beta function is fundamental in:
- Beta distribution (Bayesian priors for probabilities)
- Binomial coefficients: C(n,k) = 1/((n+1)·B(n-k+1, k+1))
- Statistical hypothesis testing
- Machine learning (Dirichlet processes)
§Mathematical Properties
- B(a, b) = B(b, a) (symmetric)
- B(1, 1) = 1
- B(a, 1) = 1/a
- B(1, b) = 1/b
- B(a, b) = B(a+1, b) + B(a, b+1)
§Arguments
a- First parameter array (must be > 0)b- Second parameter array (must be > 0, same length asa)
§Returns
- Array with
B(a[i], b[i])for each pair
§Example
use scirs2_core::ndarray_ext::elementwise::beta_simd;
use ndarray::{array, ArrayView1};
let a = array![1.0_f64, 2.0, 0.5];
let b = array![1.0_f64, 2.0, 0.5];
let result = beta_simd(&a.view(), &b.view());
assert!((result[0] - 1.0).abs() < 1e-10); // B(1,1) = 1
assert!((result[1] - 1.0/6.0).abs() < 1e-10); // B(2,2) = 1/6
assert!((result[2] - std::f64::consts::PI).abs() < 1e-8); // B(0.5,0.5) = π§Applications
- Beta Distribution: PDF = x^(a-1)(1-x)^(b-1) / B(a,b)
- Bayesian Statistics: Prior/posterior for probability parameters
- A/B Testing: Conversion rate analysis
- Machine Learning: Dirichlet processes, topic modeling