Skip to content

Commit f12f0ef

Browse files
author
aayush0325
committed
feat: c bug fix and tests added
1 parent 63d0820 commit f12f0ef

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

lib/node_modules/@stdlib/stats/base/dists/arcsine/kurtosis/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ double stdlib_base_dists_arcsine_kurtosis( const double a, const double b ) {
3838
) {
3939
return 0.0 / 0.0; // NaN
4040
}
41-
return 1.5;
41+
return -1.5;
4242
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 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 resolve = require( 'path' ).resolve;
24+
var tape = require( 'tape' );
25+
var tryRequire = require( '@stdlib/utils/try-require' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var randu = require( '@stdlib/random/base/randu' );
28+
var PINF = require( '@stdlib/constants/float64/pinf' );
29+
var NINF = require( '@stdlib/constants/float64/ninf' );
30+
31+
32+
// VARIABLES //
33+
34+
var kurtosis = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( kurtosis instanceof Error )
37+
};
38+
39+
40+
// TESTS //
41+
42+
tape( 'main export is a function', opts, function test( t ) {
43+
t.ok( true, __filename );
44+
t.strictEqual( typeof kurtosis, 'function', 'main export is a function' );
45+
t.end();
46+
});
47+
48+
tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, function test( t ) {
49+
var v = kurtosis( NaN, 0.5 );
50+
t.equal( isnan( v ), true, 'returns NaN' );
51+
52+
v = kurtosis( 10.0, NaN );
53+
t.equal( isnan( v ), true, 'returns NaN' );
54+
55+
t.end();
56+
});
57+
58+
tape( 'if provided `a >= b`, the function returns `NaN`', opts, function test( t ) {
59+
var y;
60+
61+
y = kurtosis( 3.0, 2.0 );
62+
t.equal( isnan( y ), true, 'returns NaN' );
63+
64+
y = kurtosis( 2.0, 2.0 );
65+
t.equal( isnan( y ), true, 'returns NaN' );
66+
67+
y = kurtosis( NINF, NINF );
68+
t.equal( isnan( y ), true, 'returns NaN' );
69+
70+
y = kurtosis( PINF, NINF );
71+
t.equal( isnan( y ), true, 'returns NaN' );
72+
73+
t.end();
74+
});
75+
76+
tape( 'the function returns `-3/2` as the excess kurtosis of an arcsine distribution ', opts, function test( t ) {
77+
var a;
78+
var b;
79+
var i;
80+
var v;
81+
82+
for ( i = 0; i < 10; i++ ) {
83+
a = ( randu() *10.0 );
84+
b = ( randu()*10.0 ) + a;
85+
v = kurtosis( a, b );
86+
t.equal( v, -3/2, 'returns -3/2' );
87+
}
88+
t.end();
89+
});

0 commit comments

Comments
 (0)