Skip to content

Commit f0b3890

Browse files
committed
Auto-generated commit
1 parent 992111c commit f0b3890

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-01-19)
7+
## Unreleased (2025-01-20)
88

99
<section class="features">
1010

@@ -34,6 +34,7 @@ This release closes the following issue:
3434

3535
<details>
3636

37+
- [`5a6efed`](https://github.com/stdlib-js/stdlib/commit/5a6efed4b52bece2bbcef65d8b19dcfaa168ff78) - **refactor:** precompute constant _(by Philipp Burckhardt)_
3738
- [`03954e1`](https://github.com/stdlib-js/stdlib/commit/03954e125b6cc761a5456e51c909ab09b18d15ee) - **feat:** add C implementation for `stats/base/dists/logistic/stdev` [(#4189)](https://github.com/stdlib-js/stdlib/pull/4189) _(by Vivek Maurya, Philipp Burckhardt, stdlib-bot)_
3839
- [`4a70790`](https://github.com/stdlib-js/stdlib/commit/4a707903dfef7c2b56216000165706497d19a251) - **style:** add missing spaces _(by Philipp Burckhardt)_
3940

dist/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

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
}

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
}

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)