Skip to content

Commit 488fd16

Browse files
committed
chore: clean-up new examples
1 parent 2786956 commit 488fd16

File tree

2 files changed

+41
-58
lines changed

2 files changed

+41
-58
lines changed

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/README.md

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -102,52 +102,41 @@ var y = dist.logpdf( 0.8 );
102102

103103
## Examples
104104

105-
<!-- TODO: better examples -->
106-
107105
<!-- eslint no-undef: "error" -->
108106

109107
```javascript
110-
var objectKeys = require( '@stdlib/utils/keys' );
111108
var kumaraswamy = require( '@stdlib/stats/base/dists/kumaraswamy' );
112109

113-
console.log( objectKeys( kumaraswamy ) );
114-
// Create a Kumaraswamy distribution object
110+
// Create a Kumaraswamy distribution object:
115111
var a = 2.0;
116112
var b = 5.0;
117113
var dist = new kumaraswamy.Kumaraswamy( a, b );
118114

119-
// Calculate basic distribution properties
115+
// Calculate basic distribution properties:
120116
console.log( 'Mean: %d', dist.mean );
121117
console.log( 'Median: %d', dist.median );
122118
console.log( 'Mode: %d', dist.mode );
123119
console.log( 'Variance: %d', dist.variance );
124120

125-
// Evaluate the probability density function (PDF)
121+
// Evaluate the probability density function (PDF):
126122
var x = 0.5;
127123
var y = dist.pdf( x );
128124
console.log( 'PDF at x = %d: %d', x, y );
129125

130-
// Evaluate the cumulative distribution function (CDF)
126+
// Evaluate the cumulative distribution function (CDF):
131127
y = dist.cdf( x );
132128
console.log( 'CDF at x = %d: %d', x, y );
133129

134-
// Evaluate the natural logarithm of PDF and CDF
130+
// Evaluate the natural logarithm of PDF and CDF:
135131
console.log( 'Log PDF at x = %d: %d', x, dist.logpdf( x ) );
136132
console.log( 'Log CDF at x = %d: %d', x, dist.logcdf( x ) );
137133

138-
// Calculate the quantile for a given probability
134+
// Calculate the quantile for a given probability:
139135
var p = 0.75;
140136
x = dist.quantile( p );
141137
console.log( 'Quantile at p = %d: %d', p, x );
142138

143-
// Generate random numbers
144-
var r = new Array( 5 );
145-
for ( var i = 0; i < 5; i++ ) {
146-
r[ i ] = kumaraswamy.random( a, b );
147-
}
148-
console.log( 'Random samples: %s', r.join( ', ' ) );
149-
150-
// Use standalone functions
139+
// Use standalone distribution functions:
151140
x = 0.3;
152141
y = kumaraswamy.pdf( x, a, b );
153142
console.log( 'Standalone PDF at x = %d: %d', x, y );
@@ -158,23 +147,24 @@ console.log( 'Standalone CDF at x = %d: %d', x, y );
158147
y = kumaraswamy.quantile( 0.9, a, b );
159148
console.log( 'Standalone Quantile at p = 0.9: %d', y );
160149

161-
// Calculate additional distribution properties
150+
// Calculate additional distribution properties:
162151
console.log( 'Kurtosis: %d', kumaraswamy.kurtosis( a, b ) );
163152
console.log( 'Skewness: %d', kumaraswamy.skewness( a, b ) );
164153
console.log( 'Standard Deviation: %d', kumaraswamy.stdev( a, b ) );
165154

166-
// Demonstrate the effect of different shape parameters
155+
// Demonstrate the effect of different shape parameters:
167156
console.log( '\nEffect of shape parameters:' );
168157
var shapes = [
169-
[0.5, 0.5],
170-
[5.0, 1.0],
171-
[1.0, 5.0],
172-
[2.0, 2.0],
173-
[10.0, 10.0]
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 ]
174163
];
175-
176-
for ( var i = 0; i < shapes.length; i++ ) {
177-
var params = shapes[i];
164+
var params;
165+
var i;
166+
for ( i = 0; i < shapes.length; i++ ) {
167+
params = shapes[i];
178168
console.log( '\na = %d, b = %d', params[0], params[1] );
179169
console.log( 'Mean: %d', kumaraswamy.mean( params[0], params[1] ) );
180170
console.log( 'Median: %d', kumaraswamy.median( params[0], params[1] ) );

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/examples/index.js

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,38 @@
1818

1919
'use strict';
2020

21-
var objectKeys = require( '@stdlib/utils/keys' );
2221
var kumaraswamy = require( './../lib' );
2322

24-
console.log( objectKeys( kumaraswamy ) );
25-
// Create a Kumaraswamy distribution object
23+
// Create a Kumaraswamy distribution object:
2624
var a = 2.0;
2725
var b = 5.0;
2826
var dist = new kumaraswamy.Kumaraswamy( a, b );
2927

30-
// Calculate basic distribution properties
28+
// Calculate basic distribution properties:
3129
console.log( 'Mean: %d', dist.mean );
3230
console.log( 'Median: %d', dist.median );
3331
console.log( 'Mode: %d', dist.mode );
3432
console.log( 'Variance: %d', dist.variance );
3533

36-
// Evaluate the probability density function (PDF)
34+
// Evaluate the probability density function (PDF):
3735
var x = 0.5;
3836
var y = dist.pdf( x );
3937
console.log( 'PDF at x = %d: %d', x, y );
4038

41-
// Evaluate the cumulative distribution function (CDF)
39+
// Evaluate the cumulative distribution function (CDF):
4240
y = dist.cdf( x );
4341
console.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:
4644
console.log( 'Log PDF at x = %d: %d', x, dist.logpdf( x ) );
4745
console.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:
5048
var p = 0.75;
5149
x = dist.quantile( p );
5250
console.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:
6253
x = 0.3;
6354
y = kumaraswamy.pdf( x, a, b );
6455
console.log( 'Standalone PDF at x = %d: %d', x, y );
@@ -69,25 +60,27 @@ console.log( 'Standalone CDF at x = %d: %d', x, y );
6960
y = kumaraswamy.quantile( 0.9, a, b );
7061
console.log( 'Standalone Quantile at p = 0.9: %d', y );
7162

72-
// Calculate additional distribution properties
63+
// Calculate additional distribution properties:
7364
console.log( 'Kurtosis: %d', kumaraswamy.kurtosis( a, b ) );
7465
console.log( 'Skewness: %d', kumaraswamy.skewness( a, b ) );
7566
console.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:
7869
console.log( '\nEffect of shape parameters:' );
7970
var 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

Comments
 (0)