You are on page 1of 19

Introduction to

Simulation

Lecture 8

Dr. Samah Mohammed 1


Objectives

Simulation of the beggar earns.

Random Number Generation

2
How much the Beggar Earns
There is one beggar passed around the houses asking for
money and from her experience she know if the people
speak with her behind the doors 80 % of them are women
and 20% are men.
The 70 % of the women give her money but 40 % of the
men only give her the money.
The amount of money given by the women between (18 ,
22).
The amount of money given by the men between (7,10)
3
Simulation of the Beggar Earns
Example (7)
The beggar cover around 10 to 15 houses per day .
Do the simulation for 5 days.

Result:
Decide the average of the earns money per day.

4
Simulation of the Beggar Earns
Example (7) Cont...
The distributed probability table of the visited houses by the beggar

Number of Houses Probability Cumulative Probability Random Number

10 0.167 0.167 0.00000-0.16666

11 0.167 0.334 0.16667-0.33320

12 0.167 0.501 0.33321-0.49980

13 0.167 0.668 0.49981-0.66640

14 0.167 0.835 0.66641-0.83300


5
15 0.167 1.002 0.83301-1.00000
Simulation of the Beggar Earns Cont...

The distributed probability table for who answer (F/M):

Cumulative
Probability

6
Simulation of the Beggar Earns Cont...
The distributed probability table for female pay:
Cumulative Probability

The distributed probability table for male pay:

Cumulative Probability

7
Simulation of the Beggar Earns Cont...
The distributed probability table for female donation:

Cumulative Probability

8
Simulation of the Beggar Earns Cont...
The distributed probability table for Male donation:

Cumulative
Probability

9
Simulation of the Beggar Earns Cont...
Part of simulation

10
Simulation of the Beggar Earns Cont...

11
Simulation of the Beggar Earns Cont...
By the end of the 5 days .The beggar earns 715 Pounds.
Avg. Earns = Total earns

Number of day

=715/5= 143 Pounds

12
RANDOM NUMBER GENERATION
 Random number is very important for the
simulation modelling algorithm as we see
in the previous lectures so we want to
know how we will generated and what is
their attributes of the random number.

13
RANDOM NUMBER GENERATION
(CONT.)

Each random number Rt is an independent and stable


sample drawn from a continuous uniform
distribution between 0 and 1

ì1 , 0 £ x £ 1
f(x) = í
î0 , otherwise

14
RANDOM NUMBER GENERATION
(CONT.)

15
RANDOM NUMBER GENERATION
(CONT.)

Expected number of Ri

1
E (R )    [x / 2 ] 10  1 / 2
2
x dx
0
1
V (R )    [ E ( R )]
2 2
x dx
0

 [x 3 / 3] 1
0  (1 / 2 ) 2
 1 / 3  1 / 4
 1 / 12
16
RANDOM NUMBER GENERATION
(CONT.)

The important attributes for the equal and stable


distribution are:
If we divide the period (0,1) into n sets with equal
length then the expected number of seeing in each set is
N/n consider N is the total number of seeing.
The probability of seeing value in set is independence
value of the other seeing.

17
PSEUDO-RANDOM NUMBER
GENERATION

The pseudo-random number have the same attributes


of the random number but had been generated by a special
mathematical formula.
To generate random number we must used random
method like write the number (0—9) in part of papers
mixed together then select one of them first will get 9 then
select again will get 3 ,7 ,4 continuously. we see these is
very difficult way to generate random number so we have
to find easy way to generate random number in the next
lecture.
18
Tutorial
From the following table find :
Average earns per day for the beggar.
Average of female donate.

Days Houses house Type(F/M) If payed how much Total


Day one 4 1Female yes 20
2Male yes 9
3Female yse 19
4Female yes 17
         
Day two 5 1Female yes 11
2Male yse 10
3Female no 0
4Male yes 9
5Male no 0
           
Day three 4 1Male yes 8
2Female yes 20
3Male yes 5
4Female yes 18 19
         

You might also like