diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c181c7..db6f8fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,29 @@
-## Unreleased (2025-01-21) +## Unreleased (2025-02-08) + +
+ +### Features + +- [`95dd2ff`](https://github.com/stdlib-js/stdlib/commit/95dd2ffb02ddeb98f100d73cdb017264905dd3a4) - add C implementation for `stats/base/dists/binomial/mean` [(#3681)](https://github.com/stdlib-js/stdlib/pull/3681) + +
+ + + +
+ +### Closed Issues + +This release closes the following issue: + +[#3469](https://github.com/stdlib-js/stdlib/issues/3469) + +
+ +
@@ -12,6 +34,7 @@
+- [`95dd2ff`](https://github.com/stdlib-js/stdlib/commit/95dd2ffb02ddeb98f100d73cdb017264905dd3a4) - **feat:** add C implementation for `stats/base/dists/binomial/mean` [(#3681)](https://github.com/stdlib-js/stdlib/pull/3681) _(by Prashant Kumar Yadav, Philipp Burckhardt)_ - [`af55f0d`](https://github.com/stdlib-js/stdlib/commit/af55f0d6d6b4d06c36f46357740ea89a4639ab5b) - **bench:** refactor random number generation in `stats/base/dists/binomial` [(#4841)](https://github.com/stdlib-js/stdlib/pull/4841) _(by Karan Anand)_
@@ -24,9 +47,11 @@ ### Contributors -A total of 1 person contributed to this release. Thank you to this contributor: +A total of 3 people contributed to this release. Thank you to the following contributors: - Karan Anand +- Philipp Burckhardt +- Prashant Kumar Yadav
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index aedb148..bbccf30 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -63,6 +63,7 @@ Marcus Fantham Matt Cochrane Mihir Pandit <129577900+MSP20086@users.noreply.github.com> Milan Raj +Mohammad Bin Aftab <48010758+MohammadBinAftab@users.noreply.github.com> Mohammad Kaif Momtchil Momtchev Muhammad Haris @@ -125,5 +126,6 @@ Xiaochuan Ye Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com> Yernar Yergaziyev olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com> +pranav-1720 <123018993+pranav-1720@users.noreply.github.com> rainn <88160429+AmCodesLame@users.noreply.github.com> rei2hu diff --git a/README.md b/README.md index 55aef37..c266c93 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,103 @@ for ( i = 0; i < 10; i++ ) { + + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/binomial/mean.h" +``` + +#### stdlib_base_dists_binomial_mean( n, p ) + +Returns the [expected value][expected-value] of a [binomial][binomial-distribution] distribution with number of trials `n` and success probability `p`. + +```c +double out = stdlib_base_dists_binomial_mean( 100, 0.1 ); +// returns 10.0 +``` + +The function accepts the following arguments: + +- **n**: `[in] int32_t` number of trials. +- **p**: `[in] double` success probability. + +```c +double stdlib_base_dists_binomial_mean( const int32_t n, const double p ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/binomial/mean.h" +#include "stdlib/math/base/special/ceil.h" +#include +#include +#include + +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * (max - min) ); +} + +int main( void ) { + int32_t n; + double p; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + n = stdlib_base_ceil( random_uniform( 0.0, 100.0 ) ); + p = random_uniform( 0.0, 1.0 ); + y = stdlib_base_dists_binomial_mean( n, p ); + printf( "n: %d, p: %lf, E(X;n,p): %lf\n", n, p, y ); + } + + return 0; +} +``` + +
+ + + +
+ + +