Skip to content

Commit 75b82d7

Browse files
committed
Auto-generated commit
1 parent 75347e3 commit 75b82d7

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
@@ -44,6 +44,40 @@ This release closes the following issue:
4444

4545
<!-- /.package -->
4646

47+
<section class="package" id="stats-base-dists-arcsine-entropy-unreleased">
48+
49+
#### [@stdlib/stats/base/dists/arcsine/entropy](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/arcsine/entropy)
50+
51+
<details>
52+
53+
<section class="features">
54+
55+
##### Features
56+
57+
- [`222ef72`](https://github.com/stdlib-js/stdlib/commit/222ef725730746806fa15ac1d735f0284cf4616e) - add C implementation for `stats/base/dists/arcsine/entropy` [(#3379)](https://github.com/stdlib-js/stdlib/pull/3379)
58+
59+
</section>
60+
61+
<!-- /.features -->
62+
63+
<section class="issues">
64+
65+
##### Closed Issues
66+
67+
This release closes the following issue:
68+
69+
[#3378](https://github.com/stdlib-js/stdlib/issues/3378)
70+
71+
</section>
72+
73+
<!-- /.issues -->
74+
75+
</details>
76+
77+
</section>
78+
79+
<!-- /.package -->
80+
4781
<section class="package" id="stats-base-dists-arcsine-logpdf-unreleased">
4882

4983
#### [@stdlib/stats/base/dists/arcsine/logpdf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/arcsine/logpdf)
@@ -298,9 +332,9 @@ A total of 3 issues were closed in this release:
298332

299333
### Closed Issues
300334

301-
A total of 10 issues were closed in this release:
335+
A total of 11 issues were closed in this release:
302336

303-
[#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), [#3384](https://github.com/stdlib-js/stdlib/issues/3384), [#3401](https://github.com/stdlib-js/stdlib/issues/3401), [#3414](https://github.com/stdlib-js/stdlib/issues/3414), [#3446](https://github.com/stdlib-js/stdlib/issues/3446)
337+
[#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), [#3401](https://github.com/stdlib-js/stdlib/issues/3401), [#3414](https://github.com/stdlib-js/stdlib/issues/3414), [#3446](https://github.com/stdlib-js/stdlib/issues/3446)
304338

305339
</section>
306340

@@ -332,6 +366,7 @@ A total of 9 people contributed to this release. Thank you to the following cont
332366

333367
<details>
334368

369+
- [`222ef72`](https://github.com/stdlib-js/stdlib/commit/222ef725730746806fa15ac1d735f0284cf4616e) - **feat:** add C implementation for `stats/base/dists/arcsine/entropy` [(#3379)](https://github.com/stdlib-js/stdlib/pull/3379) _(by Aayush Khanna, Philipp Burckhardt)_
335370
- [`5019fab`](https://github.com/stdlib-js/stdlib/commit/5019fab885f33507350e6b7ec6a61e1e283d6249) - **feat:** add C implementation for `stats/base/dists/bernoulli/mean` [(#3451)](https://github.com/stdlib-js/stdlib/pull/3451) _(by Vivek maurya, Athan Reines, stdlib-bot)_
336371
- [`be1e1c4`](https://github.com/stdlib-js/stdlib/commit/be1e1c4a2e5d9a1e0ebc0e2f0a4244c50d4142c5) - **bench:** fix missing namespace _(by Athan Reines)_
337372
- [`d1a200b`](https://github.com/stdlib-js/stdlib/commit/d1a200bc6ab344f9fcd8a33a70712456dbf479d0) - **feat:** add C implementation for `stats/base/dists/betaprime/stdev` [(#3461)](https://github.com/stdlib-js/stdlib/pull/3461) _(by Aayush Khanna, Philipp Burckhardt, stdlib-bot)_

base/dists/arcsine/entropy/README.md

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

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

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

137232
<section class="references">

base/dists/arcsine/entropy/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 entropy = 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() * 20.0;
45+
max[ i ] = ( randu() * 20.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 = entropy( min, max );
50+
y = entropy( 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 entropy = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( entropy 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() * 20.0;
54+
max[ i ] = ( randu() * 20.0 ) + min[ i ];
55+
}
56+
57+
b.tic();
58+
for ( i = 0; i < b.iterations; i++ ) {
59+
y = entropy( 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)