BoltzmannDistribution.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:DOO-Q_BRACIS2016 作者:
/**
 * 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"));

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号