Professional Documents
Culture Documents
Modelling 4 PDF
Modelling 4 PDF
Modelling 4 PDF
Experiment: 4
Aim:
Write a program to implement Monte Carlo Simulation.
Tools/Software Required:
MATLAB
Description:
Monte Carlo Simulation is a method for exploring the sensitivity of a complex system by
varying parameters within statistical constraints.
Common tasks for performing Monte Carlo analysis include:
Steps:
Step1: establish probability distribution
Step2: cumulative probability distribution.
Step3: setting random number intervals.
Step4: generating random numbers.
Step5: find the solution.
Implementation:
n_cards = 90000;
a = zeros(1,n_cards);
for n= 1:n_cards
deck = randperm(52);
num_drawn = 3;
draw = deck(1:num_drawn);
count = 0;
for i = 1 : num_drawn
if draw(i) <=12;
count = count+1;
end
end
if count == num_drawn;
a(n) = 1;
else
a(n) = 0;
end
end
s = sum(a);
p = s/n_cards