assigning probability

5 ビュー (過去 30 日間)
darksideofthemoon101
darksideofthemoon101 2011 年 4 月 7 日
Hi,
I'm doing a basic simulated annealing experiment and I want to assign a probability to decide whether a variable change is accepted or not.
My probability function is
probability=exp(-(A2-A1)/temp);
where A is the variable that I'm trying to minimise. As temp decreases the probability of accepting A2>A1 decreases, so that A1 will eventually be in a minimal state.
How can I program my code such that if probability=0.8 (where A2>A1 at a high value of temp), there is an 80% chance that the line
A1=A2;
will be accepted.
If I haven't explained the problem clearly enough, please comment and I'll try to elaborate.
Thanks,
Richard
  1 件のコメント
darksideofthemoon101
darksideofthemoon101 2011 年 4 月 7 日
Anyone?

サインインしてコメントする。

採用された回答

David Young
David Young 2011 年 4 月 7 日
if rand < probability
A1 = A2;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulated Annealing についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by