How to generate multiple entities randomly and control the probability of event occurring?
Show older comments
I am trying to create a model in which 4 different entities are generated randomly. Once the entity is generated, then I want to be able to control the probability that the generated event occurs. Is something like this possible, how can it be done?
Answers (1)
Will Nitsch
on 27 Jul 2017
Could you possibly use random number generation ('rand')? Say something has a 25% probability of event 'X' happening, 35% for 'Y' and 40% for 'Z'. You could say:
val = rand;
if(val<=.25) % 25% chance
% event X
else if(val>.25 & val <=.6) % .6-.25 = .35 for the 35%
% event Y
else if(val>.6) % 40% chance
% event Z
end
end
end
1 Comment
Sebastian Stankiewicz
on 28 Jul 2017
Categories
Find more on Discrete-Event Simulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!