/**
* Samples the output probability distribution.
* @return the index of the sampled element
*/
public int sample(){
if(this.needsUpdate){
this.computeProbs();
}
double r = this.rand.nextDouble();
double sum = 0.;
for(int i = 0; i < this.probs.length; i++){
sum += this.probs[i];
if(r < sum){
return i;
}
}
throw new RuntimeErrorException(new Error("Error in sample; Boltzmann distribution did not sum to 1"));
}
BoltzmannDistribution.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:DOO-Q_BRACIS2016
作者:
评论列表
文章目录