src/convnet_util.js
function(lst, probs) {
    var p = randf(0, 1.0);
    var cumprob = 0.0;
    for(var k=0,n=lst.length;k<n;k++) {
      cumprob += probs[k];
      if(p < cumprob) { return lst[k]; }
    }
  }
function(lst, probs) {
    var p = randf(0, 1.0);
    var cumprob = 0.0;
    for(var k=0,n=lst.length;k<n;k++) {
      cumprob += probs[k];
      if(p < cumprob) { return lst[k]; }
    }
  }
function ( lst , probs ) { var p = randf ( 0 , 1.0 ) ; var cumprob = 0.0 ; for ( var k = 0 , n = lst . length ; k < n ; k ++ ) { cumprob += probs [ k ] ; if ( p < cumprob ) { return lst [ k ] ; } } }
sample from list lst according to probabilities in list probs the two lists are of same size, and probs adds up to 1
sample from list lst according to probabilities in list probs the two lists are of same size and probs adds up to 1