Skip to content

Commit ded3c14

Browse files
committed
Auto-generated commit
1 parent cf4befb commit ded3c14

File tree

18 files changed

+1337
-5
lines changed

18 files changed

+1337
-5
lines changed

CHANGELOG.md

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

15111511
<!-- /.package -->
15121512

1513+
<section class="package" id="stats-base-dists-uniform-entropy-unreleased">
1514+
1515+
#### [@stdlib/stats/base/dists/uniform/entropy](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/uniform/entropy)
1516+
1517+
<details>
1518+
1519+
<section class="features">
1520+
1521+
##### Features
1522+
1523+
- [`4d6fbbd`](https://github.com/stdlib-js/stdlib/commit/4d6fbbd6ec73ee9d0ccb3bba1869f34d184329dd) - add C implementation for `stats/base/dists/uniform/entropy` [(#4021)](https://github.com/stdlib-js/stdlib/pull/4021)
1524+
1525+
</section>
1526+
1527+
<!-- /.features -->
1528+
1529+
<section class="issues">
1530+
1531+
##### Closed Issues
1532+
1533+
This release closes the following issue:
1534+
1535+
[#3826](https://github.com/stdlib-js/stdlib/issues/3826)
1536+
1537+
</section>
1538+
1539+
<!-- /.issues -->
1540+
1541+
</details>
1542+
1543+
</section>
1544+
1545+
<!-- /.package -->
1546+
15131547
<section class="package" id="stats-base-dists-uniform-pdf-unreleased">
15141548

15151549
#### [@stdlib/stats/base/dists/uniform/pdf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/uniform/pdf)
@@ -1658,9 +1692,9 @@ A total of 3 issues were closed in this release:
16581692

16591693
### Closed Issues
16601694

1661-
A total of 50 issues were closed in this release:
1695+
A total of 51 issues were closed in this release:
16621696

1663-
[#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), [#3410](https://github.com/stdlib-js/stdlib/issues/3410), [#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), [#3480](https://github.com/stdlib-js/stdlib/issues/3480), [#3494](https://github.com/stdlib-js/stdlib/issues/3494), [#3501](https://github.com/stdlib-js/stdlib/issues/3501), [#3510](https://github.com/stdlib-js/stdlib/issues/3510), [#3597](https://github.com/stdlib-js/stdlib/issues/3597), [#3656](https://github.com/stdlib-js/stdlib/issues/3656), [#3671](https://github.com/stdlib-js/stdlib/issues/3671), [#3721](https://github.com/stdlib-js/stdlib/issues/3721), [#3746](https://github.com/stdlib-js/stdlib/issues/3746), [#3759](https://github.com/stdlib-js/stdlib/issues/3759), [#3783](https://github.com/stdlib-js/stdlib/issues/3783), [#3789](https://github.com/stdlib-js/stdlib/issues/3789), [#3797](https://github.com/stdlib-js/stdlib/issues/3797), [#3798](https://github.com/stdlib-js/stdlib/issues/3798), [#3799](https://github.com/stdlib-js/stdlib/issues/3799), [#3801](https://github.com/stdlib-js/stdlib/issues/3801), [#3807](https://github.com/stdlib-js/stdlib/issues/3807), [#3811](https://github.com/stdlib-js/stdlib/issues/3811), [#3833](https://github.com/stdlib-js/stdlib/issues/3833), [#3837](https://github.com/stdlib-js/stdlib/issues/3837), [#3865](https://github.com/stdlib-js/stdlib/issues/3865), [#3866](https://github.com/stdlib-js/stdlib/issues/3866), [#3871](https://github.com/stdlib-js/stdlib/issues/3871), [#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)
1697+
[#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), [#3410](https://github.com/stdlib-js/stdlib/issues/3410), [#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), [#3480](https://github.com/stdlib-js/stdlib/issues/3480), [#3494](https://github.com/stdlib-js/stdlib/issues/3494), [#3501](https://github.com/stdlib-js/stdlib/issues/3501), [#3510](https://github.com/stdlib-js/stdlib/issues/3510), [#3597](https://github.com/stdlib-js/stdlib/issues/3597), [#3656](https://github.com/stdlib-js/stdlib/issues/3656), [#3671](https://github.com/stdlib-js/stdlib/issues/3671), [#3721](https://github.com/stdlib-js/stdlib/issues/3721), [#3746](https://github.com/stdlib-js/stdlib/issues/3746), [#3759](https://github.com/stdlib-js/stdlib/issues/3759), [#3783](https://github.com/stdlib-js/stdlib/issues/3783), [#3789](https://github.com/stdlib-js/stdlib/issues/3789), [#3797](https://github.com/stdlib-js/stdlib/issues/3797), [#3798](https://github.com/stdlib-js/stdlib/issues/3798), [#3799](https://github.com/stdlib-js/stdlib/issues/3799), [#3801](https://github.com/stdlib-js/stdlib/issues/3801), [#3807](https://github.com/stdlib-js/stdlib/issues/3807), [#3811](https://github.com/stdlib-js/stdlib/issues/3811), [#3826](https://github.com/stdlib-js/stdlib/issues/3826), [#3833](https://github.com/stdlib-js/stdlib/issues/3833), [#3837](https://github.com/stdlib-js/stdlib/issues/3837), [#3865](https://github.com/stdlib-js/stdlib/issues/3865), [#3866](https://github.com/stdlib-js/stdlib/issues/3866), [#3871](https://github.com/stdlib-js/stdlib/issues/3871), [#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)
16641698

16651699
</section>
16661700

@@ -1698,6 +1732,7 @@ A total of 15 people contributed to this release. Thank you to the following con
16981732

16991733
<details>
17001734

1735+
- [`4d6fbbd`](https://github.com/stdlib-js/stdlib/commit/4d6fbbd6ec73ee9d0ccb3bba1869f34d184329dd) - **feat:** add C implementation for `stats/base/dists/uniform/entropy` [(#4021)](https://github.com/stdlib-js/stdlib/pull/4021) _(by Divyansh Seth, Philipp Burckhardt)_
17011736
- [`b283652`](https://github.com/stdlib-js/stdlib/commit/b2836521feb83b741d0190d7600f297f0379851f) - **feat:** add C implementation for `stats/base/dists/f/mean` [(#4033)](https://github.com/stdlib-js/stdlib/pull/4033) _(by Vivek maurya)_
17021737
- [`118284b`](https://github.com/stdlib-js/stdlib/commit/118284b97293f409c1769047675bed85ddf4dd20) - **feat:** add C implementation for `stats/base/dists/chisquare/skewness` [(#4005)](https://github.com/stdlib-js/stdlib/pull/4005) _(by Vivek maurya, Philipp Burckhardt)_
17031738
- [`7a87244`](https://github.com/stdlib-js/stdlib/commit/7a872442e344e03a69d987f0f7b89d1344d5547c) - **feat:** add C implementation for `stats/base/dists/chisquare/entropy` [(#4007)](https://github.com/stdlib-js/stdlib/pull/4007) _(by Vivek maurya, Philipp Burckhardt)_

base/dists/uniform/entropy/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/entropy.h"
160+
```
161+
162+
#### stdlib_base_dists_uniform_entropy( a, b )
163+
164+
Evaluates the [entropy][entropy] of a [uniform][uniform-distribution] distribution with `a` the minimum support and `b` the maximum support.
165+
166+
```c
167+
double out = stdlib_base_dists_uniform_entropy( 2.0, 8.0 );
168+
// returns ~1.792
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_entropy( 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/entropy.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 v;
212+
double i;
213+
214+
for ( i = 0; i < 25; i++ ) {
215+
a = random_uniform( 0.0, 10.0 );
216+
b = random_uniform( a, a+10.0 );
217+
v = stdlib_base_dists_uniform_entropy( a, b );
218+
printf( "a: %lf, b: %lf, h(X;a,b): %lf\n", a, b, v );
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/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()*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 = 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()*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 = 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)