Skip to content

Commit

Permalink
chore: minor clean-up
Browse files Browse the repository at this point in the history
---
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: passed
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
  • Loading branch information
Planeshifter committed Dec 24, 2024
1 parent 90e96d0 commit ed5c4cc
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ function identity( value: number ): number {
unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ] ); // $ExpectError
unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity ); // $ExpectError
unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, identity, {}, {} ); // $ExpectError
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 1.5
JSON 0.21
julia 1.5
JSON 0.21
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var tryRequire = require( '@stdlib/utils/try-require' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );


// VARIABLES //
Expand Down Expand Up @@ -71,22 +69,14 @@ tape( 'if provided a rate parameter `lambda` that is not a nonnegative number, t
tape( 'the function returns the mode of an exponential distribution', opts, function test( t ) {
var expected;
var lambda;
var delta;
var tol;
var i;
var y;

expected = data.expected;
lambda = data.lambda;
for ( i = 0; i < expected.length; i++ ) {
y = mode( lambda[i] );
if ( y === expected[ i ] ) {
t.equal( y, expected[i], 'lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 2.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.equal( y, expected[i], 'lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ double out = stdlib_base_dists_f_entropy( 3.0, 7.0 );
The function accepts the following arguments:

- **d1**: `[in] double` numerator degrees of freedom.
- **d2**: `[in] double` maximum support.
- **d2**: `[in] double` denominator degrees of freedom.

```c
double stdlib_base_dists_f_entropy( const double d1, const double d2 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ tape( 'if provided a nonpositive `beta`, the function returns `NaN`', function t
});

tape( 'the function returns `~1.14` as the skewness of a Gumbel distribution ', function test( t ) {
var a;
var b;
var beta;
var mu;
var i;
var v;

for ( i = 0; i < 10; i++ ) {
a = ( randu()*10.0 );
b = ( randu()*10.0 ) + a;
v = skewness( a, b );
mu = ( randu()*10.0 );
beta = ( randu()*10.0 ) + 1.0;
v = skewness( mu, beta );
t.equal( v, 1.1395470994046488, 'returns ~1.14' );
}
t.end();
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/stats/base/dists/t/logpdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ for ( i = 0; i < 10; i++ ) {
#include "stdlib/stats/base/dists/t/logpdf.h"
```

#### stdlib_base_dists_t_logpdf( x, a, b )
#### stdlib_base_dists_t_logpdf( x, v )

Evaluates the natural logarithm of the [PDF][pdf] for a [Student's t][t-distribution] distribution with degree of freedom `v`.
Evaluates the natural logarithm of the [probability density function][pdf] (PDF) for a [Student's t][t-distribution] distribution with degrees of freedom `v`.

```c
double out = stdlib_base_dists_t_logpdf( 0.5, 1.0 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* limitations under the License.
*/

#include <sys/time.h>
#include "stdlib/stats/base/dists/t/logpdf.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>

#define NAME "t-logpdf"
#define ITERATIONS 1000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* limitations under the License.
*/

#include "stdlib/stats/base/dists/t/logpdf.h"
#include "stdlib/math/base/assert/is_nan.h"
#include "stdlib/math/base/special/betaln.h"
#include "stdlib/math/base/special/ln.h"
#include "stdlib/math/base/special/pow.h"
#include "stdlib/math/base/special/sqrt.h"
#include "stdlib/stats/base/dists/t/logpdf.h"

/**
* Evaluates the log probability density function (logPDF) for a Student's t distribution with degrees of freedom `v` at a value `x`.
Expand Down
114 changes: 70 additions & 44 deletions lib/node_modules/@stdlib/stats/base/dists/t/logpdf/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var tape = require( 'tape' );
var tryRequire = require( '@stdlib/utils/try-require' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );


Expand Down Expand Up @@ -60,19 +62,55 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, f
t.end();
});

tape( 'if provided `v <= 0`, the function returns `NaN`', opts, function test( t ) {
tape( 'if provided `Infinity` for `x` and a finite `v`, the function returns `-Infinity`', opts, function test( t ) {
var y = logpdf( PINF, 1.0 );
t.equal( y, NINF, 'returns -Infinity' );
t.end();
});

tape( 'if provided `-Infinity` for `x` and a finite `v`, the function returns `-Infinity`', opts, function test( t ) {
var y = logpdf( NINF, 1.0 );
t.equal( y, NINF, 'returns -Infinity' );
t.end();
});

tape( 'if provided `Infinity` for `v`, the function returns `NaN`', opts, function test( t ) {
var y;

y = logpdf( 0.0, PINF );
t.equal( isnan( y ), true, 'returns NaN' );

y = logpdf( NaN, PINF );
t.equal( isnan( y ), true, 'returns NaN' );

y = logpdf( PINF, PINF );
t.equal( isnan( y ), true, 'returns NaN' );

y = logpdf( NINF, PINF );
t.equal( isnan( y ), true, 'returns NaN' );

t.end();
});

tape( 'if provided a nonpositive `v`, the function always returns `NaN`', opts, function test( t ) {
var y;

y = logpdf( 2.0, 0.0 );
t.equal( isnan( y ), true, 'returns NaN' );

y = logpdf( 2.0, -1.0 );
t.equal( isnan( y ), true, 'returns NaN' );

y = logpdf( 0.0, -1.0 );
t.equal( isnan( y ), true, 'returns NaN' );

y = logpdf( 0.0, 0.0 );
y = logpdf( 2.0, NINF );
t.equal( isnan( y ), true, 'returns NaN' );

t.end();
});

tape( 'the function evaluates the logpdf for `x` given a large range of `v` and `x`', opts, function test( t ) {
tape( 'the function evaluates the logpdf for `x` given parameter `v` (when `x` and `v` are small)', opts, function test( t ) {
var expected;
var delta;
var tol;
Expand All @@ -81,26 +119,23 @@ tape( 'the function evaluates the logpdf for `x` given a large range of `v` and
var y;
var i;

expected = largeLarge.expected;
x = largeLarge.x;
v = largeLarge.v;
expected = smallSmall.expected;
x = smallSmall.x;
v = smallSmall.v;
for ( i = 0; i < x.length; i++ ) {
y = logpdf( x[ i ], v[ i ] );
if ( y === expected[ i ] ) {
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
y = logpdf( x[i], v[i] );
if ( y === expected[i] ) {
t.equal( y, expected[i], 'x: '+x[i]+'. v: '+v[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 2.0 * EPS * abs( expected[ i ] );
if ( tol < 1e-14 ) {
tol = 1e-14; // Set a minimum tolerance
}
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. v: '+v[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
}
t.end();
});

tape( 'the function evaluates the logpdf for `x` given a large range of `v` and small range of `x`', opts, function test( t ) {
tape( 'the function evaluates the logpdf for `x` given parameter `v` (when `x` is large and `v` small)', opts, function test( t ) {
var expected;
var delta;
var tol;
Expand All @@ -113,22 +148,19 @@ tape( 'the function evaluates the logpdf for `x` given a large range of `v` and
x = largeSmall.x;
v = largeSmall.v;
for ( i = 0; i < x.length; i++ ) {
y = logpdf( x[ i ], v[ i ] );
if ( y === expected[ i ] ) {
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
y = logpdf( x[i], v[i] );
if ( y === expected[i] ) {
t.equal( y, expected[i], 'x: '+x[i]+'. v: '+v[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 2.0 * EPS * abs( expected[ i ] );
if ( tol < 1e-14 ) {
tol = 1e-14; // Set a minimum tolerance
}
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. v: '+v[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
}
t.end();
});

tape( 'the function evaluates the logpdf for `x` given a small range of `v` and large range of `x`', opts, function test( t ) {
tape( 'the function evaluates the logpdf for `x` given parameter `v` (when `x` is small and `v` large)', opts, function test( t ) {
var expected;
var delta;
var tol;
Expand All @@ -141,22 +173,19 @@ tape( 'the function evaluates the logpdf for `x` given a small range of `v` and
x = smallLarge.x;
v = smallLarge.v;
for ( i = 0; i < x.length; i++ ) {
y = logpdf( x[ i ], v[ i ] );
if ( y === expected[ i ] ) {
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
y = logpdf( x[i], v[i] );
if ( y === expected[i] ) {
t.equal( y, expected[i], 'x: '+x[i]+'. v: '+v[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 2.0 * EPS * abs( expected[ i ] );
if ( tol < 1e-14 ) {
tol = 1e-14; // Set a minimum tolerance
}
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
tol = 50.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. v: '+v[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
}
t.end();
});

tape( 'the function evaluates the logpdf for `x` given a small range of `v` and `x`', opts, function test( t ) {
tape( 'the function evaluates the logpdf for `x` given parameter `v` (when `x` and `v` are large)', opts, function test( t ) {
var expected;
var delta;
var tol;
Expand All @@ -165,20 +194,17 @@ tape( 'the function evaluates the logpdf for `x` given a small range of `v` and
var y;
var i;

expected = smallSmall.expected;
x = smallSmall.x;
v = smallSmall.v;
expected = largeLarge.expected;
x = largeLarge.x;
v = largeLarge.v;
for ( i = 0; i < x.length; i++ ) {
y = logpdf( x[ i ], v[ i ] );
if ( y === expected[ i ] ) {
t.equal( y, expected[ i ], 'x: ' + x[ i ] + ', v: ' + v[ i ] + ', y: ' + y + ', expected: ' + expected[ i ] );
y = logpdf( x[i], v[i] );
if ( y === expected[i] ) {
t.equal( y, expected[i], 'x: '+x[i]+'. v: '+v[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 2.0 * EPS * abs( expected[ i ] );
if ( tol < 1e-14 ) {
tol = 1e-14; // Set a minimum tolerance
}
t.ok( delta <= tol, 'within tolerance. x: ' + x[ i ] + '. v: ' + v[ i ] + '. y: ' + y + '. E: ' + expected[ i ] + '. Δ: ' + delta + '. tol: ' + tol + '.' );
tol = 40.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. v: '+v[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
}
t.end();
Expand Down

0 comments on commit ed5c4cc

Please sign in to comment.