Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2025 The Stdlib Authors.
# Copyright (c) 2026 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @license Apache-2.0
#
# Copyright (c) 2025 The Stdlib Authors.
# Copyright (c) 2026 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2025 The Stdlib Authors.
# Copyright (c) 2026 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @license Apache-2.0
#
# Copyright (c) 2025 The Stdlib Authors.
# Copyright (c) 2026 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@

// MODULES //

var main = require( './main.js' );
var tryRequire = require( '@stdlib/utils/try-require' );
var polyfill = require( './main.js' );


// VARIABLES //

var kurtosis = tryRequire( require.resolve( './native.js' ) );
var main = ( kurtosis instanceof Error ) ? polyfill : kurtosis;


// EXPORTS //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2025 The Stdlib Authors.
# Copyright (c) 2026 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// MODULES //

var tape = require( 'tape' );
var proxyquire = require( 'proxyquire' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var NINF = require( '@stdlib/constants/float64/ninf' );
Expand Down Expand Up @@ -83,3 +84,21 @@ tape( 'the function returns the excess kurtosis of a chi distribution', function
}
t.end();
});

tape( 'if a native implementation is not available, the main export is a JavaScript implementation', function test( t ) {
var kurtosis;
var main;

main = require( './../lib/main.js' );

kurtosis = proxyquire( './../lib', {
'@stdlib/utils/try-require': tryRequire
});

t.strictEqual( kurtosis, main, 'returns expected value' );
t.end();

function tryRequire() {
return new Error( 'Cannot find module' );
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var tape = require( 'tape' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var NINF = require( '@stdlib/constants/float64/ninf' );


// FIXTURES //

var data = require( './fixtures/julia/data.json' );


// VARIABLES //

var kurtosis = require( './../lib/main.js' );


// TESTS //

tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof kurtosis, 'function', 'main export is a function' );
t.end();
});

tape( 'if provided `NaN` for `k`, the function returns `NaN`', function test( t ) {
var v = kurtosis( NaN );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
});

tape( 'if provided a degrees of freedom parameter `k` that is not a positive number, the function returns `NaN`', function test( t ) {
var v;

v = kurtosis( -1.0 );
t.strictEqual( isnan( v ), true, 'returns expected value' );

v = kurtosis( 0.0 );
t.strictEqual( isnan( v ), true, 'returns expected value' );

v = kurtosis( NINF );
t.strictEqual( isnan( v ), true, 'returns expected value' );

t.end();
});

tape( 'the function returns the excess kurtosis of a chi distribution', function test( t ) {
var expected;
var delta;
var tol;
var k;
var i;
var y;

expected = data.expected;
k = data.k;
for ( i = 0; i < expected.length; i++ ) {
y = kurtosis( k[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'k:'+k[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 1e-8 * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. k: '+k[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
}
t.end();
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down