Skip to content

Commit 5a6efed

Browse files
committed
refactor: precompute constant
--- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 441ea68 commit 5a6efed

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

lib/node_modules/@stdlib/stats/base/dists/logistic/stdev/lib/main.js

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

2323
var isnan = require( '@stdlib/math/base/assert/is-nan' );
24-
var SQRT3 = require( '@stdlib/constants/float64/sqrt-three' );
25-
var PI = require( '@stdlib/constants/float64/pi' );
24+
25+
26+
// VARIABLES //
27+
28+
var PI_OVER_SQRT_THREE = 1.8137993642342178; // π divided by the square root of 3
2629

2730

2831
// MAIN //
@@ -62,7 +65,7 @@ function stdev( mu, s ) {
6265
) {
6366
return NaN;
6467
}
65-
return s * PI / SQRT3;
68+
return s * PI_OVER_SQRT_THREE;
6669
}
6770

6871

lib/node_modules/@stdlib/stats/base/dists/logistic/stdev/src/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "stdlib/constants/float64/pi.h"
2222
#include "stdlib/constants/float64/sqrt_three.h"
2323

24+
static const double PI_OVER_SQRT_THREE = 1.8137993642342178; // π divided by the square root of 3
25+
2426
/**
2527
* Returns the standard deviation for a logistic distribution with location `mu` and scale `s`.
2628
*
@@ -40,5 +42,5 @@ double stdlib_base_dists_logistic_stdev( const double mu, const double s ) {
4042
) {
4143
return 0.0/0.0; // NaN
4244
}
43-
return s * STDLIB_CONSTANT_FLOAT64_PI / STDLIB_CONSTANT_FLOAT64_SQRT3;
45+
return s * PI_OVER_SQRT_THREE;
4446
}

lib/node_modules/@stdlib/stats/base/dists/logistic/stdev/test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ tape( 'the function returns the standard deviation of a logistic distribution',
9696
t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
9797
} else {
9898
delta = abs( y - expected[ i ] );
99-
tol = 2.0 * EPS * abs( expected[ i ] );
99+
tol = 1.0 * EPS * abs( expected[ i ] );
100100
t.ok( delta <= tol, 'within tolerance. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
101101
}
102102
}

lib/node_modules/@stdlib/stats/base/dists/logistic/stdev/test/test.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ tape( 'the function returns the standard deviation of a logistic distribution',
105105
t.equal( y, expected[i], 'mu:'+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
106106
} else {
107107
delta = abs( y - expected[ i ] );
108-
tol = 2.0 * EPS * abs( expected[ i ] );
108+
tol = 1.0 * EPS * abs( expected[ i ] );
109109
t.ok( delta <= tol, 'within tolerance. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
110110
}
111111
}

0 commit comments

Comments
 (0)