|
23 | 23 | var bench = require( '@stdlib/bench' ); |
24 | 24 | var isnan = require( '@stdlib/math/base/assert/is-nan' ); |
25 | 25 | var EPS = require( '@stdlib/constants/float64/eps' ); |
| 26 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 27 | +var uniform = require( '@stdlib/random/base/uniform' ); |
26 | 28 | var pkg = require( './../package.json' ).name; |
27 | 29 | var Triangular = require( './../lib' ); |
28 | | -var uniform = require( '@stdlib/random/base/uniform' ); |
29 | | -var Float64Array = require( '@stdlib/array/float64' ); |
| 30 | + |
30 | 31 |
|
31 | 32 |
|
32 | 33 | // MAIN // |
33 | 34 |
|
34 | 35 | bench( pkg+'::instantiation', function benchmark( bm ) { |
| 36 | + var as = new Float64Array(bm.iterations); |
| 37 | + var bs = new Float64Array(bm.iterations); |
| 38 | + var cs = new Float64Array(bm.iterations); |
35 | 39 | var dist; |
36 | 40 | var a; |
37 | 41 | var b; |
38 | 42 | var c; |
39 | 43 | var i; |
40 | | - var as = new Float64Array(bm.iterations); |
41 | | - var bs = new Float64Array(bm.iterations); |
42 | | - var cs = new Float64Array(bm.iterations); |
43 | | - for( i = 0; i<bm.iterations; i++){ |
44 | | - a = uniform(EPS , 10.0); |
45 | | - b = uniform(a + EPS , a + 10.0); |
46 | | - c = uniform(a , b); |
| 44 | + for ( i = 0; i < bm.iterations; i++ ) { |
| 45 | + a = uniform(EPS, 10.0); |
| 46 | + b = uniform(a + EPS, a + 10.0); |
| 47 | + c = uniform(a, b); |
47 | 48 | as[i] = a; |
48 | 49 | bs[i] = b; |
49 | 50 | cs[i] = c; |
@@ -110,7 +111,7 @@ bench( pkg+'::set:a', function benchmark( bm ) { |
110 | 111 |
|
111 | 112 | bm.tic(); |
112 | 113 | for ( i = 0; i < bm.iterations; i++ ) { |
113 | | - y = uniform(EPS , 100.0); |
| 114 | + y = uniform(EPS, 100.0); |
114 | 115 | dist.a = y; |
115 | 116 | if ( dist.a !== y ) { |
116 | 117 | bm.fail( 'should return set value' ); |
@@ -167,7 +168,7 @@ bench( pkg+'::set:b', function benchmark( bm ) { |
167 | 168 |
|
168 | 169 | bm.tic(); |
169 | 170 | for ( i = 0; i < bm.iterations; i++ ) { |
170 | | - y = uniform(EPS+c , 100.0+c+EPS); |
| 171 | + y = uniform(EPS+c, 100.0+c+EPS); |
171 | 172 | dist.b = y; |
172 | 173 | if ( dist.b !== y ) { |
173 | 174 | bm.fail( 'should return set value' ); |
@@ -224,7 +225,7 @@ bench( pkg+'::set:c', function benchmark( bm ) { |
224 | 225 |
|
225 | 226 | bm.tic(); |
226 | 227 | for ( i = 0; i < bm.iterations; i++ ) { |
227 | | - y = uniform(a , b); |
| 228 | + y = uniform(a, b); |
228 | 229 | dist.c = y; |
229 | 230 | if ( dist.c !== y ) { |
230 | 231 | bm.fail( 'should return set value' ); |
@@ -253,7 +254,7 @@ bench( pkg+':entropy', function benchmark( bm ) { |
253 | 254 |
|
254 | 255 | bm.tic(); |
255 | 256 | for ( i = 0; i < bm.iterations; i++ ) { |
256 | | - dist.a = uniform(0,c); |
| 257 | + dist.a = uniform(0, c); |
257 | 258 | y = dist.entropy; |
258 | 259 | if ( isnan( y ) ) { |
259 | 260 | bm.fail( 'should not return NaN' ); |
@@ -282,7 +283,7 @@ bench( pkg+':kurtosis', function benchmark( bm ) { |
282 | 283 |
|
283 | 284 | bm.tic(); |
284 | 285 | for ( i = 0; i < bm.iterations; i++ ) { |
285 | | - dist.a = uniform(0.0 , c); |
| 286 | + dist.a = uniform(0.0, c); |
286 | 287 | y = dist.kurtosis; |
287 | 288 | if ( isnan( y ) ) { |
288 | 289 | bm.fail( 'should not return NaN' ); |
@@ -311,7 +312,7 @@ bench( pkg+':mean', function benchmark( bm ) { |
311 | 312 |
|
312 | 313 | bm.tic(); |
313 | 314 | for ( i = 0; i < bm.iterations; i++ ) { |
314 | | - dist.a = uniform(0.0 , c); |
| 315 | + dist.a = uniform(0.0, c); |
315 | 316 | y = dist.mean; |
316 | 317 | if ( isnan( y ) ) { |
317 | 318 | bm.fail( 'should not return NaN' ); |
@@ -340,7 +341,7 @@ bench( pkg+':median', function benchmark( bm ) { |
340 | 341 |
|
341 | 342 | bm.tic(); |
342 | 343 | for ( i = 0; i < bm.iterations; i++ ) { |
343 | | - dist.a = uniform(0.0 , c); |
| 344 | + dist.a = uniform(0.0, c); |
344 | 345 | y = dist.median; |
345 | 346 | if ( isnan( y ) ) { |
346 | 347 | bm.fail( 'should not return NaN' ); |
@@ -369,7 +370,7 @@ bench( pkg+':skewness', function benchmark( bm ) { |
369 | 370 |
|
370 | 371 | bm.tic(); |
371 | 372 | for ( i = 0; i < bm.iterations; i++ ) { |
372 | | - dist.a = uniform(0.0 , c); |
| 373 | + dist.a = uniform(0.0, c); |
373 | 374 | y = dist.skewness; |
374 | 375 | if ( isnan( y ) ) { |
375 | 376 | bm.fail( 'should not return NaN' ); |
@@ -398,7 +399,7 @@ bench( pkg+':stdev', function benchmark( bm ) { |
398 | 399 |
|
399 | 400 | bm.tic(); |
400 | 401 | for ( i = 0; i < bm.iterations; i++ ) { |
401 | | - dist.a = uniform(0.0 , c); |
| 402 | + dist.a = uniform(0.0, c); |
402 | 403 | y = dist.stdev; |
403 | 404 | if ( isnan( y ) ) { |
404 | 405 | bm.fail( 'should not return NaN' ); |
@@ -427,7 +428,7 @@ bench( pkg+':variance', function benchmark( bm ) { |
427 | 428 |
|
428 | 429 | bm.tic(); |
429 | 430 | for ( i = 0; i < bm.iterations; i++ ) { |
430 | | - dist.a = uniform(0.0 , c); |
| 431 | + dist.a = uniform(0.0, c); |
431 | 432 | y = dist.variance; |
432 | 433 | if ( isnan( y ) ) { |
433 | 434 | bm.fail( 'should not return NaN' ); |
@@ -457,7 +458,7 @@ bench( pkg+':cdf', function benchmark( bm ) { |
457 | 458 |
|
458 | 459 | bm.tic(); |
459 | 460 | for ( i = 0; i < bm.iterations; i++ ) { |
460 | | - x = uniform(0.0 , 60.0); |
| 461 | + x = uniform(0.0, 60.0); |
461 | 462 | y = dist.cdf( x ); |
462 | 463 | if ( isnan( y ) ) { |
463 | 464 | bm.fail( 'should not return NaN' ); |
@@ -487,7 +488,7 @@ bench( pkg+':mgf', function benchmark( bm ) { |
487 | 488 |
|
488 | 489 | bm.tic(); |
489 | 490 | for ( i = 0; i < bm.iterations; i++ ) { |
490 | | - x = uniform(0.0 , 1.0); |
| 491 | + x = uniform(0.0, 1.0); |
491 | 492 | y = dist.mgf( x ); |
492 | 493 | if ( isnan( y ) ) { |
493 | 494 | bm.fail( 'should not return NaN' ); |
@@ -517,7 +518,7 @@ bench( pkg+':pdf', function benchmark( bm ) { |
517 | 518 |
|
518 | 519 | bm.tic(); |
519 | 520 | for ( i = 0; i < bm.iterations; i++ ) { |
520 | | - x = uniform(0.0 , 60.0); |
| 521 | + x = uniform(0.0, 60.0); |
521 | 522 | y = dist.pdf( x ); |
522 | 523 | if ( isnan( y ) ) { |
523 | 524 | bm.fail( 'should not return NaN' ); |
@@ -547,7 +548,7 @@ bench( pkg+':quantile', function benchmark( bm ) { |
547 | 548 |
|
548 | 549 | bm.tic(); |
549 | 550 | for ( i = 0; i < bm.iterations; i++ ) { |
550 | | - x = uniform(0.0 , 1.0); |
| 551 | + x = uniform(0.0, 1.0); |
551 | 552 | y = dist.quantile( x ); |
552 | 553 | if ( isnan( y ) ) { |
553 | 554 | bm.fail( 'should not return NaN' ); |
|
0 commit comments