@@ -102,15 +102,75 @@ var y = dist.logpdf( 0.8 );
102
102
103
103
## Examples
104
104
105
- <!-- TODO: better examples -->
106
-
107
105
<!-- eslint no-undef: "error" -->
108
106
109
107
``` javascript
110
- var objectKeys = require ( ' @stdlib/utils/keys' );
111
108
var kumaraswamy = require ( ' @stdlib/stats/base/dists/kumaraswamy' );
112
109
113
- console .log ( objectKeys ( kumaraswamy ) );
110
+ // Create a Kumaraswamy distribution object:
111
+ var a = 2.0 ;
112
+ var b = 5.0 ;
113
+ var dist = new kumaraswamy.Kumaraswamy ( a, b );
114
+
115
+ // Calculate basic distribution properties:
116
+ console .log ( ' Mean: %d' , dist .mean );
117
+ console .log ( ' Median: %d' , dist .median );
118
+ console .log ( ' Mode: %d' , dist .mode );
119
+ console .log ( ' Variance: %d' , dist .variance );
120
+
121
+ // Evaluate the probability density function (PDF):
122
+ var x = 0.5 ;
123
+ var y = dist .pdf ( x );
124
+ console .log ( ' PDF at x = %d: %d' , x, y );
125
+
126
+ // Evaluate the cumulative distribution function (CDF):
127
+ y = dist .cdf ( x );
128
+ console .log ( ' CDF at x = %d: %d' , x, y );
129
+
130
+ // Evaluate the natural logarithm of PDF and CDF:
131
+ console .log ( ' Log PDF at x = %d: %d' , x, dist .logpdf ( x ) );
132
+ console .log ( ' Log CDF at x = %d: %d' , x, dist .logcdf ( x ) );
133
+
134
+ // Calculate the quantile for a given probability:
135
+ var p = 0.75 ;
136
+ x = dist .quantile ( p );
137
+ console .log ( ' Quantile at p = %d: %d' , p, x );
138
+
139
+ // Use standalone distribution functions:
140
+ x = 0.3 ;
141
+ y = kumaraswamy .pdf ( x, a, b );
142
+ console .log ( ' Standalone PDF at x = %d: %d' , x, y );
143
+
144
+ y = kumaraswamy .cdf ( x, a, b );
145
+ console .log ( ' Standalone CDF at x = %d: %d' , x, y );
146
+
147
+ y = kumaraswamy .quantile ( 0.9 , a, b );
148
+ console .log ( ' Standalone Quantile at p = 0.9: %d' , y );
149
+
150
+ // Calculate additional distribution properties:
151
+ console .log ( ' Kurtosis: %d' , kumaraswamy .kurtosis ( a, b ) );
152
+ console .log ( ' Skewness: %d' , kumaraswamy .skewness ( a, b ) );
153
+ console .log ( ' Standard Deviation: %d' , kumaraswamy .stdev ( a, b ) );
154
+
155
+ // Demonstrate the effect of different shape parameters:
156
+ console .log ( ' \n Effect of shape parameters:' );
157
+ var shapes = [
158
+ [ 0.5 , 0.5 ],
159
+ [ 5.0 , 1.0 ],
160
+ [ 1.0 , 5.0 ],
161
+ [ 2.0 , 2.0 ],
162
+ [ 10.0 , 10.0 ]
163
+ ];
164
+ var params;
165
+ var i;
166
+ for ( i = 0 ; i < shapes .length ; i++ ) {
167
+ params = shapes[i];
168
+ console .log ( ' \n a = %d, b = %d' , params[0 ], params[1 ] );
169
+ console .log ( ' Mean: %d' , kumaraswamy .mean ( params[0 ], params[1 ] ) );
170
+ console .log ( ' Median: %d' , kumaraswamy .median ( params[0 ], params[1 ] ) );
171
+ console .log ( ' Mode: %d' , kumaraswamy .mode ( params[0 ], params[1 ] ) );
172
+ console .log ( ' Skewness: %d' , kumaraswamy .skewness ( params[0 ], params[1 ] ) );
173
+ }
114
174
```
115
175
116
176
</section >
0 commit comments