Skip to content

Commit 427d616

Browse files
chore: address commit comments and update tests
PR-URL: #5264 Closes: #5232 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent fc127d4 commit 427d616

File tree

3 files changed

+7
-59
lines changed

3 files changed

+7
-59
lines changed

lib/node_modules/@stdlib/stats/base/dists/cauchy/pdf/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ int main( void ) {
223223
for ( i = 0; i < 25; i++ ) {
224224
x = random_uniform( 0.0, 10.0 );
225225
x0 = random_uniform( -5.0, 5.0 );
226-
gamma = random_uniform( 0.0, 20.0 ) + STDLIB_CONSTANT_FLOAT64_EPS;
226+
gamma = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 );
227227
y = stdlib_base_dists_cauchy_pdf( x, x0, gamma );
228228
printf( "x: %lf, k: %lf, γ: %lf, f(x;x0,γ): %lf\n", x, x0, gamma, y );
229229
}

lib/node_modules/@stdlib/stats/base/dists/cauchy/pdf/test/test.native.js

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
2525
var tryRequire = require( '@stdlib/utils/try-require' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27-
var abs = require( '@stdlib/math/base/special/abs' );
2827
var PINF = require( '@stdlib/constants/float64/pinf' );
2928
var NINF = require( '@stdlib/constants/float64/ninf' );
30-
var EPS = require( '@stdlib/constants/float64/eps' );
3129

3230

3331
// FIXTURES //
@@ -121,9 +119,7 @@ tape( 'if provided a nonpositive `gamma`, the function always returns `NaN`', op
121119

122120
tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (large `gamma`)', opts, function test( t ) {
123121
var expected;
124-
var delta;
125122
var gamma;
126-
var tol;
127123
var x0;
128124
var x;
129125
var y;
@@ -135,22 +131,14 @@ tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (large `gam
135131
gamma = largeGamma.gamma;
136132
for ( i = 0; i < x.length; i++ ) {
137133
y = pdf( x[i], x0[i], gamma[i] );
138-
if ( y === expected[i] ) {
139-
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
140-
} else {
141-
delta = abs( y - expected[ i ] );
142-
tol = 1.0 * EPS * abs( expected[ i ] );
143-
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
144-
}
134+
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
145135
}
146136
t.end();
147137
});
148138

149139
tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (`x0 < 0`)', opts, function test( t ) {
150140
var expected;
151-
var delta;
152141
var gamma;
153-
var tol;
154142
var x0;
155143
var x;
156144
var y;
@@ -162,22 +150,14 @@ tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (`x0 < 0`)'
162150
gamma = negativeMedian.gamma;
163151
for ( i = 0; i < x.length; i++ ) {
164152
y = pdf( x[i], x0[i], gamma[i] );
165-
if ( y === expected[i] ) {
166-
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
167-
} else {
168-
delta = abs( y - expected[ i ] );
169-
tol = 1.0 * EPS * abs( expected[ i ] );
170-
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
171-
}
153+
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
172154
}
173155
t.end();
174156
});
175157

176158
tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (`x0 > 0`)', opts, function test( t ) {
177159
var expected;
178-
var delta;
179160
var gamma;
180-
var tol;
181161
var x0;
182162
var x;
183163
var y;
@@ -189,13 +169,7 @@ tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (`x0 > 0`)'
189169
gamma = positiveMedian.gamma;
190170
for ( i = 0; i < x.length; i++ ) {
191171
y = pdf( x[i], x0[i], gamma[i] );
192-
if ( y === expected[i] ) {
193-
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
194-
} else {
195-
delta = abs( y - expected[ i ] );
196-
tol = 1.0 * EPS * abs( expected[ i ] );
197-
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
198-
}
172+
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
199173
}
200174
t.end();
201175
});

lib/node_modules/@stdlib/stats/base/dists/cauchy/pdf/test/test.pdf.js

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

2323
var tape = require( 'tape' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25-
var abs = require( '@stdlib/math/base/special/abs' );
2625
var PINF = require( '@stdlib/constants/float64/pinf' );
2726
var NINF = require( '@stdlib/constants/float64/ninf' );
28-
var EPS = require( '@stdlib/constants/float64/eps' );
2927
var pdf = require( './../lib' );
3028

3129

@@ -112,9 +110,7 @@ tape( 'if provided a nonpositive `gamma`, the function always returns `NaN`', fu
112110

113111
tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (large `gamma`)', function test( t ) {
114112
var expected;
115-
var delta;
116113
var gamma;
117-
var tol;
118114
var x0;
119115
var x;
120116
var y;
@@ -126,22 +122,14 @@ tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (large `gam
126122
gamma = largeGamma.gamma;
127123
for ( i = 0; i < x.length; i++ ) {
128124
y = pdf( x[i], x0[i], gamma[i] );
129-
if ( y === expected[i] ) {
130-
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
131-
} else {
132-
delta = abs( y - expected[ i ] );
133-
tol = 1.0 * EPS * abs( expected[ i ] );
134-
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
135-
}
125+
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
136126
}
137127
t.end();
138128
});
139129

140130
tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (`x0 < 0`)', function test( t ) {
141131
var expected;
142-
var delta;
143132
var gamma;
144-
var tol;
145133
var x0;
146134
var x;
147135
var y;
@@ -153,22 +141,14 @@ tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (`x0 < 0`)'
153141
gamma = negativeMedian.gamma;
154142
for ( i = 0; i < x.length; i++ ) {
155143
y = pdf( x[i], x0[i], gamma[i] );
156-
if ( y === expected[i] ) {
157-
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
158-
} else {
159-
delta = abs( y - expected[ i ] );
160-
tol = 1.0 * EPS * abs( expected[ i ] );
161-
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
162-
}
144+
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
163145
}
164146
t.end();
165147
});
166148

167149
tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (`x0 > 0`)', function test( t ) {
168150
var expected;
169-
var delta;
170151
var gamma;
171-
var tol;
172152
var x0;
173153
var x;
174154
var y;
@@ -180,13 +160,7 @@ tape( 'the function evaluates the pdf for `x` given `x0` and `gamma` (`x0 > 0`)'
180160
gamma = positiveMedian.gamma;
181161
for ( i = 0; i < x.length; i++ ) {
182162
y = pdf( x[i], x0[i], gamma[i] );
183-
if ( y === expected[i] ) {
184-
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
185-
} else {
186-
delta = abs( y - expected[ i ] );
187-
tol = 1.0 * EPS * abs( expected[ i ] );
188-
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
189-
}
163+
t.equal( y, expected[i], 'x: '+x[i]+', x0 :'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
190164
}
191165
t.end();
192166
});

0 commit comments

Comments
 (0)