mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user