Skip to content

Commit d5f2b9a

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: 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 cc2d62e commit d5f2b9a

File tree

4 files changed

+46
-24
lines changed

4 files changed

+46
-24
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ for ( i = 0; i < 10; i++ ) {
163163
Evaluates the [probability density function][pdf] (PDF) for a [Student's t][t-distribution] distribution with degrees of freedom `v`.
164164

165165
```c
166-
double out = stdlib_base_dists_t_pdf( 0.5, 2.0 );
167-
// returns ~0.352
166+
double out = stdlib_base_dists_t_pdf( 0.3, 4.0 );
167+
// returns ~0.355
168168
```
169169

170170
The function accepts the following arguments:

lib/node_modules/@stdlib/stats/base/dists/t/pdf/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/binary.h"
2020
#include "stdlib/stats/base/dists/t/pdf.h"
2121

22-
// cppcheck-suppress shadowFunction
2322
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_t_pdf )

lib/node_modules/@stdlib/stats/base/dists/t/pdf/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
* @return evaluated PDF
3131
*
3232
* @example
33-
* double y = stdlib_base_dists_t_pdf( 2.0, 1.0 );
34-
* // returns ~0.063
33+
* double y = stdlib_base_dists_t_pdf( 0.3, 4.0 );
34+
* // returns ~0.355
3535
*/
3636
double stdlib_base_dists_t_pdf( const double x, const double v ) {
3737
double betaTerm;

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

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ var tape = require( 'tape' );
2525
var tryRequire = require( '@stdlib/utils/try-require' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var abs = require( '@stdlib/math/base/special/abs' );
28-
var max = require( '@stdlib/math/base/special/max' );
2928
var PINF = require( '@stdlib/constants/float64/pinf' );
3029
var NINF = require( '@stdlib/constants/float64/ninf' );
3130
var EPS = require( '@stdlib/constants/float64/eps' );
@@ -63,31 +62,55 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, f
6362
t.end();
6463
});
6564

66-
tape( 'if provided `+infinity` for `x` and a valid `v`, the function returns `0`', opts, function test( t ) {
65+
tape( 'if provided `+infinity` for `x` and a finite `v`, the function returns `0`', opts, function test( t ) {
6766
var y = pdf( PINF, 1.0 );
6867
t.equal( y, 0.0, 'returns 0' );
6968
t.end();
7069
});
7170

72-
tape( 'if provided `-infinity` for `x` and a valid `v`, the function returns `0`', opts, function test( t ) {
71+
tape( 'if provided `-infinity` for `x` and a finite `v`, the function returns `0`', opts, function test( t ) {
7372
var y = pdf( NINF, 1.0 );
7473
t.equal( y, 0.0, 'returns 0' );
7574
t.end();
7675
});
7776

78-
tape( 'if provided `v <= 0`, the function returns `NaN`', opts, function test( t ) {
77+
tape( 'if provided `+infinity` for `v`, the function returns `NaN`', opts, function test( t ) {
7978
var y;
8079

80+
y = pdf( 0.0, PINF );
81+
t.equal( isnan( y ), true, 'returns NaN' );
82+
83+
y = pdf( NaN, PINF );
84+
t.equal( isnan( y ), true, 'returns NaN' );
85+
86+
y = pdf( PINF, PINF );
87+
t.equal( isnan( y ), true, 'returns NaN' );
88+
89+
y = pdf( NINF, PINF );
90+
t.equal( isnan( y ), true, 'returns NaN' );
91+
92+
t.end();
93+
});
94+
95+
tape( 'if provided a nonpositive `v`, the function always returns `NaN`', opts, function test( t ) {
96+
var y;
97+
98+
y = pdf( 2.0, 0.0 );
99+
t.equal( isnan( y ), true, 'returns NaN' );
100+
81101
y = pdf( 2.0, -1.0 );
82102
t.equal( isnan( y ), true, 'returns NaN' );
83103

84-
y = pdf( 0.0, 0.0 );
104+
y = pdf( 0.0, -1.0 );
105+
t.equal( isnan( y ), true, 'returns NaN' );
106+
107+
y = pdf( 2.0, NINF );
85108
t.equal( isnan( y ), true, 'returns NaN' );
86109

87110
t.end();
88111
});
89112

90-
tape( 'the function evaluates the pdf for `x` given a small range `v`', opts, function test( t ) {
113+
tape( 'the function evaluates the pdf for `x` given parameter `v` (when `x` and `v` are small)', opts, function test( t ) {
91114
var expected;
92115
var delta;
93116
var tol;
@@ -105,14 +128,14 @@ tape( 'the function evaluates the pdf for `x` given a small range `v`', opts, fu
105128
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
106129
} else {
107130
delta = abs( y - expected[ i ] );
108-
tol = max( 2.0 * EPS * abs( expected[ i ] ), 1.0e-14 );
131+
tol = 10.0 * EPS * abs( expected[ i ] );
109132
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
110133
}
111134
}
112135
t.end();
113136
});
114137

115-
tape( 'the function evaluates the pdf for `x` given a medium range `v`', opts, function test( t ) {
138+
tape( 'the function evaluates the pdf for `x` given parameter `v` (when `x` is large and `v` small)', opts, function test( t ) {
116139
var expected;
117140
var delta;
118141
var tol;
@@ -121,23 +144,23 @@ tape( 'the function evaluates the pdf for `x` given a medium range `v`', opts, f
121144
var y;
122145
var i;
123146

124-
expected = smallLarge.expected;
125-
x = smallLarge.x;
126-
v = smallLarge.v;
147+
expected = largeSmall.expected;
148+
x = largeSmall.x;
149+
v = largeSmall.v;
127150
for ( i = 0; i < x.length; i++ ) {
128151
y = pdf( x[ i ], v[ i ] );
129152
if ( y === expected[ i ] ) {
130153
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
131154
} else {
132155
delta = abs( y - expected[ i ] );
133-
tol = max( 2.0 * EPS * abs( expected[ i ] ), 1.0e-14 );
156+
tol = 10.0 * EPS * abs( expected[ i ] );
134157
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
135158
}
136159
}
137160
t.end();
138161
});
139162

140-
tape( 'the function evaluates the pdf for `x` given a large range `v`', opts, function test( t ) {
163+
tape( 'the function evaluates the pdf for `x` given parameter `v` (when `x` is small and `v` large)', opts, function test( t ) {
141164
var expected;
142165
var delta;
143166
var tol;
@@ -146,23 +169,23 @@ tape( 'the function evaluates the pdf for `x` given a large range `v`', opts, fu
146169
var y;
147170
var i;
148171

149-
expected = largeSmall.expected;
150-
x = largeSmall.x;
151-
v = largeSmall.v;
172+
expected = smallLarge.expected;
173+
x = smallLarge.x;
174+
v = smallLarge.v;
152175
for ( i = 0; i < x.length; i++ ) {
153176
y = pdf( x[ i ], v[ i ] );
154177
if ( y === expected[ i ] ) {
155178
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
156179
} else {
157180
delta = abs( y - expected[ i ] );
158-
tol = max( 2.0 * EPS * abs( expected[ i ] ), 1.0e-14 );
181+
tol = 40.0 * EPS * abs( expected[ i ] );
159182
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
160183
}
161184
}
162185
t.end();
163186
});
164187

165-
tape( 'the function evaluates the pdf for `x` given a large range `v`', opts, function test( t ) {
188+
tape( 'the function evaluates the pdf for `x` given parameter `v` (when `x` and `v` are large)', opts, function test( t ) {
166189
var expected;
167190
var delta;
168191
var tol;
@@ -180,7 +203,7 @@ tape( 'the function evaluates the pdf for `x` given a large range `v`', opts, fu
180203
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
181204
} else {
182205
delta = abs( y - expected[ i ] );
183-
tol = max( 2.0 * EPS * abs( expected[ i ] ), 1.0e-14 );
206+
tol = 40.0 * EPS * abs( expected[ i ] );
184207
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
185208
}
186209
}

0 commit comments

Comments
 (0)