Skip to content

Commit d3eeca5

Browse files
committed
Auto-generated commit
1 parent 82709d9 commit d3eeca5

File tree

20 files changed

+1403
-15
lines changed

20 files changed

+1403
-15
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,63 @@
22

33
> Package changelog.
44
5+
<section class="release" id="unreleased">
6+
7+
## Unreleased (2024-12-15)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`bb09b18`](https://github.com/stdlib-js/stdlib/commit/bb09b185f74d2fc05254a2f164119ca05054887f) - add C implementation for `stats/base/dists/beta/variance` [(#3919)](https://github.com/stdlib-js/stdlib/pull/3919)
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+
[#3436](https://github.com/stdlib-js/stdlib/issues/3436)
26+
27+
</section>
28+
29+
<!-- /.issues -->
30+
31+
<section class="commits">
32+
33+
### Commits
34+
35+
<details>
36+
37+
- [`bb09b18`](https://github.com/stdlib-js/stdlib/commit/bb09b185f74d2fc05254a2f164119ca05054887f) - **feat:** add C implementation for `stats/base/dists/beta/variance` [(#3919)](https://github.com/stdlib-js/stdlib/pull/3919) _(by Vivek maurya, Philipp Burckhardt)_
38+
39+
</details>
40+
41+
</section>
42+
43+
<!-- /.commits -->
44+
45+
<section class="contributors">
46+
47+
### Contributors
48+
49+
A total of 2 people contributed to this release. Thank you to the following contributors:
50+
51+
- Philipp Burckhardt
52+
- Vivek maurya
53+
54+
</section>
55+
56+
<!-- /.contributors -->
57+
58+
</section>
59+
60+
<!-- /.release -->
61+
562
<section class="release" id="v0.2.2">
663

764
## 0.2.2 (2024-07-26)

CONTRIBUTORS

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Aayush Khanna <[email protected]>
66
Abhijit Raut <[email protected]>
77
Adarsh Palaskar <[email protected]>
88
Aditya Sapra <[email protected]>
9-
AgPriyanshu18 <[email protected]>
9+
Ahmed Atwa <[email protected]>
10+
Ahmed Kashkoush <[email protected]>
1011
Aleksandr <[email protected]>
1112
Ali Salesi <[email protected]>
1213
Aman Bhansali <[email protected]>
@@ -51,6 +52,7 @@ Krishnendu Das <[email protected]>
5152
Kshitij-Dale <[email protected]>
5253
5354
Manik Sharma <[email protected]>
55+
Manvith M <[email protected]>
5456
Marcus Fantham <[email protected]>
5557
Matt Cochrane <[email protected]>
5658
Mihir Pandit <[email protected]>
@@ -60,32 +62,34 @@ Momtchil Momtchev <[email protected]>
6062
Muhammad Haris <[email protected]>
6163
Naresh Jagadeesan <[email protected]>
6264
Neeraj Pathak <[email protected]>
63-
NightKnight <Ahmedatwa866@yahoo.com>
65+
Nishant Shinde <[email protected].com>
6466
Nithin Katta <[email protected]>
6567
Nourhan Hasan <[email protected]>
6668
Ognjen Jevremović <[email protected]>
6769
Oneday12323 <[email protected]>
70+
Ori Miles <[email protected]>
6871
Philipp Burckhardt <[email protected]>
6972
Prajwal Kulkarni <[email protected]>
7073
Pranav Goswami <[email protected]>
7174
7275
7376
Pratyush Kumar Chouhan <[email protected]>
7477
78+
Priyanshu Agarwal <[email protected]>
7579
Pushpendra Chandravanshi <[email protected]>
76-
7780
Raunak Kumar Gupta <[email protected]>
7881
Rejoan Sardar <[email protected]>
7982
Ricky Reusser <[email protected]>
8083
Ridam Garg <[email protected]>
84+
8185
Robert Gislason <[email protected]>
8286
Roman Stetsyk <[email protected]>
83-
87+
Rutam Kathale <[email protected]>
8488
Ruthwik Chikoti <[email protected]>
8589
Ryan Seal <[email protected]>
8690
Rylan Yang <[email protected]>
8791
Sai Srikar Dumpeti <[email protected]>
88-
SarthakPaandey <[email protected]>
92+
Sarthak Paandey <[email protected]>
8993
Saurabh Singh <[email protected]>
9094
Seyyed Parsa Neshaei <[email protected]>
9195
Shashank Shekhar Singh <[email protected]>
@@ -98,7 +102,7 @@ Snehil Shah <[email protected]>
98102
Soumajit Chatterjee <[email protected]>
99103
Spandan Barve <[email protected]>
100104
Stephannie Jiménez Gacha <[email protected]>
101-
Suraj kumar <[email protected]>
105+
Suraj Kumar <[email protected]>
102106
Tirtadwipa Manunggal <[email protected]>
103107
Tudor Pagu <[email protected]>
104108
Tufailahmed Bargir <[email protected]>
@@ -108,12 +112,11 @@ UtkershBasnet <[email protected]>
108112
Vaibhav Patel <[email protected]>
109113
Varad Gupta <[email protected]>
110114
Vinit Pandit <[email protected]>
115+
Vivek maurya <[email protected]>
111116
Xiaochuan Ye <[email protected]>
117+
Yaswanth Kosuru <[email protected]>
112118
Yernar Yergaziyev <[email protected]>
113119
114-
nishant-s7 <[email protected]>
115120
olenkabilonizhka <[email protected]>
116-
orimiles5 <[email protected]>
117121
118122
119-

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,101 @@ for ( i = 0; i < 10; i++ ) {
177177

178178
<!-- /.examples -->
179179

180+
<!-- C interface documentation. -->
181+
182+
* * *
183+
184+
<section class="c">
185+
186+
## C APIs
187+
188+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
189+
190+
<section class="intro">
191+
192+
</section>
193+
194+
<!-- /.intro -->
195+
196+
<!-- C usage documentation. -->
197+
198+
<section class="usage">
199+
200+
### Usage
201+
202+
```c
203+
#include "stdlib/stats/base/dists/beta/variance.h"
204+
```
205+
206+
#### stdlib_base_dists_beta_variance( alpha, beta )
207+
208+
Returns the [variance][variance] of a [beta][beta-distribution] distribution with parameters `alpha` (first shape parameter) and `beta` (second shape parameter).
209+
210+
```c
211+
double out = stdlib_base_dists_beta_variance( 1.0, 1.0 );
212+
// returns ~0.083
213+
```
214+
215+
The function accepts the following arguments:
216+
217+
- **alpha**: `[in] double` first shape parameter.
218+
- **beta**: `[in] double` second shape parameter.
219+
220+
```c
221+
double stdlib_base_dists_beta_variance( const double alpha, const double beta );
222+
```
223+
224+
</section>
225+
226+
<!-- /.usage -->
227+
228+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
229+
230+
<section class="notes">
231+
232+
</section>
233+
234+
<!-- /.notes -->
235+
236+
<!-- C API usage examples. -->
237+
238+
<section class="examples">
239+
240+
### Examples
241+
242+
```c
243+
#include "stdlib/stats/base/dists/beta/variance.h"
244+
#include "stdlib/constants/float64/eps.h"
245+
#include <stdlib.h>
246+
#include <stdio.h>
247+
248+
static double random_uniform( const double min, const double max ) {
249+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
250+
return min + ( v*(max-min) );
251+
}
252+
253+
int main( void ) {
254+
double alpha;
255+
double beta;
256+
double y;
257+
int i;
258+
for ( i = 0; i < 25; i++ ) {
259+
alpha = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
260+
beta = random_uniform( 0.0, 10.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
261+
y = stdlib_base_dists_beta_variance( alpha, beta );
262+
printf( "α: %lf, β: %lf, Var(X;α,β): %lf\n", alpha, beta, y );
263+
}
264+
}
265+
```
266+
267+
</section>
268+
269+
<!-- /.examples -->
270+
271+
</section>
272+
273+
<!-- /.c -->
274+
180275
<!-- 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. -->
181276

182277
<section class="references">

benchmark/benchmark.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var bench = require( '@stdlib/bench-harness' );
2424
var randu = require( '@stdlib/random-base-randu' );
25+
var Float64Array = require( '@stdlib/array-float64' );
2526
var isnan = require( '@stdlib/math-base-assert-is-nan' );
2627
var EPS = require( '@stdlib/constants-float64-eps' );
2728
var pkg = require( './../package.json' ).name;
@@ -33,14 +34,21 @@ var variance = require( './../lib' );
3334
bench( pkg, function benchmark( b ) {
3435
var alpha;
3536
var beta;
37+
var len;
3638
var y;
3739
var i;
3840

41+
len = 100;
42+
alpha = new Float64Array( len );
43+
beta = new Float64Array( len );
44+
for ( i = 0; i < len; i++ ) {
45+
alpha[ i ] = ( randu()*10.0 ) + EPS;
46+
beta[ i ] = ( randu()*10.0 ) + EPS;
47+
}
48+
3949
b.tic();
4050
for ( i = 0; i < b.iterations; i++ ) {
41-
alpha = ( randu()*10.0 ) + EPS;
42-
beta = ( randu()*10.0 ) + EPS;
43-
y = variance( alpha, beta );
51+
y = variance( alpha[ i % len ], beta[ i % len ] );
4452
if ( isnan( y ) ) {
4553
b.fail( 'should not return NaN' );
4654
}

benchmark/benchmark.native.js

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

0 commit comments

Comments
 (0)