0% found this document useful (0 votes)
5 views

1 INTRODUCTION model and simulation

The document discusses the importance of decision analysis and simulation in understanding complex systems and managing uncertainty in contemporary societies. It defines modeling as the process of creating abstract representations of real-world phenomena to evaluate and optimize alternatives, while simulation allows for the exploration of interactions within these models over time. Various types of models, including physical, mathematical, analogue, and simulation models, are outlined, emphasizing their roles in scientific inquiry and decision-making.

Uploaded by

Osuwa Maryam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

1 INTRODUCTION model and simulation

The document discusses the importance of decision analysis and simulation in understanding complex systems and managing uncertainty in contemporary societies. It defines modeling as the process of creating abstract representations of real-world phenomena to evaluate and optimize alternatives, while simulation allows for the exploration of interactions within these models over time. Various types of models, including physical, mathematical, analogue, and simulation models, are outlined, emphasizing their roles in scientific inquiry and decision-making.

Uploaded by

Osuwa Maryam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

1I

NTRODUCTI
ON
Theabi li
tyofmant odef i
newhatmayhappeni nt hef utureandt o
chooseamongal ternativesl ieatt hehear tofcont empor arysociet
ies.
Ourknowl edgeoft hewayt hings
wor k,i nsoci etyornat urear et r
ailedwi t
hcl oudsofi mpr ecisi
on,and
vasthar mshav e
foll
owedabel iefi ncer tainty.Tor educet hel ev elofdi spar i
tybetween
outcomeand
reali
ty ,wer equi readeci sionanal ysisandsuppor tt oolt oenabl eust o
evaluat e, compar e
and opt i
mi ze al ternat i
ve.Such a t oolshoul d be abl et o provi
de
explanat i
onst ov arious
stakehol der sanddef endt hedeci sions.Onesucht oolt hathasbeen
successf ul l
yempl oy ed
i
ssi mul at ionwhi chweuset ov aryt hepar amet erofamodeland
obser v et heout come.
Simul ationhasbeenpar t
icularlyvaluabl e:
(a)When t her ei ssi gnifi
cantuncer taint
yr egar ding t heout comeor
consequencesofa
particularal ternativeunderconsi der ati
on.Ital lowsy out odealwi th
uncer taint y
andi mpr eci sioni naquant if
iableway .
(b)Whent hesy stem underconsi der ati
oni nv
ol vescompl exi nter
acti
ons
andr equi res
i
nputf r
om mul t i
pledi sciplines.Int hi
scase,i ti sdi fficul tforanyone
persont o
easilyunder standt hesy stem.Asi mul ati
onoft hemodelcani nsuch
sit
uat ionsact
ast hef ramewor ktoi ntegrat ethev ar i
ouscomponent sinor dertobetter
under stand
theiri nteract i
ons.Assuch,i tbecomesamanagementt oolt hatkeeps
youf ocused
ont he" bi gpi cture"wi thoutget tingl ostinunimpor t
antdet ail
s.
(c)Whent heconsequencesofapr oposedact ion, planordesi gncannot
bedi rect lyand
i
mmedi at ely obser ved ( i
.e.,the consequences ar e del ay ed i
nt i
me
and/ ordi sper sed
i
nspace)and/ ori ti ssimpl yimpr act i
calorpr ohi bitivelyexpensi vet o
testt he
Alternat ivesdi rectly.

3.0Modeli
ngandSimulat
ionConcept s
Modernsciencewoul
dbei nconceivabl
ewi t
houtcomput
erst
ogather
dataandrunmodel
si
mulati
ons.Whet
heri
tinvol
vesbringingbackpi
ctur
esoft
hesurf
aceof

1
theplanetMars
ordet ai
ledi
magest ogui
debrainsurgeons,computer
shav egreat
ly
extendedour
knowledgeoft heworl
daroundusandourabi l
i
tyt oturnideasint
o
engineeri
ngr
ealit
y.
Thusmodel i
ngandcomputersi
mulat
ionareimportanti
nterdi
scipl
i
nary
tools.

3.1Def initi
ons
a.Model li
ng i st he pr ocess of gener at i
ng abst ract,concept ual,
graphi cal and/ or
mat hemat icalmodel s.Scienceof fersagr owi ngcol lectionofmet hods,
techni quesand
theor yaboutal lkindsofspeci alizedsci enti
fi
cmodel li
ng.
Model li
ngal someanst of i
ndr elationsbet weensy stemsandmodel s.
Statedot her wise,
model s ar e abst ract i
ons ofr ealori magi nar ywor l
ds we cr eat et o
under standt heir
behav iour ,playwi tht hem byper for ming" whati f"exper i
ment s,make
project i
ons,
animat eorsi mpl yhav efun.
b.Amodeli ngener alisapat tern,pl an,repr esentat i
on( especiallyin
mi niatur e), or
descr ipt iondesi gnedt oshowt hemai nobjectorwor kingsofanobj ect,
system, or
concept .
c.Amodel( phy sicalorhy pothet ical)isar epr esentationofr eal-wor l
d
phenomenonor
element s( objects,concept sorev ent s).Statedot herwiseamodeli san
attemptt o
expr essapossi blest ructureofphysi calcausal i
ty.
Model si nsci encear eof tent heor eti
calconst ructst hatrepresentany
par t
icul art hing
with a setofv ariables and a setofl ogi caland orquant itativ
e
relationshi psbet ween
them.Model si nthi ssensear econst r
uctedt oenabl er easoningwi thi
n
ani deal ized
l
ogi calf ramewor k aboutt hese pr ocesses and ar e an i mpor t
ant
componentofsci entific
theor ies.
d.Si mul ation- i
st hemani pulat i
onofamodeli nsuchawayt hati t
oper at esont i
meor
spacet ocompr essi t
,thusenabl ingonet oper cei
v et heinteractions
thatwoul dnot
other wi sebeappar entbecauseoft heirsepar ationint i
meorspace.

2
e.Model ingandSi mul ationi sadi sci
pli
nef ordev elopingal evelof
under standi ngoft he
i
nteract ionoft hepar tsofasy stem,andoft hesy st
em asawhol e.The
l
ev elof
under standi ngwhi chmaybedev elopedv iat hi
sdi sciplineissel dom
achiev ablev i
a
anyot herdi scipli
ne.
f.Acomput ermodeli sasi mulationormodelofasi tuationinther eal
wor l
doran
i
magi nar ywor l
dwhi chhaspar amet ersthattheusercanal ter
.
Forexampl eNewt onconsi dersmov ement(ofpl anetsandofmasses)
andwr ites
equat ions,among whi ch f= ma ( wher efi sf orce,m massand a
acceler ation) ,t
hatmake
the dy nami cs i ntelli
gible. Newt on by t his expr ession makes a
formidabl epr oposi t
ion, that
forcecausesaccel eration,wi t
h massaspr opor t
ionalitycoefficient.
Anotherexampl e, a
model airplanei saphy sical r
epresent at
ionofther ealairplane;model of
air
planesar e
usefuli npr edi cti
ngt hebehav ioroft herealairpl
anewhensubj ectedt o
dif
ferent
Condi tions; weat her ,speed, l
oad, etc.Model shelpusf r
ameourt hinking
aboutobj ect sin
ther ealwor l
d.Itshoul dbenot edt hatmor eof t
ent hannotwemodel
dynami c( changi ng)
systems.

3.2Whati sModel ingandSi mul ati


on?
Model i
ngi sadi sci pli
nef ordev elopingal evelofunder standingoft he
i
nt eractionoft he
par ts ofa sy stem,and oft he sy stem as a whol e.The l evelof
under standingwhi chmaybe
dev eloped v iat his di scipl
i
ne i s seldom achi ev ablev i
a any ot her
discipli
ne.
Asi mulationi sat echni que(notamet hod)forrepr esentingady nami c
real worldsy stem
by a modeland exper i
menting wi t
ht he modeli n or dert o gai n
i
nf ormat ionaboutt he
syst em andt her efor etakeappr opriatedecision.Simul ati
oncanbedone
byhandorbya
comput er.Simul ationsar egener all
yiterati
veint heirdev elopment .One
dev elopsamodel ,
simul atesi t
,learnsf r
om t heresult,revi
sest hemodel ,andcont inuest he
i
ter ati
onsunt i
lan

3
adequat elev elofunderstandi
ngi sat tained.
Model li
ngandSi mul at
ionisadi scipli
ne, itisal
sov erymuchanar tform.
Onecanl ear n
aboutr idingabi cyclefrom readingabook.Tor eallylear
nt oridea
bicy cleonemust
become act i
velyengaged wi t
h a bi cy cle.Model li
ng and Simul ati
on
followsmucht he
samer ealit
y.Youcanl earnmuchaboutmodel li
ngandsi mulati
onf r
om
readi ngbooksand
talkingwi thot herpeopl e.Skil
landt alenti ndev elopingmodel sand
per forming
simul ations i s onlydev el
oped t hrough t he bui
lding ofmodel s and
simul atingt hem.I ti
s
verymuch “ learn asy ou go”pr ocess.Fr om the i nter
acti
on oft he
dev eloperandt he
model semer gesanunder standingofwhatmakessenseandwhat
doesn' t.

3.3Ty peofModel s
Ther e ar e many t ypes of model s and di fferent way s of
classi fy i
ng/ groupi ngt hem.For
Simpl i
ci ty
,Model s may be gr ouped i ntot he foll
owi ng – Physical
,
Mat hemat ical,
Anal ogue, Si mul ati
on, Heur isti
c,Stochast icandDet erminist
icmodels.
a.Phy si cal Model s
Thesear ecal liconi cmodel s.Goodexampl esofphy sicalmodelsar e
model car s,model
rail
way , modelai r
pl ane,scal emodel s,etc.Amodelr ailwaycanbeused
tost udyt he
behav iourofar ealr ail
way ,alsoscal emodel scanbeusedt ostudya
plantl ay outdesi gn.
Insimul ati
onst udies, i
conicmodel sar er arel
yused.
b.Mat hemat icalModel s
Thesear emodel susedf orpr edict
ive( pr oj
ecti
ng)pur poses.Theyar e
abst ractandt aket he
form ofmat hemat icalexpr essionsofr elationships.Forexampl es:
1.x +y =1(
2 2
mat hemat i
calmodel ofaci rcleofr adius1)
2.Int erest=Pr incipal xRat exTi me/ 100
3.Li nearpr ogr ammi ngmodel s
Mat hemat icalmodel s can be as si mpl e as interestear ni
ngs on a
savingsaccountoras
compl exast heoper ati
onofanent iref actoryorl andingast r
onautson
themoon.The
dev elopmentofmat hemat icalmodel sr equiresgr eatdealofski l
land
knowl edge.

4
c.Anal ogueModel s
Thesear esi mi lart oi conicmodel s.Buther esomeot herent it
iesar e
usedt or epresent
direct lyt heent iti
esoft her ealwor l
d.An exampl ei st heanal ogue
comput erwher et he
magni tudesoft heel ectri
calcur rent sf l
owi ngi naci rcuitcanbeusedt o
repr esent
quant iti
esofmat eri
alsorpeopl emov i
ngar oundi nasy stem.Ot her
exampl esar e; the
gaugeusedt ocheckt hepr essur ei nat yr
e.Themov ement soft hedi al
repr esentt heai r
pressur ei nt het y r
e.Inmedi calexami nation,t hemar ksofel ect r
ical
cur rentonpaper , i
s
theanal oguer epr esentationoft hewor kingofmuscl esoror gans.
d.Si mul at i
onModel s
Her e,i nst ead of ent i
ti
es bei ng r epresent ed phy si
cal l
y ,t hey ar e
repr esent edbysequences
ofr andom number ssubj ectt ot heassumpt i
onsoft hemodel .These
model sr epresent
(emul at e)thebehav i
ourofar ealsy st em.Theyar eusedwher et her ear e
nosui t
abl e
mat hemat i
calmodel sorwher et hemat hemat i
calmodeli st oocompl ex
orwher ei tisnot
possi blet oexper i
mentuponawor kingsy st em wi thoutcausi ngser i
ous
disrupt i
on.
e.Heur isticModel s
Thesemodel susei ntuiti
ve( orf ut uristic)ruleswi ththehopet hati twi l
l
producewor kabl e
Sol ut i
ons,whi chcanbei mpr ov edupon.Forexampl e,t heAr thurC
Cler k’sheur i
st i
c
modelwast hef orerunneroft hecommuni cationssat elli
teandt oday ’
s
i
nt er nat i
onal
telev isionbr oadcast .
f.Det ermi nisticModel s
These ar e model st hatcont ain cer tain known and f ixed const ant s
throughoutt hei r
formul at i
one. g.,Economi cOr derQuant ity( EOQ)f ori nv entorycont rol
under
uncer tainty.
g.St ochast i
cmodel s
Thesemodel suseoneormor euncer tainv ariablest hatar esubj ectt o
probabi liti
es.

5
3.4Advant
agesofUsi ngModels

Theyaresafer.

Theyarelessexpensiv
e.Forexample,
Pract
ical
Simulat
orsar
eusedt
o
tr
ainpi
l
ots.

Theyareeasiertocontr
olt
hantherealworl
dcounter
part
s.

3.5Applicati
ons
Oneappl icat
ionofsci ent
if
icmodel
li
ngi sthef i
eldof"Model
li
ngand
Simulati
on",
general
lyr ef
erredt oas" M&S".M&Shasaspect r
um ofappli
cati
ons
whichrangef rom
concept dev elopment and anal ysi
s, t hr
ough experimentat
ion,
measurementand
veri
fi
cati
on,t o di sposalanal
ysi
s.Project
s and progr
ams may use
hundredsofdi ff
erent
simulat
ions,simul ator
sandmodelanaly
sistool
s

3.6Model li
ngPr ocedur eorpr ocess
Inmodel lingweconst ructasui t
abl erepr esent ati
onofani denti
fiedr eal
wor ldpr oblem,
obt ainsol uti
on(s)f ort hatr epresent ationandi nterpreteachsol utionin
termsoft her eal
situat i
on.Thest epsinv olvedi nmodel li
ngar easf ollows:
1.Exami net hereal wor ldsi t
uat i
on.
2.Ext r
actt heessent ialfeaturesf rom t her eal worldsi t
uation.
3.Const ructamodeloft her eal( obj ectorsy st
em)usi ngj ustt heessent
ial
feat uresi dent i
fi
ed.
4.Sol veandexper i
mentwi ththemodel .
5.Dr awconcl usionsaboutt hemodel .
6.I faf urtherr efi
nementnecessar y,t henr e-exami net hemodeland
readj ust
Par amet er sandcont inueat4, ot herwisecont inueat7.
7.Pr oceedwi thimpl ement ati
on.
Expl anat ionoft heSt eps
Begi nwi tht her ealwor ldsi t
uation,whi chi st obei nvestigatedwi t
ha
viewt osol vi
ng
somepr oblem ori mpr ov i
ngt hatsi t
uat ion.
Thef i
rsti mpor t
antst epi st oext ractf rom t her ealwor ldsi t
uationt he
essent ialfeaturesto
bei ncl udedi nthemodel .I ncludeonl yf actorst hatmaket hemodela
meani ngf ul
repr esent at i
onofr eality,whi l
enotcr eat i
ngamodel , whichi sdif
ficultby
i
ncl udi ngmany
variabl es t hatdo nothav e much ef fect.Fact orst o be consi dered

6
i
ncl udeonesov erwhi ch
managementhascont roland ext ernalf act orsbey ond management
cont r ol.Fort hef actors
i
ncl uded, assumpt ionshav et obemadeaboutt heirbehav ior.
Run( simul ate)t hemodelandmeasur ewhathappens.Forexampl e,i
f
wehav esi mul at i
on
ofaqueui ngsi tuationwher et woser versar eempl oy ed, wecanr unt hi
s
forhundr edsof
cust omer spassi ngt hrought hesy stem andobt ainr esul tssuchast he
aver agel engt hoft he
queueandt heav eragewai tingt i
mepercust omer .Wecant henr unit
witht hr eeser vers,
say , andseewhatnewv al
uesar eobt ainedf ort hesepar ameter s.Many
suchr unscanbe
carr i
edoutmaki ngdi fferentchangest ot hest r
uctureandassumpt ions
oft hemodel .
Int he case ofa mat hemat i
calmodelwe hav et o sol ve a setof
equat ionsofsomesor t,e.g.
l
inear pr ogr ammi ng pr oblem wher e we hav et o sol ve a setof
const rai nt sassi mul t
aneous
equat ions,ori n stockcont rol– wher e we hav et o use pr ev i
ously
accumul at eddat at o
predi ctt hef uturev alueofapar ti
cul arvar i
able.
When wehav esol ved ourmat hemat icalmodelorev al
uated some
simul at i
onr uns,wecannow dr aw someconcl usionsaboutt hemodel .
Forexampl e,ifwehav et heav eragequeuel engthandt heav erage
wai tingt imef oraqueui ngsi t
uationv ariedi nsomeway s,wecanuse
thisi nconj unct i
onwi thi nformat i
ononsuchmat tersast hewage- rates
forser v er sandv alueoft i
mel osti nt hequeuet oar ri
v eatdeci sionson
thebestwayt oser vicet hequeue.
Final ly,we use ourconcl usi ons aboutt he modelt o draw some
concl usi onsaboutt he
originalr ealwor l
dsi tuat i
on.Thev al i
dit
yoft heconcl usi onswi lldepend
onhowwel l our
model act ual lyrepresent edt her eal wor l
dsi t
uat ion.
Usual lyt hef ir
stat temptatmodel ingt hesi tuat i
onwi llalmostcer tainl
y
l
eadt or esul tsat
variancewi thr eality.Wehav et ol ookbackatt heassumpt i
onsi nt he
model andadj ust
them.Themodelmustber ebuiltandnew r esultsobt ained.Usual ly,a
l
ar genumberof
i
ter at i
onsoft hisf or m wi llber equi r
ed bef oreaccept ablemodeli s
obt ained.Whenan
accept abl e modelhas been obt ained,i ti s necessar yt ot estt he
sensi ti
v ityoft hatmodel to

7
possiblechangesi ncondition.
Themodel li
ng pr ocesscan t hen beconsi dered f
ori mpl
ementat i
on
wheni tisdecidedt hat
themodeli spresent i
ngt her ealwor ld(objectorsystem)suffi
cientl
y
wellforconclusions
drawnf rom i
ttobeausef ul guidet oacti
on.
Themodelcanbesol vedbyhand, especial
lyifi
tissimple.I
tcoul
dt ake
ti
met oar r
iveat
anaccept ablemodel .Forcompl exmodel sormodel swhi chinv ol
ve
tremendousamount
ofdata,thecomput erisveryusef ul.

RANDOM NUMBERS
1INTRODUCTI ON
TheuseofRandom number sliesatthefoundati
onofmodelingand
si
mul
ati
ons.
Computerappli
cati
onssuchassi mul
ati
ons,games,gr
aphi
cs,
etc.,
oft
en
needtheabil
it
yto
gener
aterandom numbersforsuchappl
icat
ion.

8
Thequal i
tyofarandom numbergener at
ori
sproport
ionalt
oit
sper i
od,
ort henumberof
random number sitcanpr oducebeforearepeati
ngpatter
nsetsin.In
l
ar ge-scale
simul ati
ons,dif
ferentalgori
thms (call
ed shi
ft
-r
egi
sterand lagged-
Fibonacci)canbeused,
althought hesealsohav esomedr awbacks,combiningtwodiff
erent
typesofgener at
ors
maypr oducethebestresul
ts.

3.0HOW TOGENERATERANDOM NUMBERS


Random Numbercanbedef inedasnumber st hatshow noconsi stent
pattern, witheach
numberi naser i
esandar enei t
heraf fectedinanywaybyt hepr ecedi ng
number ,nor
predictabl ef rom it.
Onewayt ogetr andom di git
si stosi mpl ystartwi thanarbi t
rarynumber
wi t
haspeci fi
ed
numberofdi gits,forexampl e4di gits.Thef irstnumberi scal ledt he
seed.Theseedi s
mul ti
pliedbyaconst antnumberoft hesamenumberofdi gits(
lengt h),
andt hedesi red
numberofdi gitsist akenof ft her ightendoft hepr oduct.Ther esult
becomest henew
seed.I ti sagai nmul tipli
edbyt heor iginalconst antt ogener ateanew
product , andt he
processi sr epeatedasof tenasdesi red.Ther esul tisaser iesofdi gits
thatappearr andoml ydistri
butedast houghgener atedbyt hrowingadi e
orspi nni ngawheel .Thi st ypeofal gor i
thm i scal l
edacongr uent i
al
gener ator .
Gener atingar andom numberser iesf r om asi ngl eseedwor ksfinewi t
h
mostsi mul ations
that r ely upon gener ati
ng r andom ev ents under t he cont rolof
probabi li
t i
es( Mont eCar l
o
simulat i
ons) .Howev er,althought hesequenceofnumber sgener ated
from agi venseedi s
randoml ydi stri
buted,itisal way st hesameser iesofnumber sf ort he
sameseed.Thus, a
comput erpokergamet hatsi mpl yusedagi v enseedwoul dal way s
gener atet hesame
handsf oreachpl ayer.
Whati sneededi sal argecollecti
onofpot entialseedsf rom whi chone
canbemor eorl essr andoml ychosen.I fther ear eenoughpossi ble
seeds,t heoddsofev erget t
ingt hesameser iesofnumber sbecome
diminishi ngl ysmal l.

9
Onewayt odot hisist or eadt heti
me( andper hapsdat e)fr
om t he
comput er’
ssy stem
clockandgener at easeedbasedont hatval
ue.Sincet heclockvalueis
i
nmi ll
iseconds,
therear emi ll
i
onsofpossi blevaluest
ochoosef r
om.Anot hercommon
techniquei stouse
theinter valbet weent heuser ’skeyst
rokes(i
nmi lli
seconds).Alt
hough
theyar enotper fect,theset echni
quesarequit
eadequat eforgames.
Theso- cal l
edt ruer andom numbergener at
orsext
r actrandom number s
from phy sical
phenomenasuchasar adioactiv
esourceorevenat mospher i
cnoiseas
detectedbyar adior eceiver.

3.1Pseudor andom NumberGener at i


on
Inthi ssect ionwel ookathow r andom number smaybegener at
edby
humanbei ngsf or
usei nsi mul atingasy stem orbycomput erf orusewhi lesi
mul ati
ngan
event .
Whatweusual lydoi st ot akef ori nstancet enpi ecesofpaper sand
numbert hem
0,1,
2, 3,
4,5,6,7,
8, and9, foldandpl acet hem i nabox.Shaket heboxand
thoroughl ymi x
thesl i
psofpaper .Sel ectasl ip;thenr ecor dt henumbert hati soni t
.
Repl acet heslipand
repeatt hispr ocedur eov erandov er.Ther esul tantrecordofdi git
sisa
reali
zedsequence
ofr andom number s.Assumi ngy out hor oughl ymi xt heslipsbef ore
everydr aw, t
hent h
digitoft hesequencehasanequaloruni f orm chanceofbei nganyof
thedi gits
0,1,2,3,4,
5,6,7,8, 9i r
respect iveofal lthepr ecedi ngdi git
si nt
her ecorded
sequence.
Insomesi mul ations, weuser andom number sthatar ebetween0and1.
Forexampl e,i
f
youneedsuchnumber swi thfourdeci maldi gits,theny oucant akefour
atat i
mef rom t her ecor dedsequenceofr andom di git
s,andpl acea
decimalpoi nti nf rontofeach gr oup off our.To i ll
ust
rate,ift he
sequenceofdi gi tsis358083429261…t hent hef ourdecimal
placedr andom number sar e.3580, .8342, and. 9261.

3.
2Random Number
sinComput
er
Howdoescomput
ergener
ateasequenceofr
andom number
s?
Onewayi st operfor
mt heabove“sl
ip-
in-
a-box”exper
imentandt
hen
stor
etherecorded
sequencei
nacomput er-
backi
ngstor
e.

10
TheRANDCor por ationusi ngspeci al
lydesi gnedel ectronicequi pment ,
toper formt he
ex per i
ment , act uallydi dgener ateat ableofami ll
i
onr andom di gi
ts.The
tablecanbe
obt ainedont ape,sot hatbl ocksoft henumber scanber eadi ntothe
memor yofahi ghspeedcomput er,ast heyar eneeded.Thei rapproach
i
sdi sadv antageoussi nceconsi derablecomput ertimewasexpendedi n
thedel ay sofr eadi ngnumber sint omemor yfrom at apedr i
ve.
Exper tsi ncomput ersci encehav edev isedmat hemat i
calpr ocessesf or
gener atingdi gits
thaty ieldsequencessat isfyi
ngmanyoft hest at
isti
calpr oper ti
esofa
trulyr andom
process.To i llustrate,ify ou exami ne a l ong sequence ofdi gi
ts
producedbydet ermi ni
stic
formul as,eachdi gitwi lloccurwi t
hnear lyt hesamef requency ,odd
number swi llbe
followedbyev ennumber saboutasof tenasbyoddnumber s,dif
fer
ent
pai r
sofnumber s
occurwi thnear lythesamef requency ,et c.Sincesuchapr ocessi snot
reallyr andom, itis
cal l
edpseudo- random numbergener ator .
Theot herway sofgener atingpseudo- r
andom number sar e:
1.Comput ersi mul ation languages and i ndeed some pr ogrammi ng
l
anguages such as BASI C hav e bui lt-
in pseudo- random number
gener ator s.Incomput ersimul ationsituat i
onswher ethisf acili
tyisnot
av ailablei nt hel anguagey ouar eusi ng,y ouwi ll
hav et owr itey ouownpseudo- random numbergener ator( seehow t o
dot hislat er).
2.Ther esul tsofexper i
ment ssuchast heonepr ev i
ousl ydescr i
be
abov ear epubl ishedi n
booksofst atist i
calt ables.Inhandsi mul ati
on,i tmaybeappr opri
ateto
useapubl i
shed
tableofr andom number s.
3.The conv ent ionalsi x-sided unbi ased di e may al so be used t o
gener ateasequenceof
random di gitsi nt heset( 1,2,3,4,5,6)wher eeach di gi
thasa
probabi li
ty1/ 6of
occur rence.

3.3UsingtheRNDFuncti
oninBASIC
TheBASI Cprogr
amminglanguagehasanumeri
cfunct
ionnamedRND,
whichgenerat
es
random numbersbetween0 and 1.EachtimeRND i sexecut
ed,a
pseudorandom number
between0and1i sgenerated.Usi
ngRND funct
ionatanytimewil
l

11
alway
sgeneratethe
samesequenceofpseudor
andom number
sunl
esswev
aryt
her
andom
numberseedusing
theBASI
Cstatement:

RANDOMI ZE
Thisway ,wecancont rolt hesequenceofr andom number sgenerated.
RANDOMI ZEwi l
l
resulttot hef ollowingpr omptont heVDU:
Random NumberSeed( -32768t o32767) ?
Supposey ourr esponset ot heabov eprompti s100.Thent hecomput er
woul duset his
number ,100,t o gener atet he f i
rstr andom number .Thi s number
gener atedi susedt o
gener atet henextr andom number .Thusbyspeci f
yingtheseedf ort he
fi
rstr andom
number ,wear ei nawaycont rolli
ngal lrandom number sthatwillbe
gener atedunt i
l t
he
seedi sreset .Acont rolsuchast hiscanbev eryusefulinvali
dati
nga
simul ati
onpr ogr am
orot hercomput erpr ogr amst hatuser andom number s.
Consi dert hef ollowingBASI Cpr ogram:
FORK%=1TO5
PRINTRND
NEXTK%
END
Iftheabov epr ogram i sr un,somesev en-digitdeci
malnumber sli
ket he
foll
owi ngwi llbe
displayed:. 6291626,. 1948297,. 6305799,. 8625749,. 736353.The
particulardigits
displayeddependont hesy st em t i
me.
Everyt imey our unt heabov epr ogram,di f
ferentsequenceofnumber s
willbedi splay ed.
NowaddaRANDOMI ZEst at ementt othepr ogr am:
RANDOMI ZETI MER
FORK%=1TO5
PRINTRND
NEXTK%
END
Ifyour unt hispr ogram wi t h300asar esponset ot hepromptf ort he
random numberseed,
thef oll
owi ngmaybedi splay ed: .1851404, .
9877729, .806621,.
8573399,
.6208935

3.
4Si
mul
ati
ngRandomness

12
Supposewewantt osi mul atet het hrowingofaf airdie.A r andom
numberbet ween0and
1wi llnotal way ssat isf yourneeds.I fthedi eisfair
,t hrowingitsev eral
ti
meswi llyielda
seriesofuni f
or mlydi stributedi nteger s1,2,3,4,5and6.Consequent lywe
needt obeabl e
togener atear andom i ntegerwi thv al
uesi nt herange1and6i nclusive.
Now t hef unct ionRNDgener atesar andom numberbet ween0and1.
Speci fical l
y, t
he
random v ariableXi sint her ange: 0<X<1
Theexpr essi onX=RND* 6
Willgener ateanumberi nt her ange: 0<X<6
Wemustconv ertt hesenumber st oi nteger sasf ollows:X% =I NT
(RND* 6)
Theexpr essi onpr oducesani ntegeri nther ange: 0<X<5
Butweneedt her ange: 0<X<6
Ther efor ei fweneedt oadd1t ot heabov eexpr essi
oni nsimulatingthe
tossingofadi e.
Thus, X%=I NT( RND* 6)+1
Ingener al,togener at ear andom i ntegerbet weenPandNweuset he
expr essi on:
INT( RND* N+1- P)+P;
Wher eN>P
Whi lef ori ntegernumberbet ween0andN–1weuset heexpressi on
INT( RND* N) .
Exampl e1
Asi mpl eQBASI Cpr ogr am t hatwi l
lstimul atethet ossi ngoft wodi ce
anddi spl ayt he
valueobt ainedaf tereacht oss,andt het otalv al
ueoft hediceisshown
below.
CLS
REM DIandD2r epresentt hei ndiv idualdice.
RANDOMI ZE
DO
D1%=I NT( RND* 6)+1
D2%=I NT( RND* 6)+1
TOTAL%=D1%+D2%
PRINT“ Di e1: ”
; D1%; “Di e2: ”;D2%
PRINT: PRI NT
INPUT“ TossAgai n( Y/ N) ?
” ,Y$
LOOPUNTI LUCASE$( Y$)=“ N”
END

Example2
AnotherQBASI
Cpr
ogr
am t
osi
mul
atet
het
ossi
ngofaf
aircoi
n10t
imes.

13
Theprogram
Displ
aysaHwhenaheadappear sandaTwhenat
ail
appear
s.
CLS
REM Program t
osimulat
ethetossi
ngofacoi
n10t
imes
REM andpr i
ntt
heoutcome
RANDOMI ZETIMER
FORK%=1TO10
RANDNO=RND
I
FRANDNO<=0. 5PRINT“H”
I
FRANDNO>0. 5PRINT“T”
NEXTK%
END

Exampl e3
Supposet heout putofthepr ogram ofexampl e3is: HHTHHTTTHH
andt hatther ear et woplayersXandYi nvolvedinthetossi
ngofthecoin.
Givent hat
playerXwi nsN50. 00from pl ayerYi faheadappear sandlosesitto
playerYi fat ail
appear s.Det ermi newhowont hegameandbyhowmuch.
Solution
From t heout putt hereare6headsand4t ail
s.
PlayerXwi nsN50. 00x6=N300. 00f r
om pl ayerY.
Hel osesN50. 00x4=N200. 00topl ayerY.
Thus, playerXwont hegamewi t
hN300. 00–N200. 00=N100.00.
3.5Pr opertiesofaGoodRandom NumberGener ator
Ther andom number sgeneratedshoul d;
a.hav easnear l
yaspossi bleauni form dist
ributi
on.
b.shoul dbef ast.
c.notr equirel argeamount sofmemor y.
d.hav eal ongper iod.
e.beabl etogener ateadiff
erentsetofr andom number soraseriesof
number s.
f.notdegener ate.

14

You might also like