Skip to content

Commit 8f1e559

Browse files
committed
Auto-generated commit
1 parent 1263742 commit 8f1e559

File tree

18 files changed

+1290
-4
lines changed

18 files changed

+1290
-4
lines changed

CHANGELOG.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,40 @@ This release closes the following issue:
180180

181181
<!-- /.package -->
182182

183+
<section class="package" id="stats-base-dists-bernoulli-mode-unreleased">
184+
185+
#### [@stdlib/stats/base/dists/bernoulli/mode](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/bernoulli/mode)
186+
187+
<details>
188+
189+
<section class="features">
190+
191+
##### Features
192+
193+
- [`06258f9`](https://github.com/stdlib-js/stdlib/commit/06258f9815f711fe5154458220c3f381d9b9134c) - add C implementation for `stats/base/dists/bernoulli/mode` [(#3450)](https://github.com/stdlib-js/stdlib/pull/3450)
194+
195+
</section>
196+
197+
<!-- /.features -->
198+
199+
<section class="issues">
200+
201+
##### Closed Issues
202+
203+
This release closes the following issue:
204+
205+
[#3417](https://github.com/stdlib-js/stdlib/issues/3417)
206+
207+
</section>
208+
209+
<!-- /.issues -->
210+
211+
</details>
212+
213+
</section>
214+
215+
<!-- /.package -->
216+
183217
<section class="package" id="stats-base-dists-beta-stdev-unreleased">
184218

185219
#### [@stdlib/stats/base/dists/beta/stdev](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/beta/stdev)
@@ -536,9 +570,9 @@ A total of 3 issues were closed in this release:
536570

537571
### Closed Issues
538572

539-
A total of 17 issues were closed in this release:
573+
A total of 18 issues were closed in this release:
540574

541-
[#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), [#3378](https://github.com/stdlib-js/stdlib/issues/3378), [#3384](https://github.com/stdlib-js/stdlib/issues/3384), [#3385](https://github.com/stdlib-js/stdlib/issues/3385), [#3401](https://github.com/stdlib-js/stdlib/issues/3401), [#3414](https://github.com/stdlib-js/stdlib/issues/3414), [#3435](https://github.com/stdlib-js/stdlib/issues/3435), [#3438](https://github.com/stdlib-js/stdlib/issues/3438), [#3445](https://github.com/stdlib-js/stdlib/issues/3445), [#3446](https://github.com/stdlib-js/stdlib/issues/3446), [#3447](https://github.com/stdlib-js/stdlib/issues/3447), [#3671](https://github.com/stdlib-js/stdlib/issues/3671)
575+
[#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), [#3378](https://github.com/stdlib-js/stdlib/issues/3378), [#3384](https://github.com/stdlib-js/stdlib/issues/3384), [#3385](https://github.com/stdlib-js/stdlib/issues/3385), [#3401](https://github.com/stdlib-js/stdlib/issues/3401), [#3414](https://github.com/stdlib-js/stdlib/issues/3414), [#3417](https://github.com/stdlib-js/stdlib/issues/3417), [#3435](https://github.com/stdlib-js/stdlib/issues/3435), [#3438](https://github.com/stdlib-js/stdlib/issues/3438), [#3445](https://github.com/stdlib-js/stdlib/issues/3445), [#3446](https://github.com/stdlib-js/stdlib/issues/3446), [#3447](https://github.com/stdlib-js/stdlib/issues/3447), [#3671](https://github.com/stdlib-js/stdlib/issues/3671)
542576

543577
</section>
544578

@@ -571,6 +605,7 @@ A total of 10 people contributed to this release. Thank you to the following con
571605

572606
<details>
573607

608+
- [`06258f9`](https://github.com/stdlib-js/stdlib/commit/06258f9815f711fe5154458220c3f381d9b9134c) - **feat:** add C implementation for `stats/base/dists/bernoulli/mode` [(#3450)](https://github.com/stdlib-js/stdlib/pull/3450) _(by Vivek maurya, Philipp Burckhardt, stdlib-bot)_
574609
- [`12a3dbf`](https://github.com/stdlib-js/stdlib/commit/12a3dbf094bb89c50ea468b9c75789124940b510) - **feat:** add C implementation for `@stdlib/stats/base/dists/beta/stdev` [(#3909)](https://github.com/stdlib-js/stdlib/pull/3909) _(by Vivek maurya, Vivek Maurya)_
575610
- [`1a98e92`](https://github.com/stdlib-js/stdlib/commit/1a98e9262d48a49dde1925c2a1d501511d795f05) - **feat:** add C implementation for `stats/base/dists/betaprime/kurtosis` [(#3459)](https://github.com/stdlib-js/stdlib/pull/3459) _(by Aayush Khanna, Philipp Burckhardt, stdlib-bot)_
576611
- [`c77a433`](https://github.com/stdlib-js/stdlib/commit/c77a433d6e33ad5f4879d32211d8cfdb4e5fa2c6) - **feat:** add C implementation for `stats/base/dists/betaprime/variance` [(#3460)](https://github.com/stdlib-js/stdlib/pull/3460) _(by Aayush Khanna, Philipp Burckhardt, stdlib-bot)_

base/dists/bernoulli/mode/README.md

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

138138
<!-- /.references -->
139139

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

142229
<section class="related">

base/dists/bernoulli/mode/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 pkg = require( './../package.json' ).name;
@@ -30,14 +31,20 @@ var mode = require( './../lib' );
3031
// MAIN //
3132

3233
bench( pkg, function benchmark( b ) {
34+
var len;
3335
var p;
3436
var y;
3537
var i;
3638

39+
len = 100;
40+
p = new Float64Array( len );
41+
for ( i = 0; i < len; i++ ) {
42+
p[ i ] = randu();
43+
}
44+
3745
b.tic();
3846
for ( i = 0; i < b.iterations; i++ ) {
39-
p = randu();
40-
y = mode( p );
47+
y = mode( p[ i%len ] );
4148
if ( isnan( y ) ) {
4249
b.fail( 'should not return NaN' );
4350
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 isnan = require( '@stdlib/math/base/assert/is-nan' );
28+
var tryRequire = require( '@stdlib/utils/try-require' );
29+
var pkg = require( './../package.json' ).name;
30+
31+
32+
// VARIABLES //
33+
34+
var mode = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( mode instanceof Error )
37+
};
38+
39+
40+
// MAIN //
41+
42+
bench( pkg+'::native', opts, function benchmark( b ) {
43+
var len;
44+
var p;
45+
var y;
46+
var i;
47+
48+
len = 100;
49+
p = new Float64Array( len );
50+
for ( i = 0; i < len; i++ ) {
51+
p[ i ] = randu();
52+
}
53+
54+
b.tic();
55+
for ( i = 0; i < b.iterations; i++ ) {
56+
y = mode( p[ i % len ] );
57+
if ( isnan( y ) ) {
58+
b.fail( 'should not return NaN' );
59+
}
60+
}
61+
b.toc();
62+
if ( isnan( y ) ) {
63+
b.fail( 'should not return NaN' );
64+
}
65+
b.pass( 'benchmark finished' );
66+
b.end();
67+
});

0 commit comments

Comments
 (0)