Skip to content

Commit 2816724

Browse files
committed
chore: clean-up
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: passed - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent ac1050a commit 2816724

12 files changed

Lines changed: 50 additions & 238 deletions

File tree

lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/benchmark/benchmark.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var Float64Array = require( '@stdlib/array/float64' );
25-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var EPS = require( '@stdlib/constants/float64/eps' );
2827
var pkg = require( './../package.json' ).name;
@@ -33,25 +32,23 @@ var entropy = require( './../lib' );
3332

3433
bench( pkg, function benchmark( b ) {
3534
var sigma;
36-
var len;
35+
var opts;
3736
var y;
3837
var i;
3938

40-
len = 100;
41-
sigma = new Float64Array( len );
42-
for ( i = 0; i < len; i++ ) {
43-
sigma[ i ] = ( randu()*20.0 ) + EPS;
44-
}
39+
opts = {
40+
'dtype': 'float64'
41+
};
42+
sigma = uniform( 100, EPS, 20.0, opts );
4543

4644
b.tic();
4745
for ( i = 0; i < b.iterations; i++ ) {
48-
y = entropy( sigma[ i % len ] );
46+
y = entropy( sigma[ i % sigma.length ] );
4947
if ( isnan( y ) ) {
5048
b.fail( 'should not return NaN' );
5149
}
5250
}
5351
b.toc();
54-
5552
if ( isnan( y ) ) {
5653
b.fail( 'should not return NaN' );
5754
}

lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/benchmark/benchmark.native.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var Float64Array = require( '@stdlib/array/float64' );
26-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var EPS = require( '@stdlib/constants/float64/eps' );
2928
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -43,25 +42,23 @@ var opts = {
4342

4443
bench( format( '%s::native', pkg ), opts, function benchmark( b ) {
4544
var sigma;
46-
var len;
45+
var opts;
4746
var y;
4847
var i;
4948

50-
len = 100;
51-
sigma = new Float64Array( len );
52-
for ( i = 0; i < len; i++ ) {
53-
sigma[ i ] = ( randu() * 20.0 ) + EPS;
54-
}
49+
opts = {
50+
'dtype': 'float64'
51+
};
52+
sigma = uniform( 100, EPS, 20.0, opts );
5553

5654
b.tic();
5755
for ( i = 0; i < b.iterations; i++ ) {
58-
y = entropy( sigma[ i % len ] );
56+
y = entropy( sigma[ i % sigma.length ] );
5957
if ( isnan( y ) ) {
6058
b.fail( 'should not return NaN' );
6159
}
6260
}
6361
b.toc();
64-
6562
if ( isnan( y ) ) {
6663
b.fail( 'should not return NaN' );
6764
}

lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{alias}}( σ )
33
Returns the differential entropy of a half-normal distribution.
44

5-
If provided `NaN` as any argument, the function returns `NaN`.
5+
If provided `NaN`, the function returns `NaN`.
66

77
If provided `σ ≤ 0`, the function returns `NaN`.
88

lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/lib/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ var GAMMA = require( '@stdlib/constants/float64/eulergamma' );
2626
var SQRT_HALF_PI = require( '@stdlib/constants/float64/sqrt-half-pi' );
2727

2828

29+
// VARIABLES //
30+
31+
var SCALAR = ln( SQRT_HALF_PI ) + ( 0.5*GAMMA ) + 0.5;
32+
33+
2934
// MAIN //
3035

3136
/**
@@ -54,7 +59,7 @@ function entropy( sigma ) {
5459
if ( isnan( sigma ) || sigma <= 0.0 ) {
5560
return NaN;
5661
}
57-
return 0.5 + ln( sigma ) + ln( SQRT_HALF_PI ) + ( 0.5 * GAMMA );
62+
return ln( sigma ) + SCALAR;
5863
}
5964

6065

lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/manifest.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@
3939
"libpath": [],
4040
"dependencies": [
4141
"@stdlib/math/base/napi/unary",
42-
"@stdlib/math/base/assert/is-nan",
43-
"@stdlib/math/base/special/ln",
44-
"@stdlib/constants/float64/eulergamma",
45-
"@stdlib/constants/float64/sqrt-half-pi"
42+
"@stdlib/math/base/assert/is-nan"
4643
]
4744
},
4845
{
@@ -58,9 +55,6 @@
5855
"libpath": [],
5956
"dependencies": [
6057
"@stdlib/math/base/assert/is-nan",
61-
"@stdlib/math/base/special/ln",
62-
"@stdlib/constants/float64/eulergamma",
63-
"@stdlib/constants/float64/sqrt-half-pi",
6458
"@stdlib/constants/float64/eps"
6559
]
6660
},
@@ -76,10 +70,7 @@
7670
"libraries": [],
7771
"libpath": [],
7872
"dependencies": [
79-
"@stdlib/math/base/assert/is-nan",
80-
"@stdlib/math/base/special/ln",
81-
"@stdlib/constants/float64/eulergamma",
82-
"@stdlib/constants/float64/sqrt-half-pi"
73+
"@stdlib/math/base/assert/is-nan"
8374
]
8475
}
8576
]

lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/src/main.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
#include "stdlib/stats/base/dists/halfnormal/entropy.h"
2020
#include "stdlib/math/base/assert/is_nan.h"
21-
#include "stdlib/math/base/special/ln.h"
22-
#include "stdlib/constants/float64/eulergamma.h"
23-
#include "stdlib/constants/float64/sqrt_half_pi.h"
21+
22+
// 0.5 + ln(sqrt(π/2)) + (eulergamma/2):
23+
static const double scalar = 1.5143991850954939;
2424

2525
/**
2626
* Returns the differential entropy of a half-normal distribution.
@@ -33,11 +33,8 @@
3333
* // returns ~1.014
3434
*/
3535
double stdlib_base_dists_halfnormal_entropy( const double sigma ) {
36-
if (
37-
stdlib_base_is_nan( sigma ) ||
38-
sigma <= 0.0
39-
) {
36+
if ( stdlib_base_is_nan( sigma ) || sigma <= 0.0 ) {
4037
return 0.0/0.0; // NaN
4138
}
42-
return 0.5 + stdlib_base_ln( sigma ) + stdlib_base_ln( STDLIB_CONSTANT_FLOAT64_SQRT_HALF_PI ) + ( 0.5 * STDLIB_CONSTANT_FLOAT64_EULERGAMMA );
39+
return stdlib_base_ln( sigma ) + SCALAR;
4340
}

lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/test/fixtures/julia/REQUIRE

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/test/fixtures/julia/data.json

Lines changed: 0 additions & 106 deletions
This file was deleted.

lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/test/fixtures/julia/runner.jl

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)