Sie sind auf Seite 1von 5

24/4/2016

Yasai

YetAnotherSimulationAddIn

Home

Downloads

UserGuide

VersionHistory

Examples

Version2.1UserGuide
(Clickhereforolder,Version2.0UserGuide)

JonathanEckstein,StevenRiedmueller,andShaneReed
March2010
AboutYasai
TheYASAI.XLAaddinisintendedisintendedforteachingelementaryMonteCarlosimulation.Itdoesnotprovidethefullfunctionalityof
@Risk,CrystalBall,andothercommercialproducts,butshouldbesufficientforelementaryinstruction.AkeyadvantageisthatYASAI.XLA
consistsofasingledownloadablefilethatcanberunonanyPCwitharecentversionofExcel,withoutrequiringadministratorprivilegesor
aspecialinstallationprocedure.Itisalsodesignedtobeverystraightforwardtouse.Inexchangeforthissimplicity,YASAImayrun
simulationsslowerthancommercialproducts,sincealltherandomnumbergenerationcodeisinterpretedinVisualBasic.

InstallingYasai
Weencounteredproblemswiththeautomatedinstallationprocedureprovidedwithsomeearlierversionsitisnolongerrecommended.
Manualinstallationisnotdifficult.
Beforestartingtheinstallationprocess,downloadtheYASAI.XLAfilefromtheYASAIwebsite.Donotopenthefiledirectlysimplysaveit
somewhereconvenientonthesystemonwhichyouwishtorunYASAI.
ManualInstallationforExcel2003
First,youmustdownloadthefileYASAI.XLAfromtheYASAIdownloadpage,andifnecessarymoveittothesystemonwhichyouwishto
installYASAI.
1.CheckforanddisableanyoldversionofYASAI:LaunchExcel.Select"AddIns..."fromtheToolsmenu.Scrolltothebottom,andif
"YASAI"appears,uncheckit.Thenclickthe"OK"button.
2.ConfigureExcelsecurity:InExcel,select"Macros>Security..."fromthe"Tools"menu.Select"Medium"security,thenswitchtothe
"TrustedSources"paneandmakesure"Trustallinstalledaddinsandtemplates"ischecked.ClickOK.
3.InstalltheYASAIaddin:Select"AddIns..."fromtheToolsmenu.Click"Browse...",locatethefileYASAI.XLA,andclick"Open".If
Excelasksifitcancopythefile,click"Yes".IfExcelasksifitcanoverwriteanotherfileofthesamename,click"Yes".(Theexact
questionsExcelasksdependvariousfactors,includingwhichversionofExcelyouhave.)
IfYASAIisinstalled,"YASAISimulation..."and"YASAICharts..."shouldappearonExcel's"Tools"menu.
ManualInstallationforExcel2007
First,youmustdownloadthefileYASAI.XLAfromtheYASAIdownloadpage,andifnecessarymoveittothesystemonwhichyouwishto
installYASAI.
1.MovetheYASAI.XLAfiletosomelocationwhereyouwillnotinadvertentlydeleteit(thatis,ifyoudownloadedittoyourdesktoporto
the"Temp"or"Downloads"folder,youmaywanttoputitsomewheresaferunlikeExcel2003,Excel2007,doesnotcopyaddin
filesforsafekeeping.)
2.LaunchExcel.ClicktheOfficeiconinthetopleftcorneroftheExcelwindow.
3.Clickthe"ExcelOptions"buttonatthebottomoftheresultingsubwindow.
4.Click"TrustCenter"intheleftpaneoftheresultingdialogbox.
5.Click"TrustCenterSettings..."ontherightsideoftheresultingdialogbox.
6.Click"MacroSettings"ontheleftpane.
7.Makesure"TrustaccesstotheVBAprojectobjectmodel"ischecked.Intheupperradioboxes,selecteither"disablemacroswith
notification"or"enableallmacros".
8.Click"OK"
http://www.yasai.rutgers.edu/yasai-guide-21.html

1/5

24/4/2016

Yasai

9.Click"AddIns"intheleftpane.
10.Makesurethepulldownmenuatthebottomleftissetto"ExcelAddins"andclick"Go..."justtotherightofit.
11.IfYASAIalreadyappearsontheresultinglist,uncheckit(itshouldonlyappearifyouinstalledanearlierversionofYASAI)
12.Clickthe"Browse"intheresultingdialogbox,locatetheYASAI.XLAfileyousaved),selectit,andclick"OK".
YASAIshouldnowbeloaded.Anew"AddIns"paneshouldappearintheribboninterface.Ifyouclickit,thebuttons"YASAI"should
appear.Ifyouclickit,twooptionsshouldappear,"Simulation..."and"Charts...".Thesechoicesshouldbringupthesimulationand
chartingdialogboxes,respectively.
InExcel2007,simulationsrunsignificantlyslowerthantheydidinExcel2003.ThisappearstobeaninternalExcelissueforwhichnofix
isreadilyavailable.Onrecent,fasterprocessors,performancestillappearsacceptable.

YASAIFunctionsforGeneratingRandomVariables
YASAIprovidesExcelfunctionsthatreturnrandomnumberswithspecifieddistributions.Theywillgenerallyreturnadifferentvalueeach
timetheyarecalled,dependingontheirarguments.Herearethefunctionsthatarecurrentlyimplemented:
GENUNIFORM(a,b):Bothargumentsarenumbers.Normally,itisexpectedthata<b.Ifso,arandomnumberuniformlydistributedover
theinterval[a,b)thatis,xsuchthata<x<bisreturned.Ifa=b,thenthevaluea(orequivalentlyb)isreturned.Ifa>b,anerror
valueisreturned.
GENNORMAL(m,s):Bothargumentsarenumbers.Ifs<0,anerrorvalueisreturned.Ifsiszero,thereturnvalueism.Otherwise,a
randomvaluewithanormaldistributionwithmeanmandstandarddeviationsisreturned.
GENBINOMIAL(n,p):Thefirstargumentnmustbeanonnegativeinteger,andthesecondargumentpmustbeanumberintherange[0,
1].Otherwise,anerrorvalueisreturned.Iftheseconditionsaremet,thenthereturnvalueisanintegerdrawnrandomlyfromabinomial
distributionwithntrialsandprobabilitypofsuccessateachtrial.Notethatifn=0,thenthereturnvalueis0.Theimplementationis
efficientevenwhennislarge.
GENPOISSON(m):Theargumentmisanonnegativenumber.Anegativeargumentcausesanerrorvaluetobereturned.Azero
argumentcauseszerotobereturned.Otherwise,thereturnvalueisrandomlychosenfromaPoissondistributionwithmeanvaluem.The
implementationisefficientevenwhenmislarge.
GENTABLE(V,P):TheargumentVandPareblocksofcellsorlists(forexample,"{1,3,7}")havingthesamenumberofcells.Essentially,
thefunctionreturnseachvalueinVwiththeprobabilityspecifiedbythecorrespondingelementinP.Ifthetwoargumentshavethesame
numberofcellsbutdifferingnumbersofrowsandcolumns,thecorrespondenceisdeterminedbyscanningfirstacrossthefirstrow,then
acrossthesecondrow,andsoforth.NonnumericentriesinParetreatedasiftheywerezero.Ifthetwoargumentsdonothavethe
samenumberofcells,orifPcontainsanynegativenumbers,orifPcontainsonlyzeroes,anerrorvalueisreturned.IfthevaluesinPdo
notsumto1,theyarerescaledproportionallysothattheydo.Forexample,GENTABLE({1,2,3},{.2,.5,.3})returns1withprobability0.2,2
withprobability0.5,and3withprobability0.3.
GENEXPON(a):Theargumentmustbeapositivenumber,oranerrorvalueisreturned.Ifso,thereturnvalueisrandomlychosenfroman
exponentialdistributionwithmeanvalue1/a.
GENGEOMETRIC(p):Returnsageometricrandomvariableswithaprobabilitypofbeing1.Thisvariableisequaltothenumberoftrials
ofameanpBernoulli(orequivalently,GENBINOMIAL(1,p))variableuntilthevalue1isobtained.Thevalueofpmustbegreaterthan0,
andlessthanorequalto1,oranerrorvalueisreturned.
GENTRIANGULAR(a,b,c):Returnsavaluefromatriangulardistributionwithminimuma,modeb,andmaximumc.Thearguments
mustbenumberswiththepropertya<b<c,oranerrorvalueisreturned.

SpecifyingScenarios
Tospecifydifferenttrialvaluesfordecisionvariables,YASAIprovidesthefunctionPARAMETER(L,k,name).Thefirstargument,L,isa
blockofcellsoralistspecifyingthepossiblereturnvalues.Thenameargumentisacharacterstringdescribingtheparameter,andisused
onlyintheoutputreports.Thekargumentspecifiesthenumberofscenariosbetweenchangesintheparameter.Forexample,acell
containing=PARAMETER({1,2,3},1,"woof")specifiesaparametercalled"woof"thatwillchangeeveryscenario,firsttakingthevalue1,
then2,andthen3.Acellcontaining=PARAMETER({1,8,2.3,2},2,"snort")definesaparametercalled"snort"thattakesthevalue1forthe
firsttwoscenarios,then8forthenexttwo,2.3forthenexttwo,and2forthelasttwo.Theargumentkmakesitpossibletotry
combinationsofvaluesofvariousparameterswithouthavingtowriteeverycombinationoutinalist.

SpecifyingOutput
Tospecifyanoutputofthesimulation,usetheformulaSIMOUTPUT(x,name):Thisfunctionreturnsthevaluex.Duringsimulationruns,
thevaluesofxencounteredaresavedforlateranalysis,asdescribedbelow.Theargumentnameisacharacterstringtodescribethe
outputinthesimulationreports.Forexampleacellcontaining=SIMOUTPUT(A4+B7,"profit")definesanoutputcalled"profit"whosevalue
isA4+B7.

RunningtheSimulation
http://www.yasai.rutgers.edu/yasai-guide-21.html

2/5

24/4/2016

Yasai

Onceyouhavebuiltyourmodel,specifiedscenarios(ifany),andspecifiedoutputs,youcanrunyoursimulation.Todoso,select"YASAI
Simulation"fromtheToolsmenu.Thiswillcauseadialogboxtoappear.

YASAIanalyzesyourspreadsheettodeterminehowmanyscenariosappeartobeneeded.Itplacesthisnumberinthedefaultnumberof
scenariosbox.Ifthisnumberissatisfactory,clickonthe"Default"button.Ifyouwouldlikeadifferentnumberofscenarios,clickonthe
"setto"buttonandenterthenumberofscenariosyouwant.
The"SampleSize"boxisthenumberoftimesYASAIwillrecalculateyourmodelforeachscenario.Itdefaultsto1000,butyoucanenter
anypositivewholenumber.
Optionally,youmayindicateafixedrandomnumberseedtouse,andwhethertheseedshouldberesetforeachscenario(resettingis
goodpractice,andisthedefault).Press"Simulate"tostartthesimulation,or"Cancel"toreturntoExcel.
Thesimulationinvolvesonlythecurrentsheetofthecurrentworkbook.Ifthenumberofscenarios"isN,andthe"SampleSize"isS,then
YASAIwillrecalculatethecurrentsheetNStimes.TheserecalculationsaredividedintoNblocksofSrecalculations,eachblock
constitutingascenario.Outputdataarecollectedseparatelyforeachscenario,andthevaluesreturnedbyanyPARAMETERfunctionsin
thesheetwillvaryfromscenariotoscenario,asdescribedabove.
A"progress"displayindicateshowquicklythesimulationisprogressing.Whenthesimulationisover,therewillbeashortdelaywhilethe
outputsareprocessed.Theoutputreportisautomaticallyplacedinanewsheetnamed"SimulationOutputn",whichYASAIinsertsintothe
currentworkbook.YASAImakesthisreportthecurrentsheetandthenreturnscontroltoExcel.Foreachoutputscenariocombination,the
reportcontainsthemean,standarddeviation,minimum,maximum,andpercentilesin5%intervals.Currentlytherearenographicsor
otheroutputdata,althoughimprovementsareplannedforlaterversions.

AbortingaSimulation
YoucanabortaYASAIsimulationwhileitisrunningbyclickingonthe"Abort"button,orsimplybypressingtheescapekeyonyour
keyboard.Itmaytakeupto5secondsforthesimulationtoabort.

TestingaModelInteractively
Totestamodelinteractively,simplypresstheF9key.Excelwillperformasinglerecalculation,drawingnewvaluesforalltherandom
variablegenerationfunctions.NewvalueswillalsobegeneratedforeachPARAMETERfunctioncall.

ChartingSimulationOutput
Asofversion2.0,YASAIcanproducechartsofsimulationoutputs.Youmustrunsimulationbeforetryingtoproducecharts.Tomakea
chart,select"YASAICharts..."fromthe"Tools..."menu,whichproducesachartingwindow:

http://www.yasai.rutgers.edu/yasai-guide-21.html

3/5

24/4/2016

Yasai

Youmaychartuptofiveblocksofoutputs,eachcorrespondingtoonerowinthewindow.Thefirstcolumnselectswhichvariablesto
chart.Thesecondandthirdcolumnsallowyoutospecifyarangeofscenariosfortheselectedvariable,forexamplescenarios1through
5agraphforeachscenariointherangewillappearintheoutput.Thelastcolumnselectsthekindofgraphdesiredfortheblockof
variables:"Histogram"isastandardbarchart,and"Cumulativeplot"producesempiricalcumulativedistributions.Youmaymixthetwo
kindsofgraphsonasinglechart.Withthe"automatic"buttonsetunder"ChartRange"YASAIchoosesthehorizontalaxisrangeand
subdivisionstoattempttoproduceanattractivechart."Manual"letsyouspecifyarangefrom"Min"to"Max",with"Buckets"subdivisions.
YASAIchartsareregularExcelcharts.Oncetheyhavebeencreated,youmodifythemtosuityourneeds.Thechartanditsassociate
dataeachbecomeanewworksheetply.Youmaydeletethemiftheyarenolongerneeded.YASAIchartsarealso"static"theyare
basedonthesimulationimmediatelyprecedingtheircreationifyourunanothersimulationofthesamemodel,theywillnotautomatically
update.Youmustrunasimulationagainandmakenewchartsifyouwantyourchartstoreflectachangetoyoursimulationmodel.
DuetointernallimitationsinExcel,cumulativegraphsarenotpossibleforoutputswithmorethan32,760observations.Histogramsare
possibleforanysamplesize.

KnownProblems
UpdatingLinks
WhenyouopenaworkbookcontainingYASAIfunctions,Excel2003maydisplaythemessagethatitcontains"automaticlinkstoanother
workbook",andasksifyouwanttoupdatethelinks.Asofversion1.15,itshouldnotmatterwhatyouanswerhereYASAIshould
automaticallyrepairthelinks.LinkupdatinggenerallyoccurswhenyoumoveaYASAIbasedspreadsheetbetweentwocomputerswhere
YASAIisinstalledindifferentplacesinthefilesystem.
Onsomeinstallations,however,Exceldoesnotseemtogeneratean"openworkbook"event,andlinkupdatingisskipped.Thisproblem
appearsincreasinglyrare.
Iflinkupdatingfails,yourspreadsheetformulasmaycontainweirdstringslike"!'C:DocumentsandSettings\JoeUser\...\YASAI.xla':".Ifyou
deletethesestringsmanuallyorwithExcel's"Replace"function,YASAIshouldstartworkingnormallyagain.
"YASAISimulation..."appearsontheToolsmenuor"YASAI"appearsinthe"Addins"ribbon,buttheallYASAIspreadsheet
functionsevaluateto"#NAME!"
Excel'ssecuritysettingsmaybepreventingYASAIfromrunning.Select"YASAISimulation..."fromtheToolsmenu.Youshouldmodify
Excel'ssecuritysettingstoletYASAIrun.Infact,youmayimmediatelyseeadialogboxaskingifyouwishtoenablemacros.Click"Yes"or
"EnableMacros".TheYASAIdialogboxshouldappear.Click"Cancel".ForeachcellcontainingaYASAIspreadsheetfunction,clickthe
cell,placethecursorattheendoftheformulaintheformulabar,click,andthenhittheenterkey.InExcel2007,youmayseean"Enable
content"buttonbetweentheworksheetgridandtheribbonclickingitshouldenableYASAItorun.
MacintoshExcel
Althoughtherandomvariablegenerationroutineswork,therestofYASAIisinoperableonolderMacintoshsystems.The2008versionof
MacintoshOfficelacksVisualBasic,soYASAIcannotworkatall.
Excel2007
SimulationsrunmuchslowerthaninExcel2003.The"Addins"panethroughwhichyourunsimulationsorcreatenewchartsisonly
visibleifyouareviewingaworksheetplyunfortunately,itisnotvisibleifyouareviewingachart.Thelinkupdatingmessageissuefinally
appearstohaveresolveditselfinExcel2007.
http://www.yasai.rutgers.edu/yasai-guide-21.html

4/5

24/4/2016

Yasai

Disclaimer:SincethisSoftwareisprovidedfreeofcharge,theSoftwareisprovidedonan"ASIS"basis,withoutwarrantyofanykind.Theauthors
assumenoresponsibilitywhatsoeverforitsusebyotherparties,andmakenoguarantees,expressedorimplied,aboutitsquality,reliability,orany
othercharacteristic.

http://www.yasai.rutgers.edu/yasai-guide-21.html

5/5

Das könnte Ihnen auch gefallen