Translate if statement in code to math

10 ビュー (過去 30 日間)
Emil Partsch
Emil Partsch 2017 年 9 月 20 日
編集済み: OCDER 2017 年 9 月 21 日
Hey,
I have this piece of code that I'm trying understand what is going on. I usually use R, but had to look at a piece of code from matlab.
So can anyone tell me what this if statement does in math??
prob = exp(-dE / kT);
if dE <= 0 I I rand() <= prob;
spin(row, col) = - spin(row, col);
Cheers, Emil

回答 (1 件)

OCDER
OCDER 2017 年 9 月 21 日
編集済み: OCDER 2017 年 9 月 21 日
prob = exp(-dE / kT);
%define probability as prob = e^(-dE/kT), where dE and kT are some value
if dE <= 0 || rand() <= prob
%if dE <= 0, OR a uniformly distributed random number from 0 to 1 is <= prob
spin(row, col) = - spin(row, col);
%negate the sign of the value stored at (row, col) position of a matrix called spin
end
%end of the if statement

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by