Simulation Modeling Lab Report Ankit Pangeni 1
Simulation Modeling Lab Report Ankit Pangeni 1
n+mainC
Cu [?3 +[ k2
* C3 CP] -Ki * CI Lr3* C2 Cr])*dE
cuT+13 J*c2C73)*de
C2C3+( ke * (a CJ- k
* c C
C2Ct -
Ca C
2.0*(kJ* CJt/) C2 Cf]
-KeX
cgC+: C3[7]+
tttdt
So
2D
J0
Simolakon
Modeling
Csc 3/ AndEPane
a b Tas 02
Soura Cocke
#nude Lioktream
Lc9tdIPb>
t mtlvde
Pnciude Lchsme
nuuode 4graphieg-hs
hardum andy Coordinales betwan -12
Foncfon to penelake
vofd generale Yandon-point double wr, Jouble
vofd v)
(doubie) Yand(O/2AN NAY*2 -
(doobie) fand) RAND. NAX *2 -J;
nt maio ()
enasn
Pnt i, cirtle poïnts so, S9vamepo?nds:0,
dobe
s4d: Cout 4 "En ter the nunber a ferah'on
S+d: cin PHetadton
t windOw I/T%kalze Jhe grap hics winod
(6o0, 60);
ouw (600, 600) '
tho Vandom noynns
Srand sead for
Telo)): lsol the
Draw CPrtle y
Squane
Cicle 360, 300, 200 )
Fettangle (100, Joo, So0,So)
PertbYD Monfe caslo SPmulah 0
cfclepomts ++
Putpizel( 30o + * 200, 30o +y #2 00, 7 R¬Eu):
else
aphios Wndo
ConctuSon
Armu lal ed he
dis erede s
ydem by ekmaky
Hona, we
Monte Carlo simuaton
he vawe e pr dSing
sc. cs1T Sh SemesleY
C3C 3/9 Stmuahon u Modelrng
Ankit Pangeni
Lab Ta 03 ono
e : Pandom Nom ber Smulaton)nenerakn
eckue The objethve ef his ask Ps t girtJennade
random numbes Using:
NiLed Conguentia Method
Addhve guetial Method
3
Mu4TpIPcakve Cong venHPal Hethod
4Ahmelie Congrvenka Hethod
ohen,
Cwhe, Xo fs Calind seod, a is caad Con& ant muiphieu,
CPs Caued Pncrement and m fs caled modulug
Swch num)
COse
Case / Enter the congland
molteplier 7:
")
P Scant" ood, a)
prind "n
Enter the ircrement C:
7od") c); "
Scant "
(C=o) rtandam nonbe
o PP2n,?++) / Sop h generate
XI(7*Yoc) 70 m
3TYay [f] XJ,
Xo-
Pntt|n YTod *od ",i, aray li3)D
pintf"E");
3
else
prin+}"for nined cong uenka) vawe of c Cant be em'");
Cage 2
Pin o enter the ?nereme c');
Scan"olod", ) ;
X J *
+c) 1om Xo
aYray C]:X2'
Xo X
p n " | o lhe generaBed raneom numbes are:");
or ( fl -
n, ?++)
printtl In X rod- 7od",?, arvayC );
prin (" 1E "); brezc,
Cale 8:
Caße nttn Enr the Condant
Scant o1od", a);
mukp lir a:");
2
a* Xo) "7o m
aTTay i] X1,
X0
PiH nThe generaBed
random numbs are:"),
are:"),
or(P 94 -D; u+)
n n Xmod: od",?, 7YYay i J )
PraintH")E"),
( breaK)
3
break
Case 2
Prin In Enter the seedvawe Xo: ")
Scant" 01od", Xo),
Pitt("]n Entor the seed vawe Xi: ")
Scan 07od"', X);
rind n Enter the moduus m: ");
Scant("od")um);
" n How many mandm numbors yoo want
Jenarae: ");
Scan' od", un);
X2- (Xb+Xn) 7o m
X0X1
Y=X,
bin"o Xlods nod", ? +u,
7*ra4[)),
printt"E");
re k
Yetm D
AtMDAsnkAi
Outpot
Choose the methd:
"nay lng Tvenhal mathod
1Thmmea¢ longruenhal mathod
2
Enter tho seed y Zwe io:S
Enter he seed vawe Xi
Eoterthe modulus m:Jo
HLo
many ranolem numbos y ou
J
cwont to qenavak Jo
he generafed rand orm numbes ae
Xa
X3:7
Xy=9
X3
3:9
XD 0
Xn9
3 st( STT sth SemesBen.
Cse 3/0Stmulatn Hodeling Panger
fask Ps fesd
fhe
Objeckue: The objechkve
al this ker te
using
Ch7- squ7re 2 Po
andom numbers
Rolal edTraoy
ChtSqvane tet andm numbees
unrorm pavpeoty
epds he
Tuse the Samplo dzhshe:
(or-E
fn the
f-th c l s , t:
3s the obceve mymbes jhe naClais
he, l0 ith class, e n
fs
numbn în the
t h e epettes
tu
t a
baseo m
a based
n
Po en-et ndeperdenca
Tndependen
Tey i he ted for Jepeated
epeaed
whn« wh0«
he poker dgls tertain
z
he
Aaa
A rn
d
wth
wtch teMs
deds ffn
7reguency Thi's
This tek na
teW n a my
et h e d
dts
s
also
also
nwmben.
bu4
buj
Sehies ebd
Sevs
vence e numbe,
nombe he epeceel
enpeckeel
aw
va we
e
0mas o4
the seg The numbee
s
&e n
nuummbbee
s
each Bf n'n a a
Compriiny e ds s the
Ch?.
mbinatm mans e
e by dne
de AhHe
*
e
vaue
Sqvase te for
or Che. S9vare S ou
S m
acceplabe Freuat
Ck.sgvare
vawe
vaR oo an fe npdene
enveod sa
pbs adeaHs
&pectked
e
Combinatns
drexchn
degret ef
en
ro 1270
0UTCO Cods
h c tude 4sldroh»
nctude zconfo»
Pnctude t stdiîb-h>
Poctude 24ime.h>
Jo //no o tndetvas
dene TNTEAVALs a9sumad ag- S 9o 2 d(:9
tFdefre +abylaBed. vawe J6.919//we
Pnt ma'n vod)
random no to be genvated
Int o- ,; //oz Se ed, Ziz nett
Cneremenb, memed
t
S C:3, m:Joo; / ar(ons/am mulhpior,
fnt nl0o; }) s/ze e he Samp le.
nt b[INTEAVALS): So, Jo»20, 30, 40,50o,6o, 70 90, go ; //ortuer bounds
nt ublTn fER VALS]-919,29.39,49,r9, 69,99,9 9,39};/|uppex bound f mieu
nt observed [TNTERVALS) So}. ezpeeled, N=0
toBa o ohseved kr y
bsekveregvencie, ezpecded treq ueg,
sdoe the Jandom numbers feneakd
Ynt .array [1 00); I]4»
loat calcwlabon l2o, final each TnBewal
*Catw 1akon s
fhe vatwe e lor-er) Jer ef Intevzs */
total cat w/aBed au
vawe
and hal fs he
orf:0 j sj++)
TNTERVALS
printt"In. --
Ana);
)elE 7od lElEJEE To',N,
Tintt"ln P's atp
calcoiated vawe Contdude Ho
tabuialed y
|/lCompaue
vaiue)
1 l 2- tabulzdel vawe -
p. So, e
Printnn The
catcwlakd vawe
: Tofk.7aby/aded
/abu afed.vaue)
hejeeled."1fnal,
nUi hypothesis s not
nok.
nd > Taby/ted
vaue-
Or E
(0i-Fi) *(0,-E:))/G
SWo 0
Jo J0 0000 0
19 6 00o00
Jo
2 2 J0 b00 000
3 0
L
22:Soo060
2s 0
J0 00O 000
0
22 So 0 00
2
10 00 o000
0
JO J0. 00 0 000
22.So00o0
Jo 2S
-
J4S 99999
Jo0
.
doUTe Code
ee
CAL H2sduAREt=(l
(obsorved. freqvenyl1 -evpetkdtregvenyEA7)*
(oherved eg veneyts 7. epethetregvenatJg))
expected.treq veny t);
3
painthl "lohe SumCauwladed chr sguare sdabehes s
Tok", c ALL (HEs AuA RE J;
errintt"The tabutated vae fr Chirgvave ii Tof , TAR
CHtsgop6),
AL CHTs8vARE TARHTS&UA