Skip to content

Commit 9d37a41

Browse files
committed
Auto-generated commit
1 parent 7a419a5 commit 9d37a41

File tree

18 files changed

+1330
-5
lines changed

18 files changed

+1330
-5
lines changed

CHANGELOG.md

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

899899
<!-- /.package -->
900900

901+
<section class="package" id="stats-base-dists-uniform-variance-unreleased">
902+
903+
#### [@stdlib/stats/base/dists/uniform/variance](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/uniform/variance)
904+
905+
<details>
906+
907+
<section class="features">
908+
909+
##### Features
910+
911+
- [`930ed98`](https://github.com/stdlib-js/stdlib/commit/930ed98207b9ae67f00b23917755589dbbd03fe5) - add C implementation for `stats/base/dists/uniform/variance` [(#3951)](https://github.com/stdlib-js/stdlib/pull/3951)
912+
913+
</section>
914+
915+
<!-- /.features -->
916+
917+
<section class="issues">
918+
919+
##### Closed Issues
920+
921+
This release closes the following issue:
922+
923+
[#3837](https://github.com/stdlib-js/stdlib/issues/3837)
924+
925+
</section>
926+
927+
<!-- /.issues -->
928+
929+
</details>
930+
931+
</section>
932+
933+
<!-- /.package -->
934+
901935
<section class="package" id="stats-base-scumax-unreleased">
902936

903937
#### [@stdlib/stats/base/scumax](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/scumax)
@@ -978,9 +1012,9 @@ A total of 3 issues were closed in this release:
9781012

9791013
### Closed Issues
9801014

981-
A total of 30 issues were closed in this release:
1015+
A total of 31 issues were closed in this release:
9821016

983-
[#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), [#3402](https://github.com/stdlib-js/stdlib/issues/3402), [#3414](https://github.com/stdlib-js/stdlib/issues/3414), [#3417](https://github.com/stdlib-js/stdlib/issues/3417), [#3421](https://github.com/stdlib-js/stdlib/issues/3421), [#3431](https://github.com/stdlib-js/stdlib/issues/3431), [#3434](https://github.com/stdlib-js/stdlib/issues/3434), [#3435](https://github.com/stdlib-js/stdlib/issues/3435), [#3436](https://github.com/stdlib-js/stdlib/issues/3436), [#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), [#3797](https://github.com/stdlib-js/stdlib/issues/3797), [#3798](https://github.com/stdlib-js/stdlib/issues/3798), [#3865](https://github.com/stdlib-js/stdlib/issues/3865), [#3873](https://github.com/stdlib-js/stdlib/issues/3873), [#3874](https://github.com/stdlib-js/stdlib/issues/3874), [#3879](https://github.com/stdlib-js/stdlib/issues/3879), [#3880](https://github.com/stdlib-js/stdlib/issues/3880)
1017+
[#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), [#3402](https://github.com/stdlib-js/stdlib/issues/3402), [#3414](https://github.com/stdlib-js/stdlib/issues/3414), [#3417](https://github.com/stdlib-js/stdlib/issues/3417), [#3421](https://github.com/stdlib-js/stdlib/issues/3421), [#3431](https://github.com/stdlib-js/stdlib/issues/3431), [#3434](https://github.com/stdlib-js/stdlib/issues/3434), [#3435](https://github.com/stdlib-js/stdlib/issues/3435), [#3436](https://github.com/stdlib-js/stdlib/issues/3436), [#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), [#3797](https://github.com/stdlib-js/stdlib/issues/3797), [#3798](https://github.com/stdlib-js/stdlib/issues/3798), [#3837](https://github.com/stdlib-js/stdlib/issues/3837), [#3865](https://github.com/stdlib-js/stdlib/issues/3865), [#3873](https://github.com/stdlib-js/stdlib/issues/3873), [#3874](https://github.com/stdlib-js/stdlib/issues/3874), [#3879](https://github.com/stdlib-js/stdlib/issues/3879), [#3880](https://github.com/stdlib-js/stdlib/issues/3880)
9841018

9851019
</section>
9861020

@@ -1015,6 +1049,7 @@ A total of 12 people contributed to this release. Thank you to the following con
10151049

10161050
<details>
10171051

1052+
- [`930ed98`](https://github.com/stdlib-js/stdlib/commit/930ed98207b9ae67f00b23917755589dbbd03fe5) - **feat:** add C implementation for `stats/base/dists/uniform/variance` [(#3951)](https://github.com/stdlib-js/stdlib/pull/3951) _(by Aayush Khanna)_
10181053
- [`ad7c388`](https://github.com/stdlib-js/stdlib/commit/ad7c3880af37bccd159b6623f92d4b0212eaf0db) - **feat:** add C implementation for `stats/base/dists/t/logpdf` [(#3934)](https://github.com/stdlib-js/stdlib/pull/3934) _(by Aadish Jain, Philipp Burckhardt)_
10191054
- [`d7f5b56`](https://github.com/stdlib-js/stdlib/commit/d7f5b56fc072abf167bd5eb5e2163833715f2211) - **feat:** add C implementation of `stats/base/dists/rayleigh/cdf` [(#3931)](https://github.com/stdlib-js/stdlib/pull/3931) _(by Vinit Pandit, Philipp Burckhardt)_
10201055
- [`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)_

base/dists/uniform/variance/README.md

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

134134
<!-- /.examples -->
135135

136+
<!-- C interface documentation. -->
137+
138+
* * *
139+
140+
<section class="c">
141+
142+
## C APIs
143+
144+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
145+
146+
<section class="intro">
147+
148+
</section>
149+
150+
<!-- /.intro -->
151+
152+
<!-- C usage documentation. -->
153+
154+
<section class="usage">
155+
156+
### Usage
157+
158+
```c
159+
#include "stdlib/stats/base/dists/uniform/variance.h"
160+
```
161+
162+
#### stdlib_base_dists_uniform_variance( a, b )
163+
164+
Returns the variance of a uniform distribution.
165+
166+
```c
167+
double out = stdlib_base_dists_uniform_variance( 0.0, 1.0 );
168+
// returns ~0.083
169+
```
170+
171+
The function accepts the following arguments:
172+
173+
- **a**: `[in] double` minimum support.
174+
- **b**: `[in] double` maximum support.
175+
176+
```c
177+
double stdlib_base_dists_uniform_variance( const double a, const double b );
178+
```
179+
180+
</section>
181+
182+
<!-- /.usage -->
183+
184+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
185+
186+
<section class="notes">
187+
188+
</section>
189+
190+
<!-- /.notes -->
191+
192+
<!-- C API usage examples. -->
193+
194+
<section class="examples">
195+
196+
### Examples
197+
198+
```c
199+
#include "stdlib/stats/base/dists/uniform/variance.h"
200+
#include <stdlib.h>
201+
#include <stdio.h>
202+
203+
static double random_uniform( const double min, const double max ) {
204+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
205+
return min + ( v*(max-min) );
206+
}
207+
208+
int main( void ) {
209+
double a;
210+
double b;
211+
double y;
212+
int i;
213+
214+
for ( i = 0; i < 25; i++ ) {
215+
a = random_uniform( 0.0, 20.0 );
216+
b = random_uniform( 0.0, 20.0 ) + a;
217+
y = stdlib_base_dists_uniform_variance( a, b );
218+
printf( "a: %lf, b: %lf, Var(X;a,b): %lf\n", a, b, y );
219+
}
220+
}
221+
```
222+
223+
</section>
224+
225+
<!-- /.examples -->
226+
227+
</section>
228+
229+
<!-- /.c -->
230+
136231
<!-- 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. -->
137232

138233
<section class="references">

base/dists/uniform/variance/benchmark/benchmark.js

Lines changed: 11 additions & 3 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;
@@ -32,14 +33,21 @@ var variance = require( './../lib' );
3233
bench( pkg, function benchmark( b ) {
3334
var min;
3435
var max;
36+
var len;
3537
var y;
3638
var i;
3739

40+
len = 100;
41+
min = new Float64Array( len );
42+
max = new Float64Array( len );
43+
for ( i = 0; i < len; i++ ) {
44+
min[ i ] = ( randu() * 10.0 );
45+
max[ i ] = ( randu() * 10.0 ) + min[ i ];
46+
}
47+
3848
b.tic();
3949
for ( i = 0; i < b.iterations; i++ ) {
40-
min = ( randu()*10.0 );
41-
max = ( randu()*10.0 ) + min;
42-
y = variance( min, max );
50+
y = variance( min[ i % len ], max[ i % len ] );
4351
if ( isnan( y ) ) {
4452
b.fail( 'should not return NaN' );
4553
}
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) 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 tryRequire = require( '@stdlib/utils/try-require' );
27+
var randu = require( '@stdlib/random/base/randu' );
28+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
29+
var pkg = require( './../package.json' ).name;
30+
31+
32+
// VARIABLES //
33+
34+
var variance = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( variance instanceof Error )
37+
};
38+
39+
40+
// MAIN //
41+
42+
bench( pkg+'::native', opts, function benchmark( b ) {
43+
var min;
44+
var max;
45+
var len;
46+
var y;
47+
var i;
48+
49+
len = 100;
50+
min = new Float64Array( len );
51+
max = new Float64Array( len );
52+
for ( i = 0; i < len; i++ ) {
53+
min[ i ] = ( randu() * 10.0 );
54+
max[ i ] = ( randu() * 10.0 ) + min[ i ];
55+
}
56+
57+
b.tic();
58+
for ( i = 0; i < b.iterations; i++ ) {
59+
y = variance( min[ i % len ], max[ 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)