Você está na página 1de 50

Simulasi & Pemodelan

Kuliah 4: Statistical Models

Amer Sharif S.Si, M.Kom

Berdasarkan bahan Dr Anis Koubaa 27 Sep 2014


Goals for Today

 Review of the most common statistical models


 Understand how to determine the empirical distribution
from a statistical sample

2
2
Topics
Discrete Probability Distributions
• Binomial Distribution
• Bernoulli Distribution
• Geometric Distribution
• Discrete Poisson Distribution/Poisson Process
Continuous Probability Distribution
• Uniform
• Exponential
• Normal
Empirical Distributions
3
3
Discrete and Continuous
Random Variables

4
Discrete versus Continuous Random Variables
Discrete Random Variable Continuous Random Variable

Finite Sample Space Infinite Sample Space


e.g. {0, 1, 2, 3} e.g. [0,1], [2.1, 5.3]

Probability Mass Function (PMF) Probability Density Function (PDF)


p x i   P X  x i  f x 
1. f ( x)  0 , for all x in R X
1. p (x i )  0, for all i
2.  i 1 p (x i )  1
 2.  f ( x)dx  1
RX

3. f ( x)  0, if x is not in RX

Cumulative Distribution Function (CDF) p  X  x 

p  X  x   x p  X  x    f t  dt  0
x

x
p (x i )
i 

p a  X  b    f  x  dx
b

5
Expectation

E(X): The expected value (the mean) of X

• Discrete E ( x)   xi p( xi )
all i


• Continuous E( x)   xf ( x)dx


Var(X) : The variance of X


2
• Discrete V X   
n  n

 x i  x   p  x i     x i
2   n

  p  x i     x i  p  x i
2 
 
i 1  i 1   i 1 
   
• Continuous  
V  X    x  x   f  x  dx   x 2  f  x  dx
2
  x2
 
   
6
Model Statistik: Sifat-sifat
Context of applications

Probability distribution (PMF, PDF)

Cumulative Distribution Function (CDF)

Mean/Expected Value

Variance and Standard Deviation

7
Distribusi Probabilitas Diskrit

 Percobaan Bernoulli
 Binomial Distribution
 Geometric Distribution
 Poisson Distribution
 Poisson Process 8
Pemodelan Event Acak dengan
Dua-State
 Percobaan Bernoulli
 Binomial Distribution

9
Percobaan Bernoulli
 Context: Event acak dengan dua kemungkinan nilai
 Dua event:Yes/No, True/False, Sukses/Gagal
 Dua kemungkinan nilai: 1 untuk sukses, 0 untuk gagal.
 Example: Melempar koin, Status Transmisi Paket,
 Sebuah experiment terdiri atas n percobaan.
 Probability Mass Function (PMF): Probabilitas dalam satu percobaan
p, x j  1, j  1, 2,..., n

PMF: p  one trial   p (x j )  1  p  q , x j  0 , j  1, 2 ,..., n
0,
 otherwise

Expected Value: E X j   p Variance :V  X j    2  p  1  p 

 Proses Bernoulli : n percobaan


p  X 1, X 1,..., X n ,   p  X 1   p  X 2   ...p  X n 
10
Binomial Distribution
 Context: Jumlah sukses dalam serangkaian n percobaan.
 Example: jumlah ‘Gambar' muncul ketika sebuah koin dilempar 50 kali.
 Jumlah transmisi yang sukses dari 100 packets
 Probability Mass Function (PMF)
 Binomial distribution dengan parameter n dan p, X ~ B(n,p)
Probabilitas memperoleh k sukses dalam n percobaan

n  k n k n  n!
P  X  k     p  1  p  with   
k   k  k !  n  k !
 di manaN
 k = 0, 1, 2, ......., n k: jumlah sukses
 n = 1, 2, 3, ....... n: jumlah percobaan
 0<p<1 p = probabilitas sukses

Expected Value: E X   n  p Variance :V  X    2  n  p  1  p 

11
Binomial Distribution
Probabilitas sukses k=2 dari n=3 percobaan?
E1: 1 1 0 P(E1)= p(1 and 1 and 0) = p p (1-p) = p2 (1-p)
or
E2: 1 0 1 P(E2)= p(1 and 0 and 1) = p (1-p) p = p2 (1-p)
or
E3: 0 1 1 P(E3)= p(1 and 1 and 0) = p p (1-p) = p2 (1-p)

Probabilitas sukses k=2 dari n=3 percobaan?


p  X  2   p  E 1  p  E 2   p  E 3  3  p 2  1  p 
3! 6
  p 2  1  p   p 2  1  p 
2!  3  2 ! 2
n  n!
 
 k  k !  n  k !
12
Pemodelan Waktu Acak
Diskrit
 Geometric Distribution

13
Geometric Distribution
 Context: jumlah percobaan Bernoulli hingga memperoleh
SUKSES PERTAMA.
 Untuk menyatakan waktu acak hingga terjadinya perubahan yang pertama kali
PMF

 q k 1 p , k  0,1, 2,..., n
PMF: p (X  k )  
0, otherwise

CDF: F  X   p  X  k   1  1  p 
k

1
Expected Value : E  X  
p k

1 p
Variance :V  X    
q
2
2

p p2
14
Pemodelan Jumlah
Kedatangan/Event Acak
 Poisson Distribution
 Poisson Process

15
Poisson Distribution
 Context: jumlah event yang terjadi dalam satu periode waktu yang
tetap (fixed)
 Event terjadi dengan rata-rata yang diketahui dan bersifat independent
 Possion distribution dicirikan oleh tingkat rata-rata 
 Jumlah rata-rata kedatangan dalam satu jangka waktu yang tetap

 Examples
 Jumlah mobil yang melalui satu titik setiap interval 5 menit.
 Tingkat rata-rata:  = 3 mobil/5 minutes
 Jumlah panggilan yang diterima sebuah switchboard dalam satu
periode waktu tertentu. Tingkat rata-rata:  =3 panggilan/minutes
 Jumlah pesan yang masuk ke dalam router per detik
 Jumlah penumpang check-in di bandara per jam

16
Poisson Distribution
 Poisson distribution dengan parameter tingkat rata-rata 

k probabilitas ada tepat k


 exp    for k  0,1, 2, .... kedatangan dalam satu periode
PMF: p  k   P  X  k    k !
waktu
0,
 otherwise
probabilitas ada paling sedikit k kedatangan
i
k
CDF: F  k   p  X  k    i !  exp   
i 0
dalam satu periode waktu

Expected value: E X    PMF

Variance: V  X   
CDF

17
Example: Poisson Distribution

 Jumlah sepeda motor yang masuk ke tempat parkir mengikuti suatu


distribusi Poisson dengan rata-rata  = 20 spd motor/jam

 Probabilitas ada tepat 15 sepeda motor yang masuk ke parkiran dalam satu
jam: 15
20
p 15  P  X  15   exp  20   0.051649
15!

atau p 15  F 15  F 14  0.156513  0.104864  0.051649

 Probabilitas ada lebih dari 3 sepeda motor yang masuk ke parkiran dalam
satu jam: p  X  3  1  p  X  3  1  F  3
 1   p  0   p 1  p  2   p  3 
USE EXCEL/MATLAB
 0.9999967 FOR COMPUTATIONS
18
Example: Poisson Distribution

Probability Mass Function Cumulative Distribution Function


Poisson ( = 20 spd motor/jam) Poisson ( = 20 spd motor/jam)

20k
p X  k    exp  20 
k
20i
k! F k   p X  k   
i 0
i!
 exp  20 

19
Pemodelan Jumlah
Kedatangan/Event Acak
 Poisson Distribution
 Poisson Process

20
Poisson Process

 Process N(t)
 Variabel acak N yang bergantung pada waktu t
 Poisson Process: Process yang memiliki Poisson Distribution
 N(t) disebut poisson process counting (terhitung)
 Ada dua macam:
 Homogenous Poisson Process: tingkat rata-rata konstan
 Non-Homogenous Poissoon Process: tingkat rata-rata
bervariasi

21
Examples of using Poisson Process

 The number of web page requests arriving at a server may be


characterized by a Poisson process except for unusual
circumstances such as coordinated denial of service attacks.
 The number of telephone calls arriving at a switchboard, or at an
automatic phone-switching system, may be characterized by a
Poisson process.
 The arrival of "customers" is commonly modelled as a Poisson
process in the study of simple queueing systems.
 The execution of trades on a stock exchange, as viewed on a tick by
tick basis, is a Poisson process.

22
(Homogenous) Poisson Process

 Secara formal, suatu proses counting N   ,  0 adalah suatu


(homogenous) Poisson process dengan tingkat rata-rata konstan 
jika:
for t  0 and n  0,1, 2,...
(   ) n
PMF: p N t     N t   n   p  N ( )  n   exp    
n!
N ( ) N (q )
t  t+ t++q

jumlah event dalam interval waktu t , t   


 N t     N t  menyatakan
 rata-rata dan varian sama E  N    V  N      
23
(Homogenous) Poisson Process
 Sifat-sifat Poisson process
 Kedatangan terjadi satu per satu (tidak serentak)
 N   ,  0 memiliki penambahan tetap, yang
artinya N t   N s   N t  s 

 Jumlah kedatangan dalam waktu s hingga t juga


berdistribusi-Poisson dengan rata-rata   t  s 
 N   ,  0 memiliki penambahan independen

24
CDF of Exponential distribution

Waktu Antar-Kedatangan Proses Poisson


 Waktu antar-kedatangan: waktu antara dua kedatangan yang berurutan
 Waktu antar-kedatangan suatu proses Poisson bersifat acak
 Apakah distribusinya?
 Perhatikan waktu antar-kedatangan dari Poisson process (A1, A2, …), di
mana Ai waktu yang berjalan antara kedatangan i dan kedatangan i+1

 Keatangan pertama terjadi setelah saat t YANG BERARTI tidak


ada kedatangan dalam interval [0,t], dengan akibat:
p  A1  t   p  N t   0   exp    t 

p  A1  t   1  p  A1  t   1  exp    t 

Waktu
25
antar-kedatangan suatu Poisson process memiliki 25
distribusi exponensial dan independen dengan rata-rata 1/
Splitting and Pooling

 Splitting
p N1(t) ~ Poi[p]
N(t) ~ Poi() 

(1-p) N2(t) ~ Poi[(1-p)]

 Pooling
N1(t) ~ Poi[1] 1
 1  2
N(t) ~ Poi(1  2)
N2(t) ~ Poi[2] 2

26
Pemodelan Jumlah
Kedatangan/Event Acak
 Poisson Distribution
 Non Homogenous Poisson Process

27
Non Homogenous (Non-stationary) Poisson Process
(NSPP)

 Non homogeneous Poisson process dicirikan oleh


suatu a parameter tingkat VARIABLE λ(t), tingkat
kedatangan pada saat t. Secara umum, parameter tingkat
dapat berubah dengan waktu.
1 2 3
 Sifat penambahan tetap tidak dipenuhi:
s ,t : N t   N s   N t  s 
 Jumlah expektasi event (mis. kedatangan) antara saat
s dan saat t adalah
t
s ,t   λ(u)  du
s 28
Example: Non-stationary Poisson Process
(NSPP)

 Jumlah mobil yang melintasi persimpangan Jl Gatot Subroto dengan Jl Sunggal


terdistribusi menurut suatu non homogenous Poisson process dengan rata-rata
(t) sebagai berikut:
80 cars/mn if 8 am  t  9am

60 cars/mn if 9am  t  11pm
 t   
50 car/mn if 11am  t  15 pm
70 car/mn if 15 pm  t  17 pm

 Kita misalkan jam 8 am sebagai t=0.
 Q1. Hitunglah jumlah kedatangan rata-rata mobil pada jam 11.30!
 Q2. Buatlah persamaan yang memberikan probabilitas hanya ada kedatangan
10000 mobil antara jam 12 pm dan 16 pm.

29
Example: Non-stationary Poisson Process
(NSPP)

 Q1. Hitunglah jumlah kedatangan rata-rata mobil pada jam 11.30!


11:30
8:00,11:30   λ(u)  du
8:00
9:00 11:00 11:30
 λ(u)  du   λ(u)  du   λ(u)  du
8:00 9:00 11:00

  80cars/mn  60mn    60cars/mn 120mn    50cars/mn  30mn   13500 cars


 Q2. Buatlah persamaan yang memberikan probabilitas hanya ada kedatangan
10000 mobil antara jam 12 pm dan 16 pm.
Kita tahu bahwa jumlah mobil antara jam 12 pm and 16 pm, yaitu.  N 16   N 12  
mengikuti Poisson distribution. Selama jam 12 pm and 16pm, jumlah rata-rata
mobil adalah 12:0016:00  180  50  60  70  13200 cars
Maka, 13200 
10000

p  N 16   N 12   10000    exp  13200 


10000!

30
Continuous Probability Distributions

 Uniform Distribution
 Exponential Distribution
 Normal (Gaussian) Distribution

31
Uniform Distribution

32
Continuous Uniform Distribution
 The continuous uniform distribution is a family of probability
distributions such that for each member of the family, all intervals of
the same length on the distribution's support are equally probable
 A random variable X is uniformly distributed on the interval [a,b],
U(a,b), if its PDF and CDF are:

0, x a
 1 x a
 , a  x b 
PDF: f (x )  b  a CDF: F (x )   , ax b
0, otherwise b  a
1, x b

Expected value: E  X  
a b  a  b 2
Variance: V  X  
2 12

33
Uniform Distribution

PDF

 Properties
 p  x 1  X  x 2is proportional to the
length of the interval

X 2 X1
F X 2   F X 1  
b a

CDF
 Special case: a standard
uniform distribution U(0,1).
 Very useful for random number
generators in simulators

34
Exponential Distribution

 Pemodelan Waktu Acak

35
Exponential Distribution

 Exponential distribution menggambarkan waktu antara event


dalam suatu Poisson process, di mana event terjadi secara terus-
menerus dan independen pada tingkat rata-rata yang konstan
 Suatu variabel acak X memiliki distribusi exponensial dengan
parameter 1/ > 0 jika memiliki PDF and CDF :
1  x
  exp    x  , x 0   exp   , x 0
PDF: f (x )   f (x )     
0, otherwise 0,
 otherwise

0, x 0 0, x 0
CDF: F (x )   x  t 
F (x )    x
 0 e dt  1  e , x  0
x
1  exp   , x 0
  

1
Variance: V  X  
1
Expected value: E  X     2
 2 36
Exponential Distribution

µ=20 µ=20

1  x  0, x 0
  exp   , x 0 
f (x )   20  20  F (x )    x 
0, 1  exp   , x 0
 otherwise   20 

37
Exponential Distribution
 Sifat memoryless: Dalam teori peluang, memoryless adalah sifat pada distribusi
probabilitas tertentu, yaitu exponential distributions dan geometric distributions,
di mana peluang yang diturunkan dari sejumlah sampel bersifat terpisah/berdiri sendiri
dan tidak memiliki informasi (“memory”) dari sampel sebelumnya.
 Secara formal, sifat memoryless adalah:
Untuk semua s dan t lebih dari atau sama dengan 0:

p X  s  t | X  s   p X  t 
 Ini berarti event di masa depan tidak bergantung pada event di masa lalu, tapi hanya
kepada event di masa kini

 Fakta bahwa Pr(X > 40 | X > 30) = Pr(X > 10) tidak berarti bahwa event X > 40 dan X >
30 saling independent; yaitu, tidak berarti bahwa
Pr(X > 40 | X > 30) = Pr(X > 40).

38
Exponential Distribution

 Sifat memoryless: bisa dibaca sebagai “peluang Anda akan


menunggu lebih dari s+t menit jika Anda telah menunggu s
menit sama dengan peluang Anda akan menunggu t menit.”
 Dengan kata lain “Peluang Anda akan menunggu s menit lagi jika
Anda sudah menunggu t menit adalah sama dengan peluang Anda
harus menunggu selama lebih dari s menit sejak awal.”

p X  s  t | X  s   p X  t 

 Fakta bahwa Pr(X > 40 | X > 30) = Pr(X > 10) tidak berarti bahwa event X
> 40 dan X > 30 saling independen; yaitu, tidak berarti bahwa
Pr(X > 40 | X > 30) = Pr(X > 40).

39
Example: Exponential Distribution

 Waktu untuk memperbaiki mesin sebuah mesin mobil memiliki


distribusi exponensial dengan waktu ratarata 3 jam.
 Probabilitas perbaikan mobil menghabiskan waktu lebih dari 3 jam
  3 
p  X  3  1  p  X  3  1  F  3  1  1  exp      0.368
  3 
 Probabilitas waktu perbaikan mobil butuh waktu antara 2 hingga 3 jam:

p   X  3  F 3  F  2  0.145

 Probabilitas waktu perbaikan akan bertambah 1 jam lagi setelah berjalan 2.5
jam:
Menggunakan sifat memoryless distribusi exponensial, diperoleh:

 1
p  X   2.5  1 | X  2.5   p  X  1  1  p  X  1  exp     0.717
 3
40
Normal (Gaussian) Distribution

41
Normal Distribution

 The Normal distribution, also called the Gaussian


distribution, is an important family of continuous probability
distributions, applicable in many fields.
 Each member of the family may be defined by two parameters,
location and scale: the mean ("average", μ) and variance
(standard deviation squared, σ2) respectively.
 The importance of the normal distribution as a model of
quantitative phenomena in the natural and behavioral sciences
is due in part to the Central Limit Theorem.
 It is usually used to model system error (e.g. channel error), the
distribution of natural phenomena, height, weight, etc.

42
Normal or Gaussian Distribution

 A continuous random variable X, taking all real values in the


range (-∞,+∞) is said to follow a Normal distribution with
parameters µ and σ if it has the following PDF and CDF:
1  1  x   2 
PDF: f  x    exp     
  2  2    
x
1   x    where
  
2
CDF: F  x    1  erf    Error Function: erf  x    exp t 2
2     2   0

 The Normal distribution is denoted asX ~ N   ,  2 


 This probability density function (PDF) is
 a symmetrical, bell-shaped curve,
 centered at its expected value µ.
 The variance is 2.
43
Normal distribution

 Example
 The simplest case of the normal distribution, known as the Standard
Normal Distribution, has expected value zero and variance one. This is
written as N(0,1).

44
Normal Distribution
 Evaluating the distribution:
 Independent of  and , using the standard normal distribution:
Z ~ N  0,1 z 1 t 2 / 2
, where ( z )   e dt

2
X 
 Transformation of variables: let Z 

 x 
F ( x )  P  X  x   P Z  
  
( x ) / 1 z2 / 2
 e dz

2
( x ) /
  ( z )dz  ( x  )

45
Normal Distribution
 Example: The time required to load an oceangoing vessel, X, is
distributed as N(12,4)
 The probability that the vessel is loaded in less than 10 hours:
 10  12 
F (10)     (1)  0.1587
 2 
 Using the symmetry property, (1) is the complement of  (-1)

46
Empirical Distribution

47
Empirical Distributions

 An Empirical Distribution is a distribution whose


parameters are the observed values in a sample of data.
 May be used when it is impossible or unnecessary to establish
that a random variable has any particular parametric
distribution.
 Advantage: no assumption beyond the observed values in the
sample.
 Disadvantage: sample might not cover the entire range of
possible values.

48
Empirical Distributions
 In statistics, an empirical distribution function is a cumulative
probability distribution function that concentrates probability
1/n at each of the n numbers in a sample.
 Let X1, X2, …, Xn be iid random variables in with the CDF equal to
F(x).
 The empirical distribution function Fn(x) based on sample X1, X2, …,
Xn is a step function defined by
n
number of element in the sample  x
 I X
1
Fn  x    i x
n n i 1

where I(A) is the indicator of event A.I  X i  x     i 


1 if X  x

0 otherwise
 For a fixed value x, I(Xi≤x) is a Bernoulli random variable with
parameter p=F(x), hence nFn(x) is a binomial random variable
with mean nF(x) and variance nF(x)(1-F(x)).
49
End of Chapter
4
50

Você também pode gostar