Skip to content

Commit 33cdbf4

Browse files
committed
chore: address commit comments for commit 8b01d81
1 parent 4afe7e2 commit 33cdbf4

File tree

1 file changed

+8
-10
lines changed
  • lib/node_modules/@stdlib/utils/tabulate-by/examples

1 file changed

+8
-10
lines changed

lib/node_modules/@stdlib/utils/tabulate-by/examples/index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,26 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var floor = require( '@stdlib/math/base/special/floor' );
21+
22+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
23+
var take = require( '@stdlib/array/take' );
2324
var tabulateBy = require( './../lib' );
2425

2526
var vals;
2627
var arr;
2728
var out;
28-
var i;
29-
var j;
3029

3130
function indicator( value ) {
3231
return value[ 0 ];
3332
}
3433

3534
vals = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ];
3635

37-
// Generate a random collection...
38-
arr = [];
39-
for ( i = 0; i < 100; i++ ) {
40-
j = floor( randu()*vals.length );
41-
arr.push( vals[ j ] );
42-
}
36+
// Generate random indices:
37+
var idx = discreteUniform( 100, 0, vals.length-1 );
38+
39+
// Select values:
40+
arr = take( vals, idx );
4341

4442
// Generate a frequency table:
4543
out = tabulateBy( arr, indicator );

0 commit comments

Comments
 (0)