adom Varate Geerato ENM 307 SIMULATION Aadolu Üverstes, Edüstr Mühedslğ Bölümü Yrd. Doç. Dr. Gürka ÖZTÜK 0
adom Varate Geerato adom varate geerato s about procedures for samplg from a varety of wdely-used cotuous ad dscrete dstrbutos. Wdely-used techques are cosdered. outes programmg lbrares or bult to smulato laguage Iverse trasform techque, acceptace-rejecto techque All techques use a source of uform [0,] radom umbers,, f ( ), 0, 0 otherwse F 0, 0 ( ), 0, 0
Iverse-Trasform Techque Iverse-trasform techque ca be used to sample from Epoetal Uform Webull Tragular Emprcal Etc. It s uderlyg prcple for samplg from a wde varety of dscrete dstrbutos. 0
Iverse-Trasform Techque Epoetal Dstrbuto Probablty desty fucto (pdf) e f ( ) 0,, 0 otherwse The parameter ca be terpreted as the mea umber of occurrece per tme ut. If the terarrval tme X, X, X 3, had a epoetal dstrbuto wth rate, the could be terpreted as the mea umber of arrvals per tme ut. Epected value of X, E( X ) s the mea of terarrval tme. f() pdfs for several epoetal dstrbutos.0.8 0.5.6.4.5..0 0.8 0.6 0.4 0. 0.0 0.0 0. 0.4 0.6 0.8.0..4.6.8.0..4.6.8 3.0 0
Iverse-Trasform Techque Epoetal Dstrbuto Cumulatve dstrbuto fucto (cdf) F ( ) f ( t) dt t e dt, 0 0 e, 0 F( ) 0, 0 0 0 The goal s to develop a procedure for geeratg values X, X, X 3, that have a epoetal dstrbuto. Iverse-trasform techque ca be utlzed for ay dstrbuto If F - ca be computed easly the t s most useful 0
Iverse-Trasform Techque Step-by-step procedure o Epoetal Dstrbuto Step : Compute the cdf of the desred radom varable X. For the epoetal dstrbuto, cdf F( ) e, 0. Step : Set F()= o the rage of X. For the epoetal dstrbuto, e X, 0. Step 3: Solve the equato F()= for X terms of. For the epoetal dstrbuto, the soluto proceeds as follows: X e Step 4: Geerate (as eeded) radom varables,, ad compute the desred radom varates by For the epoetal case e X X l( ) X l( ) X F ( ) X l( ) or X l 0
= Eample 8. 3 4 5 0.306 0.04 0.6597 0.7965 0.7696 X 0.400 0.043.0779.59.4679 F()=-e - e X F( 0 ) =-e -X X X l( ) l( 0.306) l 0.8694 0.400 0 X X =-l(- ) 0 0
Iverse-Trasform Techque Uform Dstrbuto Probablty desty fucto (pdf) f() a b, f ( ) b a 0, a b otherwse Step: Cumulatve dstrbuto fucto (cdf) s gve by F() 0 Step: Set F(X)=(X-a)/(b-a)= a 0, a F( ), b a, Step3: Solvg for X terms of yelds X=a+(b-a) b a a b b 0
Iverse-Trasform Techque Webull Dstrbuto Probablty desty fucto (pdf) f ( ) 0 e ( / a), 0,otherwse Step: The s gve by F(X)=-e -(/), 0 Step: Set F X = e α β = Step3: Solvg for X terms of yelds X = α l /β 0
Iverse-Trasform Techque Tragular Dstrbuto Probablty desty fucto (pdf).0 0.8 0.6 0.4 0. 0.0 0 3 Cumulatve dstrbuto fucto.0 0.8 0.6 0.4 0. 0.0-0 3, 0 f ( ), 0, otherwse 0,, F( ) ( ), 0 0, For 0, For, ( ) X, ( ), 0 0
Iverse-Trasform Techque Emprcal Cotuous Dstrbuto-Eample 8. Fve observatos of fre-crew respose tme ( mutes) to comg alarms:.76.83 0.80.45.4 Arrage the data from smallest to largest () () (3) () Smallest value s cosderd as 0, so (0) =0 a Iterval (-) () / ( )/ Probablty / ( ) ( ) ( ) ( ) / Cumulatve Probablty, / Slope a 0.0 0.80 0. 0. 4 0.80.4 0. 0.4.5 3.4 0.45 0. 0.6.05 4.45.83 0. 0.8.90 5.83.76 0..0 4.65 X Fˆ ( ) ( ) ( ) a..0 0.8 0.6 0.4 0. 0.0 0.8; 0..45; 0.6.4; 0.4 3;.76;.83; 0.8 0; 0 0 3 4 0
Iverse-Trasform Techque Emprcal Cotuous Dstrbuto-Eample 8.. Iterval (-) () Probablty / Cumulatve Probablty, / Slope a 0.0 0.80 0. 0. 4 0.80.4 0. 0.4.5 3.4 0.45 0. 0.6.05 4.45.83 0. 0.8.90 5.83.76 0..0 4.65.0.76; 3; X a (4 ) / ) (4 ) 4 (.45.90(0.7 0.60).66 0.8 0.6.45; 0.6.83; 0.8 0.4.4; 0.4 0. 0.0 0.8; 0. 0; 0 0 0.5.5 X.5 3 3.5 0
Cotuous dstrbutos wthout Closed-Form Iverse A umber of cotuous dstrbutos do ot have closed form epresso for ther cdf or ts verse: For eample Normal Gamma Beta Iverse trasform techque for radom varete geerato s ot avalable for these dstrbutos. A appromato for verse trasform ca be used. Smple appromato to the verse cdf of stadard ormal dstrbuto, (Schmeser [979]) X F ( ) ( ) 0.795 0.35 0.35 Appromate Iverse Eact Iverse 0.0 -.363 -.3373 0.0 -.86 -.83 0.5-0.6745-0.673 0.50 0.0000 0.0000 0.75 0.6745 0.673 0.90.86.83 0.99.363.3373 0
Dscrete Dstrbutos All dscrete dstrbutos ca be geerated va verse trasform tecque, Numercally, through table-lookup procedure Algebracally, fal geerato scheme beg terms of a formula Other techques are sometme used for certa dstrbutos, e.g. Covoluto techque for bomal dstrbuto. 0
Dscrete Dstrbuto A Emprcal Dscrete dstrbuto Eample 8.4. Dstrbuto of umber of Shpmets, X The probablty mass fucto (pmf) P(0)=P(X=0)=0.5 P()=P(X=)=0.3 P()=P(X=)=0. Cumulatve dstrbuto fucto p() F() 0 0.50 0.50 0.30 0.80 0.0.00 0 0.5 F( ) 0.8 0 X 0 0 0.5 0.5 0.8 0.8.0 F() =0.73 X = 0 3 0
0 Dscrete Dstrbutos Uform Dstrbuto Dscrete uform dstrbuto o {,,,k} pmf Cdf = ad r =p()+p()+ +p( )=F( )=/k for =,,,k k k p,...,,, ) ( k k k k k k k F,, 3,, 0, ) ( k r k r k X k k k
Dscrete Dstrbutos Geometrc Dstrbuto Geometrc dstrbuto wth pmf p( ) p( p), 0,,,... Cdf F( ) p( j 0 p) j p ( p) ( p) F( ) ( p) Iverse trasform F( ) ( p) ( p) F( ) ( p ) ( p) ( )l( p) l( ) l( p) l( ) l( p) l( ) l( p) l( ) X l( p) 0
Acceptace-ejecto Techque X uformly dstrbuted betwee /4 ad Step: Geerate a radom umber Stepa: f /4, accept X= the go to Step 3. Stepb: f </4, reject the retur to Step. Step3: f aother uform vaete o [/4,] s eeded, go to Step else stop. 0
0 Dscrete Dstrbutos Posso Dstrbuto A Posso radom varable, N, wth mea >0 has pmf N=,,...,! ) ( ) ( e N P p t=0 t= t= A A A 3 A A A + A A A A A A A l l l l l l e
Dscrete Dstrbutos Posso Dstrbuto The procedure for geeratg a Posso radom varate, N, s gve by followg steps Step: Set =0, P= Step: Geerate a radom umber + ad replace P by P. + Step3: f P<e -, the N=. Otherwse, reject, crease by oe, ad retur to step. Eample 8.8 : =0. Frst compute e - =e - =0.887. Step: =0, P= Step: =0.4357, P=. =0.4357 Step3: sce P=0.4357<e - =0.887, accept N=0. Step-3: ( =0.446, leads to N=0) 0
Dscrete Dstrbutos Posso Dstrbuto Step: =0, P= Step: =0.8353, P=. =0.8353 Step3: sce P=0.8353e - =0.887, reject, ad retur step wth =. Step: =0.995, P=. =0.833 Step3: sce P=0.833e - =0.887, reject, ad retur step wth =. Step: 3 =0.8004, P=.. 3 =0.6654 Step3: sce P=0.833<e - =0.887, accept, N=. + P Accept/reject esult 0 0.4357 0.4357 P<e - accept N=0 0 0.446 0.446 P<e - accept N=0 0 0.8353 0.8353 Pe - reject 0.995 0.833 Pe - reject 0.8004 0.6654 P<e - accept N= 0
=4 buses per hour Pe -4 0.083 Dscrete Dstrbutos Posso Dstrbuto Whe s large, say 5 the rejecto techque becomes qute epesve. Z N Z s appromately ormal dstrbuted wth mea zero ad varace. + P Accept/reject esult 0 0.4357 0.4357 Pe - reject 0.446 0.806 Pe - reject 0.8353 0.508 Pe - reject 3 0.995 0.50 Pe - reject 4 0.8004 0.0 Pe - reject 5 0.7945 0.0955 Pe - reject 6 0.530 0.046 P<e - accept N=6 The posso varate ca be geerated N Z 0.5 0