Skip to content

Commit 5a97a85

Browse files
committed
chore: precompute constant and use uniform
--- 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: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent d094935 commit 5a97a85

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

lib/node_modules/@stdlib/stats/base/dists/rayleigh/skewness/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
2424
var Float64Array = require( '@stdlib/array/float64' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var EPS = require( '@stdlib/constants/float64/eps' );
2828
var pkg = require( './../package.json' ).name;
@@ -40,7 +40,7 @@ bench( pkg, function benchmark( b ) {
4040
len = 100;
4141
sigma = new Float64Array( len );
4242
for ( i = 0; i < len; i++ ) {
43-
sigma[ i ] = ( randu()*20.0 ) + EPS;
43+
sigma[ i ] = uniform( EPS, 20.0 );
4444
}
4545

4646
b.tic();

lib/node_modules/@stdlib/stats/base/dists/rayleigh/skewness/src/main.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818

1919
#include "stdlib/stats/base/dists/rayleigh/skewness.h"
2020
#include "stdlib/math/base/assert/is_nan.h"
21-
#include "stdlib/math/base/special/pow.h"
22-
#include "stdlib/constants/float64/pi.h"
23-
24-
const double STDLIB_CONSTANT_FLOAT64_SQRT_PI = 1.772453850905516027;
21+
const double SKEWNESS_CONSTANT = 0.6311106578189364;
2522

2623
/**
2724
* Returns the skewness of a Rayleigh distribution.
@@ -34,13 +31,11 @@ const double STDLIB_CONSTANT_FLOAT64_SQRT_PI = 1.772453850905516027;
3431
* // returns ~0.631
3532
*/
3633
double stdlib_base_dists_rayleigh_skewness( const double sigma ) {
37-
double SKEWNESS;
3834
if (
3935
stdlib_base_is_nan( sigma ) ||
4036
sigma < 0.0
4137
) {
4238
return 0.0/0.0; // NaN
4339
}
44-
SKEWNESS = 2.0 * STDLIB_CONSTANT_FLOAT64_SQRT_PI * ( STDLIB_CONSTANT_FLOAT64_PI-3.0 ) / stdlib_base_pow( 4.0 - STDLIB_CONSTANT_FLOAT64_PI, 1.5 );
45-
return SKEWNESS;
40+
return SKEWNESS_CONSTANT;
4641
}

0 commit comments

Comments
 (0)