math: implement discrete and continuous distributions (#2955)

* math: implement discrete and continuous distributions

Implement a comprehensive set of continuous and discrete probability
distributions with support for PDF, CDF, inverse CDF, random sampling,
mean, and variance calculations.

The following distributions are implemented:
* Normal
* Uniform
* Exponential
* Chi-Squared
* F-Distribution
* Student t
* Binomial
* Poisson

* update releasenotes.md

* Formatting

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
konimarti
2026-02-19 20:09:11 +01:00
committed by GitHub
parent 6b3139940c
commit 8bb974829d
7 changed files with 1718 additions and 0 deletions

View File

@@ -124,6 +124,42 @@ macro sign(x)
$endif
}
<*
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro erf(x)
{
$if $typeof(x) == float:
return _erff(x);
$else
return _erf(x);
$endif
}
<*
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro tgamma(x)
{
$if $typeof(x) == float:
return _tgammaf(x);
$else
return _tgamma(x);
$endif
}
<*
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
*>
macro lgamma(x)
{
$if $typeof(x) == float:
return _lgammaf(x);
$else
return _lgamma(x);
$endif
}
<*
@require values::@is_int(x) || values::@is_float(x) : "Expected an integer or floating point value"
@require values::@is_int(y) || values::@is_float(y) : "Expected an integer or floating point value"
@@ -1088,6 +1124,14 @@ extern fn float _acoshf(float x) @MathLibc("acoshf");
extern fn float _asinhf(float x) @MathLibc("asinhf");
extern fn float _atanhf(float x) @MathLibc("atanhf");
extern fn double _erf(double x) @MathLibc("erf");
extern fn double _lgamma(double x) @MathLibc("lgamma");
extern fn double _tgamma(double x) @MathLibc("tgamma");
extern fn float _erff(float x) @MathLibc("erf");
extern fn float _lgammaf(float x) @MathLibc("lgammaf");
extern fn float _tgammaf(float x) @MathLibc("tgammaf");
fn double _frexp(double x, int* e)
{