Monte Carlo Technique. Engineering Statistics Project. (Statistics Project Sample)
this was an interesting technique called monte Carlo technique, which I did on Matlab. it can be applied in statistics, where it isolates all the possibilities, especially in games. this one I was doing for football (soccer)
source..Task 1
This is a rectangle inside a circle, we have a rectangle and a circle as the known shapes.
Area of the circle is πr2 …………………(i)
Area of a rectangle is L X W …………… (ii)
Probability of the ball going through the rectangle (goal) is
Area of rectangleArea of a circle=L X Wπr2 ………………………………………. (iii)
But L = 4 and W = 2; so, from (ii) we get 8.
From the equation (iii) above, we have 8πr2 ……………………………(iv)
Consider the triangle inside the rectangle where r is the hypotenuse, 2 is the base and 1 is the height
By Pythagoras theorem we have r2=12+22=5
That means from (iv) we have 85π …………………..(v)
We shall consider the following points:
Let N be the number of trial or attempts to have the ball go into the region of goal (where it does not matter where the ball goes)
If the ball in the rectangle, we shall assign 1, otherwise we shall assign 0
xi=1 or xo=0
For the N times; P=1Nxi………………. (vi)
So, P found (vi) is 85π approx. 0.509
1Nxi= 85π ……………………….. (vii)
Making pi the subject we have π=8N5xi
Therefore, this is the numerical value for the fraction of balls entering the goal to the total number of balls in the circular area. The numerical value is therefore 0.509
Task 2
If we consider a cartesian plane where the radius r2=(x2+y2)
Where r2 is 5. So, we know that any point(x,y) in that circle can be expressed as
(x2+y2)≤r2
The code is written T2 (below):
Task 2
%************************* Parameter Notation ******************************
%P: Sum of the possibilities of shooting successfully
%P0: Possibility of shooting in the goal successfully in each simulation
%R: Number of runs of the simulation
%N: Number of shots in each run of the simulation
%S: Number of shots that are shot in successfully in each simulation
%r: The radius coordinate of each point
%a: The angle coordinate of each point
%x: The horizontal coordinate of each point
%y: The vertical coordinate of each point
function [Result]=PartOneUniform(N,R)
P=0; %Initialize the P
rect=[-2,-2,2,2,-2;-1,1,1,-1,-1]; %Draw the rectangle and cirle
plot(rect(1,:),rect(2,:),'k')
hold on
ezplot('xˆ2+yˆ2=5')
hold on
for R=1:R
S=0; %Initialize the S for each estimation
for N=1:N
r=sqrt(5)*sqrt(rand()); %Uniform random generators of the
a=2*pi*rand(); %radius and the angle
x=cos(a)*r; %Convert the polar coordinates to
y=sin(a)*r; %the rectangular coordinates
if (abs(x)<2&&abs(y)<1) %Count the number of ``Shoot" and
S=S+1; %plot them
Shoot=plot(x,y,'+r');
hold on
else
Miss=plot(x,y,'ob'); %Plot the points of ``Miss"
hold on
end
end
PO=S/N; %Calculate the shooting possibility
P=P+PO; %Sum up the possibilities
title('PartOneUniform'); %Present axes name, title and legend
xlabel('x');
ylabel('y');
legend([Shoot, Miss],'Score','Miss');
axis equal
end
Task 3
How the results were generated
We chose the “Type” in GUI and was to be “Uniform (Without goal- keeper)” the main goal for this task. The input was N which was 1000 and we input R as 1. Next, the “Simulate” bottom was clicked.
The result
The result of the possibility of scoring is presented graphically as follows in Fig. 1
Figure SEQ Figure \* ARABIC 1: Task 3 Plotting showing the scores and the misses
Therefore, it is shown that the P value is 0.496, which is almost equal to the ideal value
Task 4
How the results were generated
We chose the “Type” in GUI and was to be “Uniform (Without goal- keeper)” which is what this task requires. Four tests were conducted and the input sets were: R=5, N=100; R=5, N=1000; R=5, N=10000; R=5, N=100000
Results, were obtained and presented in table 1 below
Table SEQ Table \* ARABIC 1: Probabilities for the different values of N
N (Values)
P (Values)
100
0.492
1000
0.5058
10000
0.51158
100000
0.5088
– The plot of probability against the value of N is presented below
Task 5
We chose the “Type” in GUI and was to be “Uniform (Without goal- keeper)” which is what this task requires. Four tests were conducted and the input sets were: R=5, N=1000; R=10, N=1000; R=15, N=1000; R=20, N=1000.
The results obtained were used to fill the table 2 below
Table SEQ Table \* ARABIC 2: The probability showing different values of R
R (Values)
P (Values)
5
0.5058
10
0.5053
15
0.5068
20
0.50515
The values were later plotted as shown below
Task 6
Explanation:
In Task 4, R remained 5, which was unchanged whereas the values N increased from 100 to 100000. We notice that when the value of N is larger, we get closer to the ideal value which was 0.509
Task 5, N value was 1000 meanwhile the values R increased from 5 to 20, it therefore can be seen that when the value of R increases the results reduces within a small range but not anywhere near the ideal value.
Analysis of the experiment
We can understand the phenomena this way, when the time of the experiment remain the same the number of shots increased, the simulation exhibited a closer value to the real situation which is a random process, thus the result can be more general that is to say the result is closer to the theoretical result.
Nevertheless, when the number of shots remain the same only the time of the experiment increase. The result will be still only for the same size of sample which does not increase the general value of the result.
So, we can conclude that by increasing the value of N, the accuracy of the result can be improved. If the simulation times is unlimited, then the result achieved by the experiment can be referred to as equal to the real result. Though, if we only increase the value of times of the experiment R, only the precision can be improved but the accuracy will not be influenced.
Task 7
Repeat Task 2 in Task 7
Explanation of the result
This program or code has been written as in T2N7 below and a brief explanation.
T2N7
%************************* Parameter Notation ******************************
%P: Sum of the possibilities of shooting successfully
%P0: Possibility of shooting in the goal successfully in each simulation
%R: Number of runs of the simulation
%N: Number of shots in each run of the simulation
%S: Number of shots that are shot in successfully in each simulation
%r: The radius coordinate of each point
%a: The angle coordinate of each point
%x: The horizontal coordinate of each point
%y: The vertical coordinate of each point
%***************************************************************************
function [Result]=PartOneNormal(N,R)
P=0; %Initialize the P
rect=[-2,-2,2,2,-2;-1,1,1,-1,-1]; %Draw the rectangle and cirle plot(rect(1,:),rect(2,:),'k')
hold on ezplot('xˆ2+yˆ2=5') hold on
for R=1:R
T=0; %Total shots
C=0; %points lying outside the circle
S=0; %Initialize the S for each estimation
while (T-C
x=r*cos(a); %Convert the polar coordinates to y=r*sin(a); %the rectangular coordinates
if (xˆ2+yˆ2>5) %Count the points outside circle
C=C+1;
else
if (abs(x)<2&&abs(y)<1) %Count the number of ``Shoot" and
S=S+1; %plot them
Shoot=plot(x,y,'+r');
hold on
else %Plot the points of ``Miss" Miss=plot(x,y,'ob');
hold on end
end T=T+1; end
PO=S/N; ...
Other Topics:
- Level of Water in a Dam. Engineering Statistics ProjectDescription: This report presents a model of changing level of water in a dam. Minimum level of water in the dam is taken as h=0 and maximum level is given by hmax. Level of water in the dam is determined by rainfall in the catchment area, evaporation and water uses....2 pages/≈550 words| No Sources | Other | Engineering | Statistics Project |