Expand description
Utility functions for numerical operations
Constants§
- EPS
- Small epsilon for numerical stability
- EPS_F32
- Small epsilon for f32
- LOG_MAX
- Log of maximum positive f64
- LOG_MIN
- Log of minimum positive f64
Functions§
- argsort
- Argsort: returns indices that would sort the array
- clamp_
log - Clamp a log value to prevent overflow/underflow
- compute_
cdf - Compute cumulative distribution function values
- cosine_
similarity - Cosine similarity between two vectors
- dot
- Dot product of two vectors
- euclidean_
distance - Euclidean distance
- jensen_
shannon - Jensen-Shannon divergence
- kl_
divergence - KL divergence: D_KL(P || Q) = sum(P * log(P/Q))
- log_
softmax - Stable softmax in log domain
- log_
sum_ exp - Stable log-sum-exp: log(sum(exp(x_i)))
- norm
- Euclidean norm of a vector
- normalize
- Normalize a vector to unit length
- normalize_
mut - Normalize vector in place
- quantile_
sorted - Quantile of sorted data (0.0 to 1.0)
- safe_
exp - Safe exp that clamps input to prevent overflow
- safe_ln
- Safe log that returns LOG_MIN for non-positive values
- softmax
- Standard softmax with numerical stability
- sort_
with_ indices - Sort with indices: returns (sorted_data, original_indices)
- squared_
euclidean - Squared Euclidean distance
- symmetric_
kl - Symmetric KL divergence: (D_KL(P||Q) + D_KL(Q||P)) / 2
- weighted_
quantile - Weighted quantile