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
Expand Up @@ -112,7 +112,7 @@ Returns the [excess kurtosis][kurtosis].
var kumaraswamy = new Kumaraswamy( 4.0, 12.0 );

var kurtosis = kumaraswamy.kurtosis;
// returns ~2.704
// returns ~-0.296
```

#### Kumaraswamy.prototype.mean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
> kumaraswamy.b
5.0
> kumaraswamy.kurtosis
~3.194
~0.194
> kumaraswamy.mean
~0.696
> kumaraswamy.mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function Kumaraswamy() {
* var kumaraswamy = new Kumaraswamy( 4.0, 12.0 );
*
* var v = kumaraswamy.kurtosis;
* // returns ~2.704
* // returns ~-0.296
*/
setReadOnlyAccessor( Kumaraswamy.prototype, 'kurtosis', function get() {
return kurtosis( this.a, this.b );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ limitations under the License.

The [excess kurtosis][kurtosis] for a [Kumaraswamy's double bounded][kumaraswamy-distribution] random variable with first shape parameter `a` and second shape parameter `b` is

<!-- <equation class="equation" label="eq:kumaraswamy_kurtosis" align="center" raw="\operatorname{Kurt}\left( X \right) = \frac{ m_4 - ( 4.0 \cdot m_3 \cdot m_1 ) + ( 6.0 \cdot m_2 \cdot m_1^2 ) - ( 3.0 \cdot m_1^4 ) ) }{\left( m_2 - m_1^2 \right)^2}" alt="Excess kurtosis for a Kumaraswamy's double bounded distribution."> -->
<!-- <equation class="equation" label="eq:kumaraswamy_kurtosis" align="center" raw="\operatorname{Kurt}\left( X \right) = \frac{ m_4 - ( 4.0 \cdot m_3 \cdot m_1 ) + ( 6.0 \cdot m_2 \cdot m_1^2 ) - ( 3.0 \cdot m_1^4 ) }{\left( m_2 - m_1^2 \right)^2} - 3" alt="Excess kurtosis for a Kumaraswamy's double bounded distribution."> -->

```math
\mathop{\mathrm{Kurt}}\left( X \right) = \frac{ m_4 - ( 4.0 \cdot m_3 \cdot m_1 ) + ( 6.0 \cdot m_2 \cdot m_1^2 ) - ( 3.0 \cdot m_1^4 ) ) }{\left( m_2 - m_1^2 \right)^2}
\mathop{\mathrm{Kurt}}\left( X \right) = \frac{ m_4 - ( 4.0 \cdot m_3 \cdot m_1 ) + ( 6.0 \cdot m_2 \cdot m_1^2 ) - ( 3.0 \cdot m_1^4 ) }{\left( m_2 - m_1^2 \right)^2} - 3
```

<!-- <div class="equation" align="center" data-raw-text="\operatorname{Kurt}\left( X \right) = \frac{ m_4 - ( 4.0 \cdot m_3 \cdot m_1 ) + ( 6.0 \cdot m_2 \cdot m_1^2 ) - ( 3.0 \cdot m_1^4 ) ) }{\left( m_2 - m_1^2 \right)^2}" data-equation="eq:kumaraswamy_kurtosis">
<!-- <div class="equation" align="center" data-raw-text="\operatorname{Kurt}\left( X \right) = \frac{ m_4 - ( 4.0 \cdot m_3 \cdot m_1 ) + ( 6.0 \cdot m_2 \cdot m_1^2 ) - ( 3.0 \cdot m_1^4 ) }{\left( m_2 - m_1^2 \right)^2} - 3" data-equation="eq:kumaraswamy_kurtosis">
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@591cf9d5c3a0cd3c1ceec961e5c49d73a68374cb/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/kurtosis/docs/img/equation_kumaraswamy_kurtosis.svg" alt="Excess kurtosis for a Kumaraswamy's double bounded distribution.">
<br>
</div> -->
Expand Down Expand Up @@ -78,13 +78,13 @@ Returns the [excess kurtosis][kurtosis] of a [Kumaraswamy's double bounded][kuma

```javascript
var v = kurtosis( 1.0, 1.0 );
// returns ~1.8
// returns ~-1.2

v = kurtosis( 4.0, 12.0 );
// returns ~2.704
// returns ~-0.296

v = kurtosis( 2.0, 8.0 );
// returns ~2.666
// returns ~-0.334
```

If provided `NaN` as any argument, the function returns `NaN`.
Expand Down Expand Up @@ -187,7 +187,7 @@ Returns the [excess kurtosis][kurtosis] of a [Kumaraswamy's double bounded][kuma

```c
double v = stdlib_base_dists_kumaraswamy_kurtosis( 0.5, 1.0 );
// returns ~2.143
// returns ~-0.857
```

The function accepts the following arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
Examples
--------
> var v = {{alias}}( 1.0, 1.0 )
~1.8
~-1.2
> v = {{alias}}( 4.0, 12.0 )
~2.704
~-0.296
> v = {{alias}}( 16.0, 8.0 )
~4.311
~1.311

See Also
--------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
*
* @example
* var v = kurtosis( 0.5, 1.0 );
* // returns ~2.143
* // returns ~-0.857
*
* @example
* var v = kurtosis( 4.0, 12.0 );
* // returns ~2.704
* // returns ~-0.296
*
* @example
* var v = kurtosis( 12.0, 2.0 );
* // returns ~4.817
* // returns ~1.817
*
* @example
* var v = kurtosis( 1.0, -0.1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
* var kurtosis = require( '@stdlib/stats/base/dists/kumaraswamy/kurtosis' );
*
* var v = kurtosis( 2.0, 1.0 );
* // returns ~2.4
* // returns ~-0.6
*
* v = kurtosis( 4.0, 12.0 );
* // returns ~2.704
* // returns ~-0.296
*
* v = kurtosis( 16.0, 8.0 );
* // returns ~4.311
* // returns ~1.311
*/

// MODULES //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ var beta = require( '@stdlib/math/base/special/beta' );
*
* @example
* var v = kurtosis( 0.5, 1.0 );
* // returns ~2.143
* // returns ~-0.857
*
* @example
* var v = kurtosis( 4.0, 12.0 );
* // returns ~2.704
* // returns ~-0.296
*
* @example
* var v = kurtosis( 12.0, 2.0 );
* // returns ~4.817
* // returns ~1.817
*
* @example
* var v = kurtosis( 1.0, -0.1 );
Expand Down Expand Up @@ -85,7 +85,7 @@ function kurtosis( a, b ) {
mu2 = m1 * m1;
out = ( m4 - ( 4.0*m3*m1 ) + ( 6.0*m2*mu2 ) - ( 3.0*mu2*mu2 ) );
out /= sigma2*sigma2;
return out;
return out - 3.0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ var addon = require( './../src/addon.node' );
*
* @example
* var v = kurtosis( 0.5, 1.0 );
* // returns ~2.143
* // returns ~-0.857
*
* @example
* var v = kurtosis( 4.0, 12.0 );
* // returns ~2.704
* // returns ~-0.296
*
* @example
* var v = kurtosis( 12.0, 2.0 );
* // returns ~4.817
* // returns ~1.817
*
* @example
* var v = kurtosis( 1.0, -0.1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @example
* double v = stdlib_base_dists_kumaraswamy_kurtosis( 0.5, 1.0 );
* // returns ~2.143
* // returns ~-0.857
*/
double stdlib_base_dists_kumaraswamy_kurtosis( const double a, const double b ) {
double sigma2;
Expand All @@ -55,6 +55,6 @@ double stdlib_base_dists_kumaraswamy_kurtosis( const double a, const double b )
mu2 = m1 * m1;
out = ( m4 - ( 4.0*m3*m1 ) + ( 6.0*m2*mu2 ) - ( 3.0*mu2*mu2 ) );
out /= sigma2*sigma2;
return out;
return out - 3.0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Distributions 0.23.8
julia 1.5
JSON 0.21

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env julia
#
# @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.

import Distributions: kurtosis, Kumaraswamy
import JSON

"""
gen( a, b, name )

Generate fixture data and write to file.

# Arguments

* `a`: shape parameter a (must be positive)
* `b`: shape parameter b (must be positive)
* `name::AbstractString`: output filename

# Examples

``` julia
julia> a = rand( 1000 );
julia> b = rand( 1000 );
julia> gen( a, b, \"data.json\" );
```
"""
function gen( a, b, name )
z = Array{Float64}( undef, length(a) );
for i in eachindex(a)
z[ i ] = kurtosis( Kumaraswamy( a[ i ], b[ i ] ) );
end

# Store data to be written to file as a collection:
data = Dict([
("a", a),
("b", b),
("expected", z)
]);

# Based on the script directory, create an output filepath:
filepath = joinpath( dir, name );

# Write the data to the output filepath as JSON:
outfile = open( filepath, "w" );
write( outfile, JSON.json(data) );
write( outfile, "\n" );
close( outfile );
end

# Get the filename:
file = @__FILE__;

# Extract the directory in which this file resides:
dir = dirname( file );

# Generate fixtures:
a = rand( 1000 );
b = rand( 1000 );
gen( a, b, "data.json" );
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@
// MODULES //

var tape = require( 'tape' );
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var randu = require( '@stdlib/random/base/randu' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var kurtosis = require( './../lib' );


// FIXTURES //

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


// TESTS //

tape( 'main export is a function', function test( t ) {
Expand Down Expand Up @@ -100,17 +103,18 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', function test
});

tape( 'the function returns the excess kurtosis of a Kumaraswamy\'s double bounded distribution', function test( t ) {
var expected;
var a;
var b;
var i;
var y;

// TODO: Add fixtures
for ( i = 0; i < 100; i++ ) {
a = ( randu()*5.0 ) + EPS;
b = ( randu()*5.0 ) + EPS;
y = kurtosis( a, b );
t.strictEqual( isNumber( y ), true, 'returns expected value' );
expected = data.expected;
a = data.a;
b = data.b;
for ( i = 0; i < expected.length; i++ ) {
y = kurtosis( a[i], b[i] );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1043762 ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var tryRequire = require( '@stdlib/utils/try-require' );
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var randu = require( '@stdlib/random/base/randu' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );


// FIXTURES //

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


// VARIABLES //
Expand Down Expand Up @@ -112,17 +115,18 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', opts, functio
});

tape( 'the function returns the excess kurtosis of a Kumaraswamy\'s double bounded distribution', opts, function test( t ) {
var expected;
var a;
var b;
var i;
var y;

// TODO: Add fixtures
for ( i = 0; i < 100; i++ ) {
a = ( randu()*5.0 ) + EPS;
b = ( randu()*5.0 ) + EPS;
y = kurtosis( a, b );
t.strictEqual( isNumber( y ), true, 'returns expected value' );
expected = data.expected;
a = data.a;
b = data.b;
for ( i = 0; i < expected.length; i++ ) {
y = kurtosis( a[i], b[i] );
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1043762 ), true, 'returns expected value' );
}
t.end();
});
Loading