Skip to content

Commit 8f01ad8

Browse files
committed
refactor: apply suggestions from PR review
--- 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: missing_dependencies - 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: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - 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 7267f00 commit 8f01ad8

File tree

5 files changed

+57
-53
lines changed

5 files changed

+57
-53
lines changed

lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/lib/factory.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,7 @@
2323
var constantFunction = require( '@stdlib/utils/constant-function' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var exp = require( '@stdlib/math/base/special/exp' );
26-
var expm1 = require( '@stdlib/math/base/special/expm1' );
27-
28-
29-
// FUNCTIONS //
30-
31-
/**
32-
* Helper function for repeated computation in the MGF formula.
33-
*
34-
* @private
35-
* @param {number} x - input value
36-
* @returns {number} evaluated result
37-
*/
38-
function phi2( x ) {
39-
if ( x === 0 ) {
40-
return 1;
41-
}
42-
return ( 2 * ( expm1( x ) - x ) ) / ( x * x );
43-
}
26+
var phi2 = require( './phi2.js' );
4427

4528

4629
// MAIN //
@@ -90,12 +73,7 @@ function factory( a, b, c ) {
9073
}
9174
if ( a < c ) {
9275
if ( c < b ) {
93-
return (
94-
exp( c * t ) * (
95-
( ( c - a ) * phi2( ( a - c ) * t ) ) +
96-
( ( b - c ) * phi2( ( b - c ) * t ) )
97-
) / ( b - a )
98-
);
76+
return exp( c*t ) * ( ( (c-a)*phi2( (a-c)*t ) ) + ( (b-c)*phi2( (b-c)*t ) ) ) / ( b-a ); // eslint-disable-line max-len
9977
}
10078
return exp( c * t ) * phi2( ( a - c ) * t );
10179
}

lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/lib/main.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,7 @@
2222

2323
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2424
var exp = require( '@stdlib/math/base/special/exp' );
25-
var expm1 = require( '@stdlib/math/base/special/expm1' );
26-
27-
28-
// FUNCTIONS //
29-
30-
/**
31-
* Helper function for repeated computation in the MGF formula.
32-
*
33-
* @private
34-
* @param {number} x - input value
35-
* @returns {number} evaluated result
36-
*/
37-
function phi2( x ) {
38-
if ( x === 0 ) {
39-
return 1;
40-
}
41-
return ( 2 * ( expm1( x ) - x ) ) / ( x * x );
42-
}
25+
var phi2 = require( './phi2.js' );
4326

4427

4528
// MAIN //
@@ -102,12 +85,7 @@ function mgf( t, a, b, c ) {
10285
}
10386
if ( a < c ) {
10487
if ( c < b ) {
105-
return (
106-
exp( c * t ) * (
107-
( ( c - a ) * phi2( ( a - c ) * t ) ) +
108-
( ( b - c ) * phi2( ( b - c ) * t ) )
109-
) / ( b - a )
110-
);
88+
return exp( c*t ) * ( ( (c-a)*phi2( (a-c)*t ) ) + ( (b-c)*phi2( (b-c)*t ) ) ) / ( b-a ); // eslint-disable-line max-len
11189
}
11290
return exp( c * t ) * phi2( ( a - c ) * t );
11391
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var expm1 = require( '@stdlib/math/base/special/expm1' );
24+
25+
26+
// MAIN //
27+
28+
/**
29+
* Helper function for repeated computation in the MGF formula.
30+
*
31+
* @param {number} x - input value
32+
* @returns {number} evaluated result
33+
*
34+
* @example
35+
* var y = phi2( 0.0 );
36+
* // returns 1.0
37+
*
38+
* @example
39+
* var y = phi2( 1.0 );
40+
* // returns ~1.437
41+
*/
42+
function phi2( x ) {
43+
if ( x === 0.0 ) {
44+
return 1.0;
45+
}
46+
return ( 2.0 * ( expm1( x ) - x ) ) / ( x * x );
47+
}
48+
49+
module.exports = phi2;

lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/src/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
/**
2525
* Helper function for repeated computation in the MGF formula.
2626
*
27-
* @private
2827
* @param x input value
2928
* @return evaluated result
3029
*/

lib/node_modules/@stdlib/stats/base/dists/triangular/mgf/test/test.factory.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ tape( 'the created function evaluates the MGF for `x` given a large range `b - a
229229
t.end();
230230
});
231231

232-
tape( 'the function evaluates the MGF for `x` given the case: a < c < b', function test( t ) {
232+
tape( 'the created function evaluates the MGF for `x` given the case: a < c < b', function test( t ) {
233233
var expected;
234234
var delta;
235235
var mgf;
@@ -260,7 +260,7 @@ tape( 'the function evaluates the MGF for `x` given the case: a < c < b', functi
260260
t.end();
261261
});
262262

263-
tape( 'the function evaluates the MGF for `x` given the case: a < c = b', function test( t ) {
263+
tape( 'the created function evaluates the MGF for `x` given the case: a < c = b', function test( t ) {
264264
var expected;
265265
var delta;
266266
var mgf;
@@ -291,7 +291,7 @@ tape( 'the function evaluates the MGF for `x` given the case: a < c = b', functi
291291
t.end();
292292
});
293293

294-
tape( 'the function evaluates the MGF for `x` given the case: a = c < b', function test( t ) {
294+
tape( 'the created function evaluates the MGF for `x` given the case: a = c < b', function test( t ) {
295295
var expected;
296296
var delta;
297297
var mgf;
@@ -322,7 +322,7 @@ tape( 'the function evaluates the MGF for `x` given the case: a = c < b', functi
322322
t.end();
323323
});
324324

325-
tape( 'the function evaluates the MGF for `x` given the case: a = c = b', function test( t ) {
325+
tape( 'the created function evaluates the MGF for `x` given the case: a = c = b', function test( t ) {
326326
var expected;
327327
var delta;
328328
var mgf;

0 commit comments

Comments
 (0)