Skip to content

Commit 2197129

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: passed - 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: 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: passed - 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 b5bff35 commit 2197129

File tree

5 files changed

+51
-23
lines changed

5 files changed

+51
-23
lines changed

lib/node_modules/@stdlib/stats/base/dists/levy/cdf/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ for ( i = 0; i < 100; i++ ) {
170170
Evaluates the [cumulative distribution function][cdf] (CDF) for a [Lévy][levy-distribution] distribution with parameters `mu` (location parameter) and `c > 0` (scale parameter).
171171

172172
```c
173-
double out = stdlib_base_levy_cdf( 0.5, 0.0, 2.0 );
174-
// returns ~0.520
173+
double out = stdlib_base_levy_cdf( 2.0, 0.0, 1.0 );
174+
// returns ~0.48
175175
```
176176

177177
The function accepts the following arguments:
@@ -213,8 +213,8 @@ static double random_uniform( const double min, const double max ) {
213213
}
214214
215215
int main( void ) {
216-
double x;
217216
double mu;
217+
double x;
218218
double c;
219219
double y;
220220
int i;

lib/node_modules/@stdlib/stats/base/dists/levy/cdf/examples/c/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ static double random_uniform( const double min, const double max ) {
2626
}
2727

2828
int main( void ) {
29-
double x;
3029
double mu;
30+
double x;
3131
double c;
3232
double y;
3333
int i;

lib/node_modules/@stdlib/stats/base/dists/levy/cdf/src/addon.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@
1919
#include "stdlib/math/base/napi/ternary.h"
2020
#include "stdlib/stats/base/dists/levy/cdf.h"
2121

22-
// cppcheck-suppress shadowFunction
2322
STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_dists_levy_cdf )

lib/node_modules/@stdlib/stats/base/dists/levy/cdf/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
* @return evaluated CDF
3131
*
3232
* @example
33-
* double y = stdlib_base_dists_levy_cdf( 9.0, 0.0, 1.0 );
34-
* // returns ~0.999
33+
* double y = stdlib_base_dists_levy_cdf( 2.0, 0.0, 1.0 );
34+
* // returns ~0.48
3535
*/
3636
double stdlib_base_dists_levy_cdf( const double x, const double mu, const double c ) {
3737
double z;

lib/node_modules/@stdlib/stats/base/dists/levy/cdf/test/test.native.js

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ var EPS = require( '@stdlib/constants/float64/eps' );
3232

3333
// FIXTURES //
3434

35-
var largeVariance = require( './fixtures/julia/large_variance.json' );
3635
var negativeMean = require( './fixtures/julia/negative_mean.json' );
3736
var positiveMean = require( './fixtures/julia/positive_mean.json' );
37+
var largeVariance = require( './fixtures/julia/large_variance.json' );
3838

3939

4040
// VARIABLES //
@@ -75,19 +75,44 @@ tape( 'if provided `-infinity` for `x` and a valid `mu` and `c`, the function re
7575
t.end();
7676
});
7777

78-
tape( 'if provided `c <= 0`, the function returns `NaN`', opts, function test( t ) {
78+
tape( 'if provided a `x` smaller than `mu`, the function returns `0`', opts, function test( t ) {
79+
var y = cdf( -1.0, 0.0, 1.0 );
80+
t.equal( y, 0.0, 'returns 0' );
81+
82+
y = cdf( 3.0, 4.0, 1.0 );
83+
t.equal( y, 0.0, 'returns 0' );
84+
85+
t.end();
86+
});
87+
88+
tape( 'if provided a nonpositive `c`, the function returns `NaN`', opts, function test( t ) {
7989
var y;
8090

81-
y = cdf( 2.0, 0.0, -1.0 );
91+
y = cdf( 2.0, 2.0, 0.0 );
92+
t.equal( isnan( y ), true, 'returns NaN' );
93+
94+
y = cdf( 2.0, 2.0, -1.0 );
95+
t.equal( isnan( y ), true, 'returns NaN' );
96+
97+
y = cdf( 0.0, 2.0, -1.0 );
98+
t.equal( isnan( y ), true, 'returns NaN' );
99+
100+
y = cdf( 2.0, 1.0, NINF );
101+
t.equal( isnan( y ), true, 'returns NaN' );
102+
103+
y = cdf( 2.0, PINF, NINF );
104+
t.equal( isnan( y ), true, 'returns NaN' );
105+
106+
y = cdf( 2.0, NINF, NINF );
82107
t.equal( isnan( y ), true, 'returns NaN' );
83108

84-
y = cdf( 0.0, 0.0, 0.0 );
109+
y = cdf( 2.0, NaN, NINF );
85110
t.equal( isnan( y ), true, 'returns NaN' );
86111

87112
t.end();
88113
});
89114

90-
tape( 'the function evaluates the cdf for `x` given a large variance `c`', opts, function test( t ) {
115+
tape( 'the function evaluates the cdf for `x` given a positive `mu`', opts, function test( t ) {
91116
var expected;
92117
var delta;
93118
var tol;
@@ -97,24 +122,26 @@ tape( 'the function evaluates the cdf for `x` given a large variance `c`', opts,
97122
var y;
98123
var i;
99124

100-
expected = largeVariance.expected;
101-
x = largeVariance.x;
102-
mu = largeVariance.mu;
103-
c = largeVariance.c;
125+
expected = positiveMean.expected;
126+
x = positiveMean.x;
127+
mu = positiveMean.mu;
128+
c = positiveMean.c;
104129
for ( i = 0; i < x.length; i++ ) {
105130
y = cdf( x[ i ], mu[ i ], c[ i ] );
106131
if ( y === expected[ i ] ) {
107132
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', mu: ' + mu[ i ] + ', c: ' + c[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
108133
} else {
109134
delta = abs( y - expected[ i ] );
135+
136+
// NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205
110137
tol = 2.0 * EPS * abs( expected[ i ] );
111138
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. mu: ' + mu[ i ] + '. c: ' + c[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
112139
}
113140
}
114141
t.end();
115142
});
116143

117-
tape( 'the function evaluates the cdf for `x` given a negative mean `mu`', opts, function test( t ) {
144+
tape( 'the function evaluates the cdf for `x` given a negative `mu`', opts, function test( t ) {
118145
var expected;
119146
var delta;
120147
var tol;
@@ -134,14 +161,14 @@ tape( 'the function evaluates the cdf for `x` given a negative mean `mu`', opts,
134161
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', mu: ' + mu[ i ] + ', c: ' + c[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
135162
} else {
136163
delta = abs( y - expected[ i ] );
137-
tol = 2.0 * EPS * abs( expected[ i ] );
164+
tol = 1.0 * EPS * abs( expected[ i ] );
138165
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. mu: ' + mu[ i ] + '. c: ' + c[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
139166
}
140167
}
141168
t.end();
142169
});
143170

144-
tape( 'the function evaluates the cdf for `x` given a positive mean `mu`', opts, function test( t ) {
171+
tape( 'the function evaluates the cdf for `x` given a large variance ( = large `b` )', opts, function test( t ) {
145172
var expected;
146173
var delta;
147174
var tol;
@@ -151,16 +178,18 @@ tape( 'the function evaluates the cdf for `x` given a positive mean `mu`', opts,
151178
var y;
152179
var i;
153180

154-
expected = positiveMean.expected;
155-
x = positiveMean.x;
156-
mu = positiveMean.mu;
157-
c = positiveMean.c;
181+
expected = largeVariance.expected;
182+
x = largeVariance.x;
183+
mu = largeVariance.mu;
184+
c = largeVariance.c;
158185
for ( i = 0; i < x.length; i++ ) {
159186
y = cdf( x[ i ], mu[ i ], c[ i ] );
160187
if ( y === expected[ i ] ) {
161188
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', mu: ' + mu[ i ] + ', c: ' + c[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
162189
} else {
163190
delta = abs( y - expected[ i ] );
191+
192+
// NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205
164193
tol = 2.0 * EPS * abs( expected[ i ] );
165194
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. mu: ' + mu[ i ] + '. c: ' + c[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
166195
}

0 commit comments

Comments
 (0)