6

我正在编写java代码来解决模拟退火方法的问题。我需要一种方法来仅在给定参数true的概率 exp(a/b) 中a生成随机数。b

谢谢。

4

1 回答 1

11

假设这a/b是返回 true 的百分比概率:

public boolean exp(double probabilityTrue)
{
    return Math.random() >= 1.0 - probabilityTrue;
}
于 2015-03-16T09:49:35.687 回答