jsbayes.js
function initCpt(numValues) {
    var cpt = [];
    var sum = 0;
    for(var i=0; i < numValues; i++) {
      cpt[i] = Math.random();
      sum += cpt[i];
    }
    for(var i=0; i < numValues; i++) {
      cpt[i] = cpt[i] / sum;
    }
    return cpt;
  }
function initCpt(numValues) {
    var cpt = [];
    var sum = 0;
    for(var i=0; i < numValues; i++) {
      cpt[i] = Math.random();
      sum += cpt[i];
    }
    for(var i=0; i < numValues; i++) {
      cpt[i] = cpt[i] / sum;
    }
    return cpt;
  }
function initCpt ( numValues ) { var cpt = [ ] ; var sum = 0 ; for ( var i = 0 ; i < numValues ; i ++ ) { cpt [ i ] = Math . random ( ) ; sum += cpt [ i ] ; } for ( var i = 0 ; i < numValues ; i ++ ) { cpt [ i ] = cpt [ i ] / sum ; } return cpt ; }
Initializes a conditional probability table.
@param {Number} numValues Number of values.
@returns {Array} Array of doubles that sum to 1.0.
Initializes a conditional probability table .