jsbayes.js
function setNodeCptProbs(cpt, probs, index) {
    if(!isArrayOfArray(cpt)) {
      for(var i=0; i < cpt.length; i++) {
        cpt[i] = probs[index][i];
      }
      var nextIndex = index + 1;
      return nextIndex;
    } else {
      var next = index;
      for(var i=0; i < cpt.length; i++) {
        next = setNodeCptProbs(cpt[i], probs, next);
      }
      return next;
    }
  }
function setNodeCptProbs(cpt, probs, index) {
    if(!isArrayOfArray(cpt)) {
      for(var i=0; i < cpt.length; i++) {
        cpt[i] = probs[index][i];
      }
      var nextIndex = index + 1;
      return nextIndex;
    } else {
      var next = index;
      for(var i=0; i < cpt.length; i++) {
        next = setNodeCptProbs(cpt[i], probs, next);
      }
      return next;
    }
  }
function setNodeCptProbs ( cpt , probs , index ) { if ( ! isArrayOfArray ( cpt ) ) { for ( var i = 0 ; i < cpt . length ; i ++ ) { cpt [ i ] = probs [ index ] [ i ] ; } var nextIndex = index + 1 ; return nextIndex ; } else { var next = index ; for ( var i = 0 ; i < cpt . length ; i ++ ) { next = setNodeCptProbs ( cpt [ i ] , probs , next ) ; } return next ; } }
Sets the CPT entries to the specified probabilities.
@param {Array} cpt Array of nested arrays representing a CPT.
@param {Array} probs Array of arrays of probabilities representing a CPT.
@param {Number} index The current index.
@returns {Number} The next index.
Sets the CPT entries to the specified probabilities .