1818
1919'use strict' ;
2020
21- var objectKeys = require ( '@stdlib/utils/keys' ) ;
2221var kumaraswamy = require ( './../lib' ) ;
2322
24- console . log ( objectKeys ( kumaraswamy ) ) ;
25- // Create a Kumaraswamy distribution object
23+ // Create a Kumaraswamy distribution object:
2624var a = 2.0 ;
2725var b = 5.0 ;
2826var dist = new kumaraswamy . Kumaraswamy ( a , b ) ;
2927
30- // Calculate basic distribution properties
28+ // Calculate basic distribution properties:
3129console . log ( 'Mean: %d' , dist . mean ) ;
3230console . log ( 'Median: %d' , dist . median ) ;
3331console . log ( 'Mode: %d' , dist . mode ) ;
3432console . log ( 'Variance: %d' , dist . variance ) ;
3533
36- // Evaluate the probability density function (PDF)
34+ // Evaluate the probability density function (PDF):
3735var x = 0.5 ;
3836var y = dist . pdf ( x ) ;
3937console . log ( 'PDF at x = %d: %d' , x , y ) ;
4038
41- // Evaluate the cumulative distribution function (CDF)
39+ // Evaluate the cumulative distribution function (CDF):
4240y = dist . cdf ( x ) ;
4341console . log ( 'CDF at x = %d: %d' , x , y ) ;
4442
45- // Evaluate the natural logarithm of PDF and CDF
43+ // Evaluate the natural logarithm of PDF and CDF:
4644console . log ( 'Log PDF at x = %d: %d' , x , dist . logpdf ( x ) ) ;
4745console . log ( 'Log CDF at x = %d: %d' , x , dist . logcdf ( x ) ) ;
4846
49- // Calculate the quantile for a given probability
47+ // Calculate the quantile for a given probability:
5048var p = 0.75 ;
5149x = dist . quantile ( p ) ;
5250console . log ( 'Quantile at p = %d: %d' , p , x ) ;
5351
54- // Generate random numbers
55- var r = new Array ( 5 ) ;
56- for ( var i = 0 ; i < 5 ; i ++ ) {
57- r [ i ] = kumaraswamy . random ( a , b ) ;
58- }
59- console . log ( 'Random samples: %s' , r . join ( ', ' ) ) ;
60-
61- // Use standalone functions
52+ // Use standalone distribution functions:
6253x = 0.3 ;
6354y = kumaraswamy . pdf ( x , a , b ) ;
6455console . log ( 'Standalone PDF at x = %d: %d' , x , y ) ;
@@ -69,25 +60,27 @@ console.log( 'Standalone CDF at x = %d: %d', x, y );
6960y = kumaraswamy . quantile ( 0.9 , a , b ) ;
7061console . log ( 'Standalone Quantile at p = 0.9: %d' , y ) ;
7162
72- // Calculate additional distribution properties
63+ // Calculate additional distribution properties:
7364console . log ( 'Kurtosis: %d' , kumaraswamy . kurtosis ( a , b ) ) ;
7465console . log ( 'Skewness: %d' , kumaraswamy . skewness ( a , b ) ) ;
7566console . log ( 'Standard Deviation: %d' , kumaraswamy . stdev ( a , b ) ) ;
7667
77- // Demonstrate the effect of different shape parameters
68+ // Demonstrate the effect of different shape parameters:
7869console . log ( '\nEffect of shape parameters:' ) ;
7970var shapes = [
80- [ 0.5 , 0.5 ] ,
81- [ 5.0 , 1.0 ] ,
82- [ 1.0 , 5.0 ] ,
83- [ 2.0 , 2.0 ] ,
84- [ 10.0 , 10.0 ]
71+ [ 0.5 , 0.5 ] ,
72+ [ 5.0 , 1.0 ] ,
73+ [ 1.0 , 5.0 ] ,
74+ [ 2.0 , 2.0 ] ,
75+ [ 10.0 , 10.0 ]
8576] ;
86- for ( var i = 0 ; i < shapes . length ; i ++ ) {
87- var params = shapes [ i ] ;
88- console . log ( '\na = %d, b = %d' , params [ 0 ] , params [ 1 ] ) ;
89- console . log ( 'Mean: %d' , kumaraswamy . mean ( params [ 0 ] , params [ 1 ] ) ) ;
90- console . log ( 'Median: %d' , kumaraswamy . median ( params [ 0 ] , params [ 1 ] ) ) ;
91- console . log ( 'Mode: %d' , kumaraswamy . mode ( params [ 0 ] , params [ 1 ] ) ) ;
92- console . log ( 'Skewness: %d' , kumaraswamy . skewness ( params [ 0 ] , params [ 1 ] ) ) ;
77+ var params ;
78+ var i ;
79+ for ( i = 0 ; i < shapes . length ; i ++ ) {
80+ params = shapes [ i ] ;
81+ console . log ( '\na = %d, b = %d' , params [ 0 ] , params [ 1 ] ) ;
82+ console . log ( 'Mean: %d' , kumaraswamy . mean ( params [ 0 ] , params [ 1 ] ) ) ;
83+ console . log ( 'Median: %d' , kumaraswamy . median ( params [ 0 ] , params [ 1 ] ) ) ;
84+ console . log ( 'Mode: %d' , kumaraswamy . mode ( params [ 0 ] , params [ 1 ] ) ) ;
85+ console . log ( 'Skewness: %d' , kumaraswamy . skewness ( params [ 0 ] , params [ 1 ] ) ) ;
9386}
0 commit comments