Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写java代码来解决模拟退火方法的问题。我需要一种方法来仅在给定参数true的概率 exp(a/b) 中a生成随机数。b
true
a
b
谢谢。
假设这a/b是返回 true 的百分比概率:
a/b
public boolean exp(double probabilityTrue) { return Math.random() >= 1.0 - probabilityTrue; }