Skip to content

Commit 75347e3

Browse files
committed
Auto-generated commit
1 parent 1e1c34a commit 75347e3

File tree

18 files changed

+1300
-6
lines changed

18 files changed

+1300
-6
lines changed

CHANGELOG.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-12-13)
7+
## Unreleased (2024-12-14)
88

99
<section class="packages">
1010

@@ -78,6 +78,40 @@ This release closes the following issue:
7878

7979
<!-- /.package -->
8080

81+
<section class="package" id="stats-base-dists-bernoulli-mean-unreleased">
82+
83+
#### [@stdlib/stats/base/dists/bernoulli/mean](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/bernoulli/mean)
84+
85+
<details>
86+
87+
<section class="features">
88+
89+
##### Features
90+
91+
- [`5019fab`](https://github.com/stdlib-js/stdlib/commit/5019fab885f33507350e6b7ec6a61e1e283d6249) - add C implementation for `stats/base/dists/bernoulli/mean` [(#3451)](https://github.com/stdlib-js/stdlib/pull/3451)
92+
93+
</section>
94+
95+
<!-- /.features -->
96+
97+
<section class="issues">
98+
99+
##### Closed Issues
100+
101+
This release closes the following issue:
102+
103+
[#3414](https://github.com/stdlib-js/stdlib/issues/3414)
104+
105+
</section>
106+
107+
<!-- /.issues -->
108+
109+
</details>
110+
111+
</section>
112+
113+
<!-- /.package -->
114+
81115
<section class="package" id="stats-base-dists-betaprime-stdev-unreleased">
82116

83117
#### [@stdlib/stats/base/dists/betaprime/stdev](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/betaprime/stdev)
@@ -264,9 +298,9 @@ A total of 3 issues were closed in this release:
264298

265299
### Closed Issues
266300

267-
A total of 9 issues were closed in this release:
301+
A total of 10 issues were closed in this release:
268302

269-
[#1619](https://github.com/stdlib-js/stdlib/issues/1619), [#1632](https://github.com/stdlib-js/stdlib/issues/1632), [#1633](https://github.com/stdlib-js/stdlib/issues/1633), [#3236](https://github.com/stdlib-js/stdlib/issues/3236), [#3237](https://github.com/stdlib-js/stdlib/issues/3237), [#3238](https://github.com/stdlib-js/stdlib/issues/3238), [#3384](https://github.com/stdlib-js/stdlib/issues/3384), [#3401](https://github.com/stdlib-js/stdlib/issues/3401), [#3446](https://github.com/stdlib-js/stdlib/issues/3446)
303+
[#1619](https://github.com/stdlib-js/stdlib/issues/1619), [#1632](https://github.com/stdlib-js/stdlib/issues/1632), [#1633](https://github.com/stdlib-js/stdlib/issues/1633), [#3236](https://github.com/stdlib-js/stdlib/issues/3236), [#3237](https://github.com/stdlib-js/stdlib/issues/3237), [#3238](https://github.com/stdlib-js/stdlib/issues/3238), [#3384](https://github.com/stdlib-js/stdlib/issues/3384), [#3401](https://github.com/stdlib-js/stdlib/issues/3401), [#3414](https://github.com/stdlib-js/stdlib/issues/3414), [#3446](https://github.com/stdlib-js/stdlib/issues/3446)
270304

271305
</section>
272306

@@ -276,7 +310,7 @@ A total of 9 issues were closed in this release:
276310

277311
### Contributors
278312

279-
A total of 8 people contributed to this release. Thank you to the following contributors:
313+
A total of 9 people contributed to this release. Thank you to the following contributors:
280314

281315
- Aayush Khanna
282316
- Athan Reines
@@ -286,6 +320,7 @@ A total of 8 people contributed to this release. Thank you to the following cont
286320
- Pratyush Kumar Chouhan
287321
- Ruthwik Chikoti
288322
- Vinit Pandit
323+
- Vivek maurya
289324

290325
</section>
291326

@@ -297,6 +332,7 @@ A total of 8 people contributed to this release. Thank you to the following cont
297332

298333
<details>
299334

335+
- [`5019fab`](https://github.com/stdlib-js/stdlib/commit/5019fab885f33507350e6b7ec6a61e1e283d6249) - **feat:** add C implementation for `stats/base/dists/bernoulli/mean` [(#3451)](https://github.com/stdlib-js/stdlib/pull/3451) _(by Vivek maurya, Athan Reines, stdlib-bot)_
300336
- [`be1e1c4`](https://github.com/stdlib-js/stdlib/commit/be1e1c4a2e5d9a1e0ebc0e2f0a4244c50d4142c5) - **bench:** fix missing namespace _(by Athan Reines)_
301337
- [`d1a200b`](https://github.com/stdlib-js/stdlib/commit/d1a200bc6ab344f9fcd8a33a70712456dbf479d0) - **feat:** add C implementation for `stats/base/dists/betaprime/stdev` [(#3461)](https://github.com/stdlib-js/stdlib/pull/3461) _(by Aayush Khanna, Philipp Burckhardt, stdlib-bot)_
302338
- [`cf7d38a`](https://github.com/stdlib-js/stdlib/commit/cf7d38ae3e7bce92cf47778f7b1c3da731121d77) - **docs:** update related packages sections [(#3527)](https://github.com/stdlib-js/stdlib/pull/3527) _(by stdlib-bot)_

base/dists/bernoulli/mean/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,93 @@ for ( i = 0; i < 10; i++ ) {
130130

131131
<!-- /.references -->
132132

133+
<!-- C interface documentation. -->
134+
135+
* * *
136+
137+
<section class="c">
138+
139+
## C APIs
140+
141+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
142+
143+
<section class="intro">
144+
145+
</section>
146+
147+
<!-- /.intro -->
148+
149+
<!-- C usage documentation. -->
150+
151+
<section class="usage">
152+
153+
### Usage
154+
155+
```c
156+
#include "stdlib/stats/base/dists/bernoulli/mean.h"
157+
```
158+
159+
#### stdlib_base_dists_bernoulli_mean( p )
160+
161+
Returns the [expected value][expected-value] of a [Bernoulli][bernoulli-distribution] distribution with success probability `p`.
162+
163+
```c
164+
double out = stdlib_base_dists_bernoulli_mean( 0.1 );
165+
// returns 0.1
166+
```
167+
168+
The function accepts the following arguments:
169+
170+
- **p**: `[in] double` success probability.
171+
172+
```c
173+
double stdlib_base_dists_bernoulli_mean( const double p );
174+
```
175+
176+
</section>
177+
178+
<!-- /.usage -->
179+
180+
<!-- C API usage notes. Make sure to keep an empty line after the `section`
181+
element and another before the `/section` close. -->
182+
183+
<section class="notes">
184+
185+
</section>
186+
187+
<!-- /.notes -->
188+
189+
<!-- C API usage examples. -->
190+
191+
<section class="examples">
192+
193+
### Examples
194+
195+
```c
196+
#include "stdlib/stats/base/dists/bernoulli/mean.h"
197+
#include <stdlib.h>
198+
#include <stdio.h>
199+
200+
int main( void ) {
201+
double p;
202+
double y;
203+
int i;
204+
for ( i = 0; i < 25; i++ ) {
205+
p = (double)rand() / ( (double)RAND_MAX + 1.0 );
206+
y = stdlib_base_dists_bernoulli_mean( p );
207+
printf( "x: %lf, E(X;p): %lf\n", p, y );
208+
}
209+
}
210+
```
211+
212+
</section>
213+
214+
<!-- /.examples -->
215+
216+
</section>
217+
218+
<!-- /.c -->
219+
133220
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
134221

135222
<section class="related">

base/dists/bernoulli/mean/benchmark/benchmark.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24+
var Float64Array = require( '@stdlib/array/float64' );
2425
var randu = require( '@stdlib/random/base/randu' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2627
var EPS = require( '@stdlib/constants/float64/eps' );
@@ -31,14 +32,20 @@ var mean = require( './../lib' );
3132
// MAIN //
3233

3334
bench( pkg, function benchmark( b ) {
35+
var len;
3436
var p;
3537
var y;
3638
var i;
3739

40+
len = 100;
41+
p = new Float64Array( len );
42+
for ( i = 0; i < len; i++ ) {
43+
p[ i ] = ( randu()*1.0 ) + EPS;
44+
}
45+
3846
b.tic();
3947
for ( i = 0; i < b.iterations; i++ ) {
40-
p = ( randu()*1.0 ) + EPS;
41-
y = mean( p );
48+
y = mean( p[ i%len ] );
4249
if ( isnan( y ) ) {
4350
b.fail( 'should not return NaN' );
4451
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var Float64Array = require( '@stdlib/array/float64' );
26+
var randu = require( '@stdlib/random/base/randu' );
27+
var EPS = require( '@stdlib/constants/float64/eps' );
28+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
30+
var pkg = require( './../package.json' ).name;
31+
32+
33+
// VARIABLES //
34+
35+
var mean = tryRequire( resolve( __dirname, './../lib/native.js' ) );
36+
var opts = {
37+
'skip': ( mean instanceof Error )
38+
};
39+
40+
41+
// MAIN //
42+
43+
bench( pkg+'::native', opts, function benchmark( b ) {
44+
var len;
45+
var p;
46+
var y;
47+
var i;
48+
49+
len = 100;
50+
p = new Float64Array( len );
51+
for ( i = 0; i < len; i++ ) {
52+
p[ i ] = ( randu()*1.0 ) + EPS;
53+
}
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
y = mean( p[ i % len ] );
58+
if ( isnan( y ) ) {
59+
b.fail( 'should not return NaN' );
60+
}
61+
}
62+
b.toc();
63+
if ( isnan( y ) ) {
64+
b.fail( 'should not return NaN' );
65+
}
66+
b.pass( 'benchmark finished' );
67+
b.end();
68+
});

0 commit comments

Comments
 (0)