Skip to content

Commit 84926e3

Browse files
committed
Auto-generated commit
1 parent 0456d60 commit 84926e3

File tree

22 files changed

+1321
-8
lines changed

22 files changed

+1321
-8
lines changed

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ indent_style = tab
8686
[*.{f,f.txt}]
8787
indent_style = space
8888
indent_size = 2
89-
insert_final_newline = false
9089

9190
# Set properties for shell files:
9291
[*.{sh,sh.txt}]

.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 (2025-01-19)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`ccaed30`](https://github.com/stdlib-js/stdlib/commit/ccaed309a4bfdc50b0c8f2c78f1ee4e365d51337) - add C implementation for `stats/base/dists/chisquare/variance` [(#3999)](https://github.com/stdlib-js/stdlib/pull/3999)
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+
[#3512](https://github.com/stdlib-js/stdlib/issues/3512)
26+
27+
</section>
28+
29+
<!-- /.issues -->
30+
31+
<section class="commits">
32+
33+
### Commits
34+
35+
<details>
36+
37+
- [`ccaed30`](https://github.com/stdlib-js/stdlib/commit/ccaed309a4bfdc50b0c8f2c78f1ee4e365d51337) - **feat:** add C implementation for `stats/base/dists/chisquare/variance` [(#3999)](https://github.com/stdlib-js/stdlib/pull/3999) _(by Vivek Maurya, Philipp Burckhardt, stdlib-bot)_
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-27)

CONTRIBUTORS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Daniel Killenberger <daniel.killenberger@gmail.com>
2727
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
2828
Debashis Maharana <debashismaharana7854@gmail.com>
2929
Desh Deepak Kant <118960904+DeshDeepakKant@users.noreply.github.com>
30+
Dev Goel <135586571+corsairier@users.noreply.github.com>
31+
Dhruv Arvind Singh <154677013+DhruvArvindSingh@users.noreply.github.com>
3032
Divyansh Seth <59174836+sethdivyansh@users.noreply.github.com>
3133
Dominic Lim <46486515+domlimm@users.noreply.github.com>
3234
Dominik Moritz <domoritz@gmail.com>
@@ -49,6 +51,7 @@ Joey Reed <joeyrreed@gmail.com>
4951
Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
5052
Joris Labie <joris.labie1@gmail.com>
5153
Justin Dennison <justin1dennison@gmail.com>
54+
Karan Anand <119553199+anandkaranubc@users.noreply.github.com>
5255
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
5356
Kohantika Nath <145763549+kohantikanath@users.noreply.github.com>
5457
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
@@ -117,7 +120,7 @@ UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
117120
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
118121
Varad Gupta <varadgupta21@gmail.com>
119122
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
120-
Vivek maurya <155618190+vivekmaurya001@users.noreply.github.com>
123+
Vivek Maurya <vm8118134@gmail.com>
121124
Xiaochuan Ye <tap91624@gmail.com>
122125
Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
123126
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Copyright (c) 2016-2024 The Stdlib Authors.
1+
Copyright (c) 2016-2025 The Stdlib Authors.

README.md

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,98 @@ for ( i = 0; i < 10; i++ ) {
149149

150150
<!-- /.examples -->
151151

152+
<!-- C interface documentation. -->
153+
154+
* * *
155+
156+
<section class="c">
157+
158+
## C APIs
159+
160+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
161+
162+
<section class="intro">
163+
164+
</section>
165+
166+
<!-- /.intro -->
167+
168+
<!-- C usage documentation. -->
169+
170+
<section class="usage">
171+
172+
### Usage
173+
174+
```c
175+
#include "stdlib/stats/base/dists/chisquare/variance.h"
176+
```
177+
178+
#### stdlib_base_dists_chisquare_variance( k )
179+
180+
Returns the [variance][variance] of a [chi-squared][chisquare-distribution] distribution with degrees of freedom `k`.
181+
182+
```c
183+
double out = stdlib_base_dists_chisquare_variance( 9.0 );
184+
// returns 18.0
185+
```
186+
187+
The function accepts the following arguments:
188+
189+
- **k**: `[in] double` degrees of freedom.
190+
191+
```c
192+
double stdlib_base_dists_chisquare_variance( const double k );
193+
```
194+
195+
</section>
196+
197+
<!-- /.usage -->
198+
199+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
200+
201+
<section class="notes">
202+
203+
</section>
204+
205+
<!-- /.notes -->
206+
207+
<!-- C API usage examples. -->
208+
209+
<section class="examples">
210+
211+
### Examples
212+
213+
```c
214+
#include "stdlib/stats/base/dists/chisquare/variance.h"
215+
#include <stdlib.h>
216+
#include <stdio.h>
217+
218+
static double random_uniform( const double min, const double max ) {
219+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
220+
return min + ( v*(max-min) );
221+
}
222+
223+
int main( void ) {
224+
double k;
225+
double y;
226+
int i;
227+
228+
for ( i = 0; i < 25; i++ ) {
229+
k = random_uniform( 0.0, 20.0 );
230+
y = stdlib_base_dists_chisquare_variance( k );
231+
printf( "k: %lf, Var(X;k): %lf\n", k, y );
232+
}
233+
}
234+
```
235+
236+
</section>
237+
238+
<!-- /.examples -->
239+
240+
</section>
241+
242+
<!-- /.c -->
243+
152244
<!-- 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. -->
153245

154246
<section class="references">
@@ -191,7 +283,7 @@ See [LICENSE][stdlib-license].
191283

192284
## Copyright
193285

194-
Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
286+
Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
195287

196288
</section>
197289

benchmark/benchmark.js

Lines changed: 9 additions & 2 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;
@@ -31,14 +32,20 @@ var variance = require( './../lib' );
3132
// MAIN //
3233

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

40+
len = 100;
41+
k = new Float64Array( len );
42+
for ( i = 0; i < len; i++ ) {
43+
k[ i ] = ( randu() * 20.0 ) + EPS;
44+
}
45+
3846
b.tic();
3947
for ( i = 0; i < b.iterations; i++ ) {
40-
k = ( randu()*20.0 ) + EPS;
41-
y = variance( k );
48+
y = variance( k[ i % len ] );
4249
if ( isnan( y ) ) {
4350
b.fail( 'should not return NaN' );
4451
}

benchmark/benchmark.native.js

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) 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 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 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 len;
45+
var k;
46+
var y;
47+
var i;
48+
49+
len = 100;
50+
k = new Float64Array( len );
51+
for ( i = 0; i < len; i++ ) {
52+
k[ i ] = ( randu() * 20.0 ) + EPS;
53+
}
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
y = variance( k[ 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)