Skip to content

Commit 4ed44b1

Browse files
committed
Auto-generated commit
1 parent 7efa93c commit 4ed44b1

File tree

22 files changed

+1351
-29
lines changed

22 files changed

+1351
-29
lines changed

CHANGELOG.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,37 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-03-22)
7+
## Unreleased (2025-04-24)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`0a6c344`](https://github.com/stdlib-js/stdlib/commit/0a6c344b6922ed9d12900074f01c88aaf58855f1) - add C implementation for `stats/base/dists/bernoulli/mgf` [(#3981)](https://github.com/stdlib-js/stdlib/pull/3981)
14+
15+
</section>
16+
17+
<!-- /.features -->
18+
19+
<section class="issues">
20+
21+
### Closed Issues
22+
23+
This release closes the following issue:
24+
25+
[#3416](https://github.com/stdlib-js/stdlib/issues/3416)
26+
27+
</section>
28+
29+
<!-- /.issues -->
830

931
<section class="commits">
1032

1133
### Commits
1234

1335
<details>
1436

37+
- [`0a6c344`](https://github.com/stdlib-js/stdlib/commit/0a6c344b6922ed9d12900074f01c88aaf58855f1) - **feat:** add C implementation for `stats/base/dists/bernoulli/mgf` [(#3981)](https://github.com/stdlib-js/stdlib/pull/3981) _(by Neeraj Pathak, stdlib-bot)_
1538
- [`975de6a`](https://github.com/stdlib-js/stdlib/commit/975de6ac8cf9349a047a39921ddf3f29a9b0d77e) - **docs:** replace manual `for` loop in examples [(#6280)](https://github.com/stdlib-js/stdlib/pull/6280) _(by Karan Anand)_
1639
- [`802775e`](https://github.com/stdlib-js/stdlib/commit/802775ea028fb2a42041611187b6373b49f5f397) - **bench:** refactor random number generation in `stats/base/dists/bernoulli` [(#4775)](https://github.com/stdlib-js/stdlib/pull/4775) _(by Karan Anand, Athan Reines)_
1740

@@ -25,10 +48,11 @@
2548

2649
### Contributors
2750

28-
A total of 2 people contributed to this release. Thank you to the following contributors:
51+
A total of 3 people contributed to this release. Thank you to the following contributors:
2952

3053
- Athan Reines
3154
- Karan Anand
55+
- Neeraj Pathak
3256

3357
</section>
3458

CONTRIBUTORS

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Contributors listed in alphabetical order.
44

55
Aadish Jain <jain.aadishj@gmail.com>
6+
Aarya Balwadkar <142713127+AaryaBalwadkar@users.noreply.github.com>
67
Aayush Khanna <aayushiitbhu23@gmail.com>
78
Abdelrahman Samir <60700731+abdelrahman04@users.noreply.github.com>
89
Abdul Kaium <97376242+impawstarlight@users.noreply.github.com>
@@ -42,13 +43,15 @@ Dev Goel <135586571+corsairier@users.noreply.github.com>
4243
Dhanyabad behera <110620935+dhanyabad11@users.noreply.github.com>
4344
Dhruv Arvind Singh <154677013+DhruvArvindSingh@users.noreply.github.com>
4445
Dhruvil Mehta <68022411+dhruvilmehta@users.noreply.github.com>
46+
Dipjyoti Das <126075231+dipexplorer@users.noreply.github.com>
4547
Divyansh Seth <59174836+sethdivyansh@users.noreply.github.com>
4648
Dominic Lim <46486515+domlimm@users.noreply.github.com>
4749
Dominik Moritz <domoritz@gmail.com>
4850
Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
4951
EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com>
5052
Frank Kovacs <fran70kk@gmail.com>
5153
GK Bishnoi <gkishan1kyt@gmail.com>
54+
GURU PRASAD SHARMA <168292003+GURUPRASADSHARMA@users.noreply.github.com>
5255
Gaurav <gaurav70380@gmail.com>
5356
Gautam sharma <gautamkrishnasharma1@gmail.com>
5457
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
@@ -74,15 +77,18 @@ Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
7477
Joris Labie <joris.labie1@gmail.com>
7578
Justin Dennison <justin1dennison@gmail.com>
7679
Justyn Shelby <96994781+ShelbyJustyn@users.noreply.github.com>
77-
Karan Anand <119553199+anandkaranubc@users.noreply.github.com>
80+
Karan Anand <anandkarancompsci@gmail.com>
81+
Karan Yadav <77043443+karanBRAVO@users.noreply.github.com>
7882
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
7983
Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com>
84+
Kavyansh-Bagdi <153486713+Kavyansh-Bagdi@users.noreply.github.com>
8085
Kohantika Nath <145763549+kohantikanath@users.noreply.github.com>
8186
Krishnam Agarwal <83017176+888krishnam@users.noreply.github.com>
8287
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
8388
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
8489
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
8590
MANI <77221000+Eternity0207@users.noreply.github.com>
91+
Mahfuza Humayra Mohona <mhmohona@gmail.com>
8692
Manik Sharma <maniksharma.rke@gmail.com>
8793
Manvith M <148960168+manvith2003@users.noreply.github.com>
8894
Marcus Fantham <mfantham@users.noreply.github.com>
@@ -93,23 +99,30 @@ Mohammad Bin Aftab <48010758+MohammadBinAftab@users.noreply.github.com>
9399
Mohammad Kaif <mdkaifprofession@gmail.com>
94100
Momtchil Momtchev <momtchil@momtchev.com>
95101
Muhammad Haris <harriskhan047@outlook.com>
102+
Muhammad Taaha Tariq <166188821+Taaha-Tariq@users.noreply.github.com>
103+
Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com>
96104
Naresh Jagadeesan <naresh.naresh000@gmail.com>
97105
Naveen Kumar <stupiddint@gmail.com>
98106
Neeraj Pathak <neerajrpathak710@gmail.com>
107+
NirvedMishra <139633597+NirvedMishra@users.noreply.github.com>
99108
Nishant Shinde <97207366+nishant-s7@users.noreply.github.com>
109+
Nishant singh <38534128+Nishantsingh11@users.noreply.github.com>
100110
Nishchay Rajput <121144841+NishchayRajput@users.noreply.github.com>
101111
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
102112
Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com>
103113
Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
104114
Oneday12323 <107678750+Oneday12323@users.noreply.github.com>
105115
Ori Miles <97595296+orimiles5@users.noreply.github.com>
106116
Philipp Burckhardt <pburckhardt@outlook.com>
117+
Prajjwal Bajpai <142303989+prajjwalbajpai@users.noreply.github.com>
107118
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
108119
Pranav Goswami <pranavchiku11@gmail.com>
109120
Pranjal Jha <97080887+PraneGIT@users.noreply.github.com>
110121
Prashant Kumar Yadav <144602492+0PrashantYadav0@users.noreply.github.com>
122+
PrathamBhamare <164445568+PrathamBhamare@users.noreply.github.com>
111123
Pratik Singh <97464067+Pratik772846@users.noreply.github.com>
112124
Pratyush Kumar Chouhan <pratyushkumar0308@gmail.com>
125+
Pravesh Kunwar <praveshkunwar04@gmail.com>
113126
Priyansh Prajapati <88396544+itsspriyansh@users.noreply.github.com>
114127
Priyanshu Agarwal <113460573+AgPriyanshu18@users.noreply.github.com>
115128
Pulkit Gupta <65711278+pulkitgupta2@users.noreply.github.com>
@@ -123,11 +136,15 @@ Rishav <115060907+rishav2404@users.noreply.github.com>
123136
Rishav Tarway <rishavtarway@gmail.com>
124137
Robert Gislason <gztown2216@yahoo.com>
125138
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
139+
Rupa <102663541+Rupa-Rd@users.noreply.github.com>
126140
Rutam Kathale <138517416+performant23@users.noreply.github.com>
127141
Ruthwik Chikoti <145591715+ruthwikchikoti@users.noreply.github.com>
128142
Ryan Seal <splrk@users.noreply.github.com>
129143
Rylan Yang <137365285+rylany27@users.noreply.github.com>
144+
SAHIL KUMAR <168997976+sahilk45@users.noreply.github.com>
130145
SHIVAM YADAV <120725381+Shivam-1827@users.noreply.github.com>
146+
Sahil Goyal <87982509+sahil20021008@users.noreply.github.com>
147+
Sai Avinash <120403424+nasarobot@users.noreply.github.com>
131148
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
132149
Sanchay Ketan Sinha <122982233+satansin123@users.noreply.github.com>
133150
Sarthak Paandey <145528240+SarthakPaandey@users.noreply.github.com>
@@ -162,9 +179,12 @@ Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
162179
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
163180
Yugal Kaushik <yugalkaushik14@gmail.com>
164181
Yuvi Mittal <128018763+yuvi-mittal@users.noreply.github.com>
182+
devshree-bhati <147095250+devshree-bhati@users.noreply.github.com>
165183
ditsu <170345142+ditsus@users.noreply.github.com>
166184
ekambains <bainsinbusiness@gmail.com>
167185
fadiothman22 <48636283+fadiothman22@users.noreply.github.com>
186+
iraandrushko <71790513+iraandrushko@users.noreply.github.com>
187+
lohithganni <116790357+lohithganni@users.noreply.github.com>
168188
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
169189
pranav-1720 <123018993+pranav-1720@users.noreply.github.com>
170190
rahulrangers <127782777+rahulrangers@users.noreply.github.com>

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,101 @@ logEachMap( 't: %0.4f, p: %0.4f, M_X(t;p): %0.4f', t, p, mgf );
170170

171171
<!-- /.examples -->
172172

173+
<!-- C interface documentation. -->
174+
175+
* * *
176+
177+
<section class="c">
178+
179+
## C APIs
180+
181+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
182+
183+
<section class="intro">
184+
185+
</section>
186+
187+
<!-- /.intro -->
188+
189+
<!-- C usage documentation. -->
190+
191+
<section class="usage">
192+
193+
### Usage
194+
195+
```c
196+
#include "stdlib/stats/base/dists/bernoulli/mgf.h"
197+
```
198+
199+
#### stdlib_base_dists_bernoulli_mgf( t, p )
200+
201+
Evaluates the moment-generating function ([MGF][mgf]) of a [Bernoulli][bernoulli-distribution] distribution with success probability `p`.
202+
203+
```c
204+
double y = stdlib_base_dists_bernoulli_mgf( 0.2, 0.5 );
205+
// returns ~1.111
206+
```
207+
208+
The function accepts the following arguments:
209+
210+
- **t**: `[in] double` input value.
211+
- **p**: `[in] double` success probability.
212+
213+
```c
214+
double stdlib_base_dists_bernoulli_mgf( const double t, const double p );
215+
```
216+
217+
</section>
218+
219+
<!-- /.usage -->
220+
221+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
222+
223+
<section class="notes">
224+
225+
</section>
226+
227+
<!-- /.notes -->
228+
229+
<!-- C API usage examples. -->
230+
231+
<section class="examples">
232+
233+
### Examples
234+
235+
```c
236+
#include "stdlib/stats/base/dists/bernoulli/mgf.h"
237+
#include <stdlib.h>
238+
#include <stdio.h>
239+
240+
static double random_uniform( const double min, const double max ) {
241+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
242+
return min + ( v*(max-min) );
243+
}
244+
245+
int main( void ) {
246+
double p;
247+
double t;
248+
double y;
249+
int i;
250+
251+
for ( i = 0; i < 10; i++ ) {
252+
t = random_uniform( -2.0, 2.0 );
253+
p = random_uniform( 0.0, 1.0 );
254+
y = stdlib_base_dists_bernoulli_mgf( t, p );
255+
printf( "t: %lf, p: %lf, M_X(t;p): %lf\n", t, p, y );
256+
}
257+
}
258+
```
259+
260+
</section>
261+
262+
<!-- /.examples -->
263+
264+
</section>
265+
266+
<!-- /.c -->
267+
173268
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
174269

175270
<section class="references">

benchmark/benchmark.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench-harness' );
24-
var Float64Array = require( '@stdlib/array-float64' );
2524
var uniform = require( '@stdlib/random-base-uniform' );
25+
var Float64Array = require( '@stdlib/array-float64' );
2626
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2727
var pkg = require( './../package.json' ).name;
2828
var mgf = require( './../lib' );
@@ -38,11 +38,11 @@ bench( pkg, function benchmark( b ) {
3838
var i;
3939

4040
len = 100;
41-
p = new Float64Array( len );
4241
t = new Float64Array( len );
42+
p = new Float64Array( len );
4343
for ( i = 0; i < len; i++ ) {
44-
p[ i ] = uniform( 0.0, 1.0 );
4544
t[ i ] = uniform( 0.0, 3.0 );
45+
p[ i ] = uniform( 0.0, 1.0 );
4646
}
4747

4848
b.tic();
@@ -70,6 +70,7 @@ bench( pkg+':factory', function benchmark( b ) {
7070

7171
p = 0.3;
7272
mymgf = mgf.factory( p );
73+
7374
len = 100;
7475
t = new Float64Array( len );
7576
for ( i = 0; i < len; i++ ) {

benchmark/benchmark.native.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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-harness' );
25+
var uniform = require( '@stdlib/random-base-uniform' );
26+
var Float64Array = require( '@stdlib/array-float64' );
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 mgf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( mgf instanceof Error )
37+
};
38+
39+
40+
// MAIN //
41+
42+
bench( pkg+'::native', opts, function benchmark( b ) {
43+
var len;
44+
var p;
45+
var t;
46+
var y;
47+
var i;
48+
49+
len = 100;
50+
t = new Float64Array( len );
51+
p = new Float64Array( len );
52+
for ( i = 0; i < len; i++ ) {
53+
t[ i ] = uniform( 0.0, 3.0 );
54+
p[ i ] = uniform( 0.0, 1.0 );
55+
}
56+
57+
b.tic();
58+
for ( i = 0; i < b.iterations; i++ ) {
59+
y = mgf( t[ i % len ], p[ i % len ] );
60+
if ( isnan( y ) ) {
61+
b.fail( 'should not return NaN' );
62+
}
63+
}
64+
b.toc();
65+
if ( isnan( y ) ) {
66+
b.fail( 'should not return NaN' );
67+
}
68+
b.pass( 'benchmark finished' );
69+
b.end();
70+
});

0 commit comments

Comments
 (0)