public double inferenceByGibbsSampling(Document d,double[] pzd,int numBurnIn,int numSampling){
  Arrays.fill(pzd,0);
  double loglikelihood=0.0;
  for (int i=0; i < numBurnIn + numSampling; i++) {
    loglikelihood+=gibbsSampling(d);
    if (i >= numBurnIn) {
      for (      int topic : d.topics) {
        if (topic != NO_TOPIC)         pzd[topic]++;
      }
    }
 else {
      loglikelihood=0;
    }
  }
  normalize(pzd,alpha);
  return loglikelihood / numSampling;
}

public double inferenceByGibbsSampling ( Document d , double [ ] pzd , int numBurnIn , int numSampling ) { Arrays . fill ( pzd , 0 ) ; double loglikelihood = 0.0 ; for ( int i = 0 ; i < numBurnIn + numSampling ; i ++ ) { loglikelihood += gibbsSampling ( d ) ; if ( i >= numBurnIn ) { for ( int topic : d . topics ) { if ( topic != NO_TOPIC ) pzd [ topic ] ++ ; } } else { loglikelihood = 0 ; } } normalize ( pzd , alpha ) ; return loglikelihood / numSampling ; }
inference by gibbs sampling .
