Can I use this algorithm with GPU coding?
7 次查看(过去 30 天)
显示 更早的评论
I want to create code about picture and want to do monte carlo simulation with gpu
Is it possible to code with gpu?
1st pseudo code
Function EvaluateTopEventProbability (T)
//for number of samples n
For number of samples n
//determine the state of events
For each Ei which is a basic event
//a random number r between 0 and 1
r = rand()
//State of Ei
if r ≤ Pi then Si = True else Si = False
//Calculate the state of top event
ST = GetState (T)//f(S)
if ST ≡ True then m = m + 1
//Evaluate the top event probability PT
PT = m/n
Return PT
2nd pseudo code
Function GetState (g)
//return Sg for basic event
if g is a basic event then
return Sg
//for Gate
//if already processed
if Sg is already determined then
return Sg
//calculate the state for each input
For each Ci ∈ g
//recursively for each input
Si = GetState (Ci)
//Determine the State of g
Sg = DetermineState (g)
Return Sg
3rd pseudo code
Function DetermineState (g)
if g is a OR Gate then
u = False
For each Ci ∈ g
u = u∪Si
else if g is a AND Gate then
u = True
For each Ci ∈ g
u = u∩Si
else if g is a NOT Gate then
For Ci ∈g
u = not Si
Sg = u
return Sg
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!