Skip to content

Commit 2fc1b31

Browse files
committed
Auto-generated commit
1 parent 9d37a41 commit 2fc1b31

File tree

18 files changed

+1340
-5
lines changed

18 files changed

+1340
-5
lines changed

CHANGELOG.md

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

661661
<!-- /.package -->
662662

663+
<section class="package" id="stats-base-dists-laplace-variance-unreleased">
664+
665+
#### [@stdlib/stats/base/dists/laplace/variance](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/laplace/variance)
666+
667+
<details>
668+
669+
<section class="features">
670+
671+
##### Features
672+
673+
- [`2b67875`](https://github.com/stdlib-js/stdlib/commit/2b67875eca43c4846a5b048971eab7bf898216e9) - add C implementation for `stats/base/dists/laplace/variance` [(#3948)](https://github.com/stdlib-js/stdlib/pull/3948)
674+
675+
</section>
676+
677+
<!-- /.features -->
678+
679+
<section class="issues">
680+
681+
##### Closed Issues
682+
683+
This release closes the following issue:
684+
685+
[#3721](https://github.com/stdlib-js/stdlib/issues/3721)
686+
687+
</section>
688+
689+
<!-- /.issues -->
690+
691+
</details>
692+
693+
</section>
694+
695+
<!-- /.package -->
696+
663697
<section class="package" id="stats-base-dists-pareto-type1-skewness-unreleased">
664698

665699
#### [@stdlib/stats/base/dists/pareto-type1/skewness](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/pareto-type1/skewness)
@@ -1012,9 +1046,9 @@ A total of 3 issues were closed in this release:
10121046

10131047
### Closed Issues
10141048

1015-
A total of 31 issues were closed in this release:
1049+
A total of 32 issues were closed in this release:
10161050

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)
1051+
[#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), [#3721](https://github.com/stdlib-js/stdlib/issues/3721), [#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)
10181052

10191053
</section>
10201054

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

10501084
<details>
10511085

1086+
- [`2b67875`](https://github.com/stdlib-js/stdlib/commit/2b67875eca43c4846a5b048971eab7bf898216e9) - **feat:** add C implementation for `stats/base/dists/laplace/variance` [(#3948)](https://github.com/stdlib-js/stdlib/pull/3948) _(by Aayush Khanna, stdlib-bot)_
10521087
- [`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)_
10531088
- [`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)_
10541089
- [`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)_

base/dists/laplace/variance/README.md

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

132132
<!-- /.examples -->
133133

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

136231
<section class="references">

base/dists/laplace/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 EPS = require( '@stdlib/constants/float64/eps' );
@@ -32,15 +33,22 @@ var variance = require( './../lib' );
3233

3334
bench( pkg, function benchmark( b ) {
3435
var scale;
36+
var len;
3537
var mu;
3638
var y;
3739
var i;
3840

41+
len = 100;
42+
mu = new Float64Array( len );
43+
scale = new Float64Array( len );
44+
for ( i = 0; i < len; i++ ) {
45+
mu[ i ] = ( randu() * 100.0 ) - 50.0;
46+
scale[ i ] = ( randu() * 20.0 ) + EPS;
47+
}
48+
3949
b.tic();
4050
for ( i = 0; i < b.iterations; i++ ) {
41-
mu = ( randu()*100.0 ) - 50.0;
42-
scale = ( randu()*20.0 ) + EPS;
43-
y = variance( mu, scale );
51+
y = variance( mu[ i % len ], scale[ i % len ] );
4452
if ( isnan( y ) ) {
4553
b.fail( 'should not return NaN' );
4654
}
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' );
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 EPS = require( '@stdlib/constants/float64/eps' );
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 scale;
45+
var len;
46+
var mu;
47+
var y;
48+
var i;
49+
50+
len = 100;
51+
mu = new Float64Array( len );
52+
scale = new Float64Array( len );
53+
for ( i = 0; i < len; i++ ) {
54+
mu[ i ] = ( randu() * 100.0 ) - 50.0;
55+
scale[ i ] = ( randu() * 20.0 ) + EPS;
56+
}
57+
58+
b.tic();
59+
for ( i = 0; i < b.iterations; i++ ) {
60+
y = variance( mu[ i % len ], scale[ 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)