math-utils
Mathematical functions and statistics for PascalAI. Clamp, interpolate, compute means and standard deviations, and work with number theory.
Install
ppm install math-utils
Usage Example
uses math_utils;
// Clamping and interpolation
var v := Clamp(150.0, 0.0, 100.0); // 100.0
var t := Lerp(0.0, 10.0, 0.5); // 5.0
// Statistics
var data := [1.0, 2.0, 3.0, 4.0, 5.0];
var avg := Mean(data); // 3.0
var sd := StdDev(data); // ~1.41
var med := Median(data); // 3.0
// Number theory
var f := Factorial(10); // 3628800
var b := Fibonacci(10); // 55
if IsPrime(17) then
WriteLn('17 is prime');
Features
Clamp: constrain a value to a min/max range
Lerp: linear interpolation between two values
Mean, Median, StdDev: descriptive statistics on arrays
Factorial and Fibonacci sequence computation
IsPrime primality testing
GCD and LCM for integer arithmetic
Log2, Log10, and natural logarithm helpers