matlab simulation.ppt

183
System Simulation Dr. Dessouky

Upload: mujeeb-abdullah

Post on 03-Oct-2015

13 views

Category:

Documents


0 download

DESCRIPTION

Matlab simulation

TRANSCRIPT

  • System SimulationDr. Dessouky

  • DescriptionSimulation is a very powerful and widely used management science technique for the analysis and study of complex systems.

    Simulation may be defined as a technique that imitates the operation of a real-world system as it evolves over time. This is normally done by developing a simulation model. A simulation model usually takes the form of a set of assumptions about the operation of the system, expressed as mathematical or logical relations between the objects of interest in the system.

    Simulation has its advantages and disadvantages. We will focus our attention on simulation models and the simulation technique.

  • SimulationWhat is simulation:The process of designing a mathematical or logical model of a real-system and then conducting computer-based experiments with the model to describe, explain, and predict the behavior of the real system.

  • SimulationWhere simulation fits inSimulationProgrammingAnalysisModelingProbability & Statistics

  • Basic TerminologyIn most simulation studies, we are concerned with the simulation of some system.Thus, in order to model a system, we must understand the concept of a system.Definition: A system is a collection of entities that act and interact toward the accomplishment of some logical end.Systems generally tend to be dynamic their status changes over time. To describe this status, we use the concept of the state of a system.

  • Example Simulation ModelFord - # of Panels per day (throughput)Emergency Room (beds, doctors, nurses), (minor, moderate, major, critical)TRW Ballistic Missile Survivability against Soviet ThreatParamount Farms PistachioMiami University ParkingHMT Disks ThroughputChristopher Ranch Garlic CapacityPower Integration Semiconductor Capacity, and random machine down times

  • Value of Simulation

    Empirical Method verses mathematical model

    Allow you to calculate the extreme values not just the expected value

  • SimulationWhat is simulation

    Simulation is the actual running of the model system to gain insight into its performance.

  • SimulationWhy use simulation

    Simulation is used to better understand the expected performance of the real system and to test the effectiveness of the system design.

  • SimulationWhy use simulationWithout building themexperimental systemnew conceptsWithout disturbing themcostly experimentationunsafe experimentation.Without destroying themDetermine limits of stress

  • Queuing systemsPerformance measures (output)

    Data requirements (input)

    Uses of model

    Kendalls notation

  • Queuing systemsSystem Performance measures (outputs)Expected number of customers in systemExpected number of customers in queueExpected time in systemExpected time in queueServer utilizationProbability of n customers in systemThroughput

  • Queuing systemsData requirements (Inputs)Interarrival time distributionService time distributionNumber of serversQueue disciplineSystem capacitySize of input populationKendalls notation (M/M/s/FCFS/K/M)

  • Alternative to simulationSimulationAnalytic modelsPhysical experimentationVisit other sites

  • Simulation vs. analytic modelingAdvantage:various performance measuresgreater realismeasier to understandmodel the steady-state as well as the transit behavior.Disadvantage:May not provide you with the optimal solutiontime to construct model will be longer.

  • Simulation vs. PhysicalAdvantage:High SpeedNot disruptiveReplication easyControl variationsGenerally less costlyDisadvantage:RealismValidity

  • Simulation vs. AlternativesVA

  • Representing systemSystem:a collection of mutually interacting objects designed to accomplish a goal (machines repair system) Entities:denotes an element/object within boundary of system (machines, operators, repairman)Entity work being performed on objectResource performing the work

  • Representing systemAttribute:Characteristic or property or an entity (machine ID, Type of breakdown, time that machine went down) Activity:transforms the state of an object usually over some time (repairman service time, machine run time)

  • Representing systemState of the system:Numeric values that contain all the information necessary to describe the system at any time.

    Delays:Processes that take a conditional length of time in the system

  • Representing systemEvents:Change the state of the system(end of service of machine,machine breaks down)

    Queue:it is set, used to model waiting

  • Ex. Elevator systemsEntitiesElevators, peopleSetsPeople waiting at each floorAttributesElevators capacity, speed, destination, current location of each elevatorPeople inter-arrival time at each floor, destination of each people

  • Ex. Elevator systemsState of system:# of people on each elevator# of people in each floorActivitiesLoad/Unloading passengerTravel to next floor (speed and distance)Persons travel to elevator

  • Ex. Elevator systemsDelays:Persons waiting for elevatorEvents:Elevator arrivalEnd unloadingEnd LoadingPerson Arrival

  • Static Simulation vs. Dynamic SimulationThere are two types of simulation models, static and dynamic.Definition: A static simulation model is a representation of a system at a particular point in time.We usually refer to a static simulation as a Monte Carlo simulation.

  • Static Simulation vs. Dynamic SimulationDefinition: A dynamic simulation is a representation of a system as it evolves over time.Within these two classifications, a simulation may be deterministic or stochastic.A deterministic simulation model is one that contains no random variables; a stochastic simulation model contains one or more random variables.

  • Discrete Event vs. Continuous Event SimulationDiscrete event:state of system changes only at discrete points in time(events) ex. Machine repair problem

    ProgrammingLook at system only when events occur; time is advanced from event to event.

  • Discrete Event vs. Continuous Event SimulationContinuous event:state of system changes continuously over timeEx. Level of fluid in tank

    Programming:Advances time in small intervals. Use differential equations to represent flows.

  • An Example of a Discrete-Event SimulationTo simulate a queuing system, we first have to describe it.We assume arrivals are drawn from an infinite calling population.There is unlimited waiting room capacity, and customers will be serve in the order of their arrival (FCFS).Arrivals occur one at a time in a random fashion.All arrivals are eventually served with the distribution of service teams as shown in the book.

  • Service times are also assumed to be random. After service, all customers return to the calling population.For this example, we use the following variables to define the state of the system: (1) the number of customers in the system; (2) the status of the server that is, whether the server is busy or idle; and (3)the time of the next arrival.An event is defined as a situation that causes the state of the system to change instantaneously.

  • All the information about them is maintained in a list called the event list.Time in a simulation is maintained using a variable called the clock time.We begin this simulation with an empty system and arbitrarily assume that our first event, an arrival, takes place at clock time 0.Next we schedule the departure time of the first customer.Departure time = clock time now + generated service time

  • Also, we now schedule the next arrival into the system by randomly generating an interarrival time from the interarrival time distribution and setting the arrival time asArrival time = clock time now + generated interarrival timeBoth these events are their scheduled times are maintained on the event list.This approach of simulation is called the next-event time-advance mechanism, because of the way the clock time is updated. We advance the simulation clock to the time of the most imminent event.

  • As we move from event to event, we carry out the appropriate actions for each event, including any scheduling of future events.The jump to the next event in the next-event mechanism may be a large one or a small one; that is, the jumps in this method are variable in size.We contrast this approach with the fixed-increment time-advance method.With this method, we advance the simulation clock in increments of t time units, where t is some appropriate time unit, usually 1 time unit.

  • For most models, however, the next event mechanism tends to be more efficient computationally.Consequently, we use only the next-event approach for the development of the models for the rest of the chapter.To demonstrate the simulation model, we need to define several variables:TM = clock time of the simulationAT = scheduled time of the next arrival

  • DT = scheduled time of the next departureSS = status of the server (1=busy, 0=idle)WL = length of the waiting lineMX = length (in time units) of a simulation runWe now begin the simulation by initializing all the variables. This simple example illustrates some of the basic concepts in simulation and the way in which simulation can be used to analyze a particular problem.

  • World View The Structure concepts and views under which the simulation is guided for the development of the simulation modelEvent Orientation defines the changes in state that occur at each event time

    Process Orientation describes the process through which the entities in the system flow

    Activity Scanning Orientation describes the activities in which the entities in the system engage

  • Discrete Event SimulationEvent schedulingWrite modules that describe changes in the state of the system at each eventMain program advances timeOne subprogram for each eventGeneral purpose programming language

  • Discrete Event SimulationProcess interactionWrite modules that describe the progress of entities through the systemAs entities move the systems changes stateEntities are held to represent activities and delaysPromodel programming language

  • Event schedulingTime is advanced from event to eventFuture events list ordered list of upcoming eventsAs events are scheduled, they are added to the listAs events occur they are removed from listActivities in event ( one / event type)

  • Event schedulingList is required to keep track of entities in a setStatistics Two typesSample statistics average of some values (W)W = (W1 +W2 + +Wn)/n = Total Wait / # of waitTime average statistics time weighted (L)L = (0(t1) + 1(t2-t1) + 2(t3-t2) + 1(t4-t3)) / t4

  • Activity scanningActivity scanningTime is modeled in fixed time increments to check if activity occurredSmall time increments is inefficient Large time increments may miss activitydescribes the activities in which the entities in the system engage.

  • Process OrientedProcess oriented:Many simulation models include elements which occur in defined patternsThe logic associated with such a system or events can be generalized and defined by a single statementA simulation language could then translate such statement into the appropriate sequence of eventsdescribes the processes through which the entities in the system flow.

  • Process OrientedProcess oriented:These statements, define a sequence of events which are automatically executed by the simulation language as the entities move through the processCreate arrival entities every t time unitsHowever, since we are normally restricted to a set of standardized statement, provided by the simulation language, our model flexibility is not as great as with the event condition

  • Feature provided by a languageConceptual framework(entities, attributes, resource, queues) Maintenance of event listRandom variable generationAnimationDebugging functionOutput analysisInput analysisReport generation

  • Simulation LanguagesOne of the most important aspects of a simulation study is the computer programming.Several special-purpose computer simulation languages have been developed to simplify programming.The best known and most readily available simulation languages, including GPSS, GASP IV and SLAM.Most simulation languages use one of two different modeling approaches or orientations; event scheduling or process interaction.

  • GPSS uses the process-interaction approach.SLAM allows the modeler to use either approach or even a mixture of the two, whichever is the most appropriate for the model being analyzed.Of the general-purpose languages, FORTRAN is the most commonly used in simulation.In fact, several simulation languages, including GASP IV and SLAM, use a FORTRAN base.

  • To use GASP IV we must provide a main program, an initialization routine, and the event routines.For the rest of the program, we use the GASP routines.Because of these prewritten routines, GASP IV provides a great deal of programming flexibility.GPSS, in contrast to GASP, is a highly structured special-purpose language.GPSS does not require writing a program in the usual sense.

  • Building a GPSS model then consist of combining these sets of blocks into a flow diagram so that it represents the path an entity takes as it passes through the system.SLAM was developed by Pritsket and Pegden (1979). It allows us to develop simulation model as network models, discrete-event models, continuous models, or any combination of these.

  • The decision of which language to use is one of the most important that a modeler or an analyst must make in performing a simulation study.The simulation language offer several advantages.The most important of these is that the special-purpose languages provide a natural framework for simulation modeling and most of the features needed in programming a simulation model.

  • The Simulation Modeling StepsWe now discuss the process for a complete simulation study and present a systematic approach of carrying out a simulation.A simulation study normally consists of several distinct stages. (See Figure in the book)However, not all simulation studies consist of all these stages or follow the order stated here.On the other hand, there may even be considerable overlap between some of these stages.

  • Problem/Model FormulationState the objective of the study.Identify the Problem. Determine any underlying causes if possible.Determine the input variables.Controllable Variables.Uncontrollable Variables.Make assumptions / boundaries that were used to simplify the model.Determine Performance measures used to measure the objective. (Output)

  • Data collection/acquisitionDetermine the Data Collection System or Estimates to be used.Observe the systemHistorical or Similar SystemsTheoretical EstimatesEngineering EstimatesOperator EstimatesVendor EstimatesIdentify the data collected.How it was collected.How it was represented in the model.

  • Model Construction or DevelopmentIdentify The Real SystemDetermine Conceptual Model -Activities and EventsDevelop the Logical Model.Identify the Programming Language used.Computer Implementation (Promodel, Arena, Slam Systems).

  • Model Construction or DevelopmentModeling Tips

    Art vs. ScienceOver Simplification vs. Unnecessary DetailStart SimpleAdd stronger assumptions

  • Model Verification and ValidationVerification: Determining whether simulation model works as intended.Verifying the Model.Structure: Walk Through of the ModelDebugger.Trace = print or writing in process calculations.Animation.Model testingAnalytical Model.

  • Model Verification and ValidationVerification.Logical Model. Are events represented correctly?Are mathematical formulas and relationships correct?Are statistical measures formulated correctly?Computer Model/Simulation Model.Does the code contain all aspects of the logical model?Are the statistics and formulas calculated correctly?Does the model contain coding errors?

  • Model Verification and ValidationValidation:Determine whether Simulation of The Model is a credible representation of a Real System. Compare the model with the actual systems by performing statistical tests. T-Test & C.I. Conceptual Model.Does the model contain all relevant elements, events and relationships?Will the model answer the questions of concern?

  • Model Verification and ValidationLogical Model.Does the model contain all events included in the conceptual model?Does the model contain all the relationships of the conceptual model?Computer Model/Simulation Model.Is the computer model a valid representation of the real system?Can the computer model duplicate the performance of the real system?Does the computer model output have credibility with system experts and decision makers?

  • Experimentation and Analysis of ResultsExperimentation The execution of the simulation model to obtain output values

    Analysis of Results The process of analyzing the simulation outputs to draw inferences and make recommendations for problem resolution

  • Implementation and DocumentationThe process of implementing decisions resulting from the simulation and documenting the model and its use.

  • Manual Simulation ExampleGiven the following arrival times for a single server system what will be the average number in the queue, average number in the system, average time in system, average time in queue, the number of completed jobs, number in the queue, number in the system, and server utilization at time 15 if the service time is 3 time units for each entity. 1, 3, 5, 9,13,15,17

  • Data CollectionActivities may be represented asConstantsRandom variablesCollection of dataDesign a data collection formRecord more than single attribute in case you need to use data in a different way.Use several session to get representative dataUse control charts

  • Data CollectionMachineBegin RepairEnd RepairTime Elapsed

  • Data CollectionTesting dataIndependence

    Randomness

    Homogeneity

  • Data CollectionTest of IndependenceHo: Measure A is independent of measure B

    H1: Measure A is not independent of measure B.Inventory and day of week

  • Data CollectionTest of RandomnessHo: f(xi/xj) = f(xi) =IndependentHi: f(xi/xj) f(xi) : Dependent For example, when simulation a production process in which the items can be defective or good, it would be important to know if successive items are randomly distributed with reputation good items followed by some of defective items.

  • Data CollectionTest of HomogeneityTests for whether multiple sets of data can be considered as coming from statistical population are generally referred to as tests of homogeneity distribution free.Ho : G(x) =H(x)H1 : G(x) H(x)Two different workers working on the same machine.

  • Random VariableTwo typesDiscrete

    Continuous

  • Random VariableProbability mass functionDiscrete

    P(X = xi) = p(xi)

    p(xi) = 1

  • Random VariableProbability density functionContinuousf(x) = e x x > 0P(X = a) = 0- f(x) dx = 1P(a < x < b) = ab f(x) dx

  • Random VariableCumulative distribution function (CDF)

    F(X) = P(X

  • Random VariableExpected value

    = E(x) = xi p (xi) = x f(x) dx

  • Random VariableVariance

  • Random VariableStandard deviation

    Sums of R.V.

  • Random Variable

  • Poisson Probability Distribution

    Consider a discrete r.v. which is often useful when dealing with the number of occurrences of an event over a specified interval of time.

    Suppose we want to find the probability distribution of the accidents at the intersection of Rural and Apache during a one week period.

    The R.V. we are interested in is the number of accidents.

  • Poisson Probability Distribution

    i. The Poisson Distribution provides a good model for the probability distribution of the number of rare events that occur in space, time, and volume where ( is the average at which events occur.

    ii. Define: A r.v. is said to have a Poisson distribution if the p.m.f of X isP(x) = f(x) =

    , x = 0,1, where ( is the rate per unit time or per unit area

    iii.

    _1020423081.unknown

    _1058611642.unknown

  • Exponential Distribution

    Previously, we discussed the Poisson random variable, which was the number of events occurring in a given interval. This number was a discrete r.v. and the probabilities associated with it could be described by the Poisson Probability Distribution.

    Not only is the number of events a r.v., but the waiting time between event is also a random variable. This r.v. is a continuous r.v. for it can assume any positive value.

    This r.v. is an exponential r.v. which can be described by the exponential distribution.

  • Exponential Distribution

    i. Pdf:

    where ( = rate at which events occur

    ii. Correspondingly,

    iii. An important application of the exponential distribution is to model the distribution of component lifetime. A reason for its popularity is because of the memory-less property of the Exponential Distribution

    _1020430693.unknown

    _1058611614.unknown

    _1020430508.unknown

  • The Uniform Distribution

    a. The simplest distribution is the one in which a continuous r.v. can assume any value within a interval [a, b]

    i. Def: A continuous r.v. X is said to have a uniform distribution on the interval [a,b] if the probability distribution (pdf) of X is:

    _1020429890.unknown

  • The Uniform Distribution

    The cumulative distribution is

    _1020429990.unknown

  • The Uniform Distribution

    Note:

    An important uniform distribution is that for when a = 0 and b = 1, namely U(0, 1)A U(0,1) r.v. can be used to simulate observation of other random variables of the discrete and continuous type.

  • The Triangular Distribution Continuous Distribution

  • The Triangular Distribution

  • The Triangular Distribution

  • Normal Distribution

    It is a fact that measurements on many random variables will follow a bell-shaped distribution.

    Random variable of this type are closely approximated by a Normal Probability Distribution.

    A continuous r.v. X is said to have a normal distribution if the pdf of X is

    The distribution contains 2 parameters (( and (). These are the expected value and the variance and hence locate the center of the distribution and measure its spread.

    _1020431105.unknown

  • Normal Distribution

    The Standard Normal Distribution

    To compute P(a ( x (b) when X ~ N((, (2), we must evaluate

    Note: None of the standard integration techniques can be used to evaluate this pdf. Instead, for ( = 0, and (2 = 1, the pdf has been evaluated and values have been computed. Using the table, probabilities for any other values of ( and (2 can be determined

    _1020431397.unknown

  • Normal Distribution

    The normal distribution for parameters values ( = 0, and (2 = 1 is called the standard normal distribution. A r.v. that has a standard distribution is called a standard normal random variable (denoted by Z). The pdf of Z is:

    _1020433302.unknown

  • Normal Distribution

    The cumulative distribution of Z is

    Note: The N(0,1) Table returns the cumulative probability up to z or ((z)

    _1020433440.unknown

  • Normal Distribution

    Non-standard Normal Distribution

    The table only provides probabilities for r.v. following the N(0,1) distribution. Thus, when X ~ N((, (2), (i.e. not ( = 0, (2 = 1), probabilities involving X are computed by standardizing the r.v. to N(0,1) scale.

  • Selecting a Distribution Theoretical prior knowledgeRandom arrival => exponential IATSum of large manufactures => Normal CLTCompare histogram with probability mass or probability density

  • Data CollectionLittle variability model as a constant.Variability model as a random variable.Empirical vs. Theoretical, Select a Distribution, Estimate Parameter of distribution, goodness or fit test.

  • X2 goodness of fit testCompare observed versus theoretical densityA collection of data can be as a sample from a specified p.d.fH0: Xis are IID r.v. with density f(x)H1: Xis are not IID r.v. with density f(x)

  • X2 goodness of fit testCritical valueIf H0 is true, TS ~ X2k-1-(# of par estimated), A large T.S.would cause rejection of H0Reject Ho if T.S. > X2 critical

  • X2 goodness of fit testIssues test is an artNumber of intervals > 2 Size of intervals: Ei ~ same > 5Requires relatively large amount of data

  • K-S testCompare observed with theoretical CDFLimited to continuous distribution, known parametersH0: Xi are IID r.v. with CDF F(x)H1: Xi are not IID r.v. with CDF F(x)Test statistic From table

  • K-S testCritical valueA large T.S would cause rejectionCritical value

  • Parameter estimationSet of datax1, x2, xm

    Methods of moments => equate E(X), V(X) to x and S2

  • Parameter estimationMaximum likelihood => find parameter that max the likelihood of obtaining the given sampleProduces efficient and consistent estimatesNot always unbiasedSuperior properties to methods of momentsCommon sense.

  • Statistical Analysis of SimulationsAs previously mentioned, output data from simulation always exhibit random variability, since random variables are input to the simulation model.We must utilize statistical methods to analyze output from simulations.The overall measure of variability is generally stated in the form of a confidence interval at a given level of confidence.Thus, the purpose of the statistical analysis is to estimate this confidence interval.

  • Output analysisNeed multiple observations to estimate variabilityY1, Y2, Y3, . YnEstimate a confidence interval for the measure of performanceEstimate the number of observations required to obtain the desired precision

  • Output analysisWhat is an observation?Is observation a sample statistic or time average statistic?Is this a steady state simulation or terminating simulation?Are the observations independent or correlated?

  • Terminating vs Steady State Simulation Often, the type of model determines which type of output analysis is appropriate for a particular simulation.However, the system or model may not always be the best indicator of which simulation would be the most appropriate.It is quite possible to use the terminating simulation approach for systems more suited to steady-state simulations, and vice versa.

  • Observation vs Time BasedObservation (Sample)Average Time In SystemAverage Time In QueueTime BasedAverage Number in SystemAverage Number in QueueMachine Utilization

  • Terminating simulationSimulation in which the output measure of performance is defined over a specific interval of time with a specific starting condition and a specific ending conditionRetail sales during a business dayProject networkTime to produce a batch of parts in a work cellMilitary Simulations

  • Terminating simulationHas a specified starting and ending condition.Each observation must have the same starting and ending.Observations are obtained by replication. Use a different seed for random number generation.

  • Steady state simulationSimulation in which the output measure of performance is defined over an infinite interval of time independent of the initial state of the system and stopping conditionAverage production from an assembly line of well trained employeesInventory simulation

  • Steady state simulationIndependent of starting and ending condition. Remove initial condition bias Specify warm-up period (transient period) .Set initial condition too steady state.Have a very long run length

  • Steady state simulation1. Individual Yi average of individuals. 2. Replication Yi average of each one. 3. Batch means batch by time, by number.

  • Terminating vs. Steady state simulationTerminatingObservations are obtained by replicationEach observation must reflect the specified starting and ending conditionUse a different seed for each replicationY1, Y2, , Yr => one independent observation per replication

  • Confidence interval for steady state simulationY1, Y2, . YnTrying to estimate a long run performance measure independent of starting and ending conditionsTwo problemsInitial condition biasDependent observations

  • Confidence interval for steady state simulationOutlineRemoving initial condition biasCreating independent observationReplication/ deletionBatch means

  • Confidence interval for replicationLet Y1, Y2, and Y3YR be measures of performance from R independent replication. Independent -> different seed for each run

  • Confidence interval for replicationApproximate due to need for Yi ~ Normal(1-) Confidence Interval => Probability of containing true mean

  • Number of replication neededSuppose we desire a confidence interval

    Based on a preliminary run of R0 replication, we have an estimate of S2 and confidence interval

  • Number of replication neededFind R such that

    If R is large,

  • Test for comparing two means

    H0: (1 (2 = 0H1: (1 (2 ( 0Two approaches:

    Form a (1 () confident on (1 (2 :

    Reject H0 if confident does not contain 0.

    Perform a t test

    Reject if \t\ > tr,(/2

    AssumptionsCase 1: Y1, Y2 YR1 (

    Case 2: Y1, Y2 YR2 (

    Observations are independent

    Observation are normally distributedVariances are unknown/known.

    Variances are equal/unequalObservations are paired/unpaired.

    _1020440442.unknown

    _1020440619.unknown

    _1020440684.unknown

    _1020440298.unknown

  • Test for comparing two means Equal Variance

    1. Assumptions: independent, normal, unknown, unpaired, equal variance.

    2.

    3.

    4.

    5. t-test:

    t-crit =

    6. Note: Many simulations do not have equal variance.

    _1020443151.unknown

    _1020443287.unknown

    _1020443319.unknown

    _1020443164.unknown

    _1020442671.unknown

  • Test for comparing two means

    One sided test

    Need to make hypothesis in advance

    Use t test, adjust critical value

  • Test for comparing two means

    i. Test for normal population with known variance

    1. Assumptions: independent, normal, known variance, unpaired, unequal variance.

    2. 2 populations: X1 ~ N((1, (12) & X2 ~ N((2, (22)

    3. Sample m from X1 & sample n from X2

    4. Want to test whether (1= (2

    5. H0: (1 = (2 H1: (1 ( (2

    6. Test Statistic:

    _1020449279.unknown

  • Test for comparing two means Unequal Variance

    1. Assumptions: independent, normal, unknown variance, unpaired, unequal variance.

    2.

    3.

    _1020443599.unknown

    _1020443611.unknown

    _1020443533.unknown

  • Test for comparing two means

    i. Paired Test

    1. Assumptions: independent, normal, unknown variance, equal # of replications

    2. Case 1: Y1, Y2 YR Case 2: Y1, Y2 YR Different: d1, d2 dR , where di = yi yi

    3. H0: (1 (2 = 0 ( d = 0H1: (1 (2 ( 0 ( d ( 0

    4.

    5.

    _1020444206.unknown

    _1020444311.unknown

    _1020444012.unknown

  • Test for comparing two variances

    F-test for equal variance

    1.

    2. Test statistics = F =

    =

    3. Critical Value =

    4. Example

    F =5.4/2.55 = 2.12

    (= .10, Fcritical = F9,9,. 05 = 3.18, can not reject Ho

    _1020445207.unknown

    _1128944981.unknown

    _1020445089.unknown

  • Common Random NumberThe process of comparing cases with the same set of random numbers creating identical conditionObservationConfident Interval

    Use the paired test

  • Random NumbersGeneration of U(0,1) random number algorithm used by the RND function

    Generation of random variates from various distributions algorithm used by EXPONENTIAL, UNIFORM, and so on (these algorithms use U(0,1) random numbers.

  • Random Number GenerationDesirable propertiesFast and efficientCapable of repeating same sequenceStatistically equivalent to U(0,1)Independent and denseLarge cycle length or periodLow storage requirementsOld method tables

  • Random Number GenerationPseudo random number generatorsA non random sequence of numbers each completely determined by its predecessor, the algorithm, and initially, the seed.

  • Linear Congruential Generator Zi = ( a * Zi-1 + C ) mod m Z0 = seedUi = Zi / m (Random Number)

    If we choose a, C, and m correctly, => then we achieve a maximum period0

  • Linear Congruential Generator Rule For Full Period : C is relatively prime to m. other than 1, hence there is no integer that exactly divides C and mEvery prime factor of M is also a prime factor of A-1If m is exactly dividable by 4, then A-1 must be exactly dividable by 4

  • Linear Congruential Generator A full period does NOT mean always a good random number generator

  • Multiplicative GeneratorsZi = a * Zi-1 mod m Z0 = seed

    Saves an addition, more popular

  • Multiplicative GeneratorsC=0M divides both m and cCondition (a) is violatedNot full periodP = m 1 is largest available period

  • Multiplicative Generators2b is not a good choice for monly possible numbersLet m = 2b - 1

  • Testing a random number generatorTesting the distributionGenerate 1000 or more observationsX2 test or K-S test for U(0, 1)Use 100 intervalsTest for independenceRuns up Tests designed to compare observed and expected distributionE(x) = .5 V(X) = 1/12, where a = 0, b=1

  • Random variate generationAssume a random number generator is available to generate Ui ~ U(0, 1)Goal: Generate Xi from a specified distribution f(x) or p(x) of F(x)Three methodsInverse transformation methodConvolution methodAcceptance\Rejection method

  • Random variate generationApply these methods to the fivedistributions we are using in this classUniformTriangularExponentialNormalPoisson

  • Inverse transformation methodGeneral idea use CDFSelect UiFind corresponding xiThat is xi = F-1(Ui)Advantage of inverse transformation methodOne Ui per xiDisadvantageCDF may not always exist

  • Inverse transformation methodExponential distributionf(x) = e -x x 0F(X) = 1 - e -x x 0Ui = F(Xi) = 1 - e -xi(1- Ui) = e -xiln(1- Ui) = - XiXi = - (1/ ) ln(1- Ui) = - (1/ ) ln(Ui)

  • Inverse transformation methodTriangular distribution

  • Convolution MethodApplicable to situation where the random variable of interest can be expressed as a sum of other random variables that are IID (independent identical distributed) X=Y1+Y2+Y3. +YnIdea: Generate Y1. Yn and add these up to calculate X

  • Convolution MethodNormal distributionFocus: Generating Zi ~ N(0, 1)

    Generating Zi

    Inverse transformation: F(x) does not existAcceptance\Rejection: Not bounded

  • Convolution MethodNormal distribution

  • Acceptance\Rejection MethodApplicable to distribution functions that are hard to integrateIdeaFind a majoring function t(x) where t(x) > f(x)Sample values of x from t(x) call it x*Sample Ui < f(x*) / t(x*), accept x*Simplification for this class we will always use a rectangular majoring function

  • 9.3 Random Numbers and Monte Carol SimulationThe procedure of generating these times from the given probability distributions is known as sampling from probability distributions, or random variate generation, or Monte Carlo sampling.We will discuss several different methods of sampling from discrete distributions.The principle of sampling from discrete distributions is based on the frequency interpretation of probability.

  • In addition to obtaining the right frequencies, the sampling procedure should be independent; that is, each generated service time should be independent of the service times that precede it and follow it.This procedure of segmentation and using a roulette wheel is equivalent to generating integer random numbers between 00 and 99.This follows from the fact that each random number in a sequence has an equal probability of showing up, and each random number is independent of the numbers that precede and follow it.

  • A random number, Ri, is defined as an independent random sample drawn from a continuous uniform distribution whose probability density function (pdf) is given by

  • Random Number GeneratorsSince our interest in random numbers is for use within simulations, we need to be able to generate them on a computer.This is done by using mathematical functions called random number generators.Most random number generators use some form of a congruential relationships. Examples of such generators include linear congruential generator, the multiplicative generator, and the mixed generator.The lineal congruential generator is by far the most widely used.

  • Each random number generated using this methods will be a decimal number between 0 and 1.Random numbers generated using congruential methods are called pseudorandom numbers.Random number generators must have these important characteristics:The routine must be fastThe routine should not require a lot of core storageThe random numbers should be replicable; andThe routine should have a sufficiently long cycle

  • Most programming languages have built-in library functions that provide random (or pseudorandom) numbers directly.

  • Computer Generation of Random NumbersWe now take the method of Monte Carlo sampling a stage further and develop a procedure using random numbers generated on a computer.The idea is to transform the U(0,1) random numbers into integer random numbers between 00 and 99 and then to use these integer random numbers to achieve the segmentation by numbers.We now formalize this procedure and use it to generate random variates for a discrete random variable.

  • The procedure consists of two steps:We develop the cumulative probability distribution (cdf) for the given random variable, andWe use the cdf to allocate the integer random numbers directly to the various values of the random variables.

  • 9.4 An Example of Monte Carlo SimulationThe book uses a Monte Carlo simulation to simulate a news vendor problem.The procedure in this simulation is different from the queuing simulation, in that the present simulation does not evolve over time in the same way.Here, every day is an independent simulation. Such simulations are commonly referred to as Monte Carlo simulations.

  • 9.5 Simulations with Continuous Random VariablesIn many simulations, it is more realistic and practical to use continuous random variables.We present and discuss several procedures for generating random variates from continuous distributions.The basic principle is similar to the discrete case.We first generate U(0,1) random number and then transform it into a random variate from the specified distribution.

  • The selection of a particular algorithm will depend on the distribution from which we want to generate, taking into account such factors as the exactness of the random variables, the computations and storage efficiencies, and the complexity of the algorithm.The two most common used algorithms are the inverse transformation method (ITM) and the acceptance-rejection method (ARM).

  • Inverse Transformation MethodThe inverse transformation method is generally used for distribution whose cumulative distribution function can be obtained in closed form.Examples include the exponential, the uniform, the triangular, and the Weibull distributions.For distributions whose cdf does not exist in closed form, it may be possible to use some numerical method, such as a power-series expansion, within the algorithm to evaluate the cdf.

  • The ITM is relatively easy to describe and execute.It consists of the following steps:Step1: Given the probability density formula f(x) for a random variable X, obtain the cumulative distribution function F(x) as

    Step 2: Generate a random number r.Step 3: Set F(x) = r and solve for x.

  • We consider the distribution given by the function

    A function of this type is called a ramp function.To obtain random variates from the distribution using the inverse transformation method, we first computer the cdf as

  • In Step 2, we generate a random number r. Finally, in Step 3, we set F(x) =r and solve for x.

    Since the service time are defined only for positive values of x, a service time of as the solution for x. This equation is called a random variate generator or a process generator. Thus, to obtain a service time, we first generate a random number and then transform it using the preceding equation.

  • As this example shows, the major advantage of the inverse transformation method is its simplicity and ease of application.

  • Acceptance Rejection MethodThere are several important distributions, including the Erlang (used in queuing models) and the beta (used in PERT), whose cumulative distribution functions do not exist in closed form.For these distributions, we must resort to other methods of generating random variates, one of which is the acceptance rejection method (ARM).This method is generally used for distributions whose domains are defined over finite intervals.

  • Given a distribution whose pdf, f(x), is defined over the interval a x b, the algorithm consists of the following steps:Step 1: Select a constant M such that M is the largest value of f(x) over the interval [a, b].Step 2: Generate two random numbers, r1 and r2.Step 3: Computer x* = a + (b a)r1. (This ensures that each member of [a, b] has an equal chance to be chosen as x*.)Step 4: Evaluate the function f(x) at the point x*. Let this be f(x*).

  • Step 5: If deliver x* as a random variate from the distribution whose pdf is f(x). Otherwise, reject x* and go back to Step 2.Note that the algorithm continues looping back to Step 2 until a random variate is accepted.This may take several iterations. For this reason, the algorithm can be relatively inefficient.The efficiency, however, is highly dependent on the shape of the distribution.

  • There are several ways by which the method can be made more efficient.One of these is to use a function in Step 1 instead of a constant.We now give an intuitive justification of the validity of the ARM.In particular, we want to show that the ARM does generate observations from the given random variable X.

  • Direct and Convolution Methods for the Normal DistributionBoth the inverse transformation method and the acceptance reject method are inappropriate for the normal distribution, because (1) the cdf does not equal in closed form and (2) the distribution is not defined over a finite interval.Other methods such as an algorithm based on convolution techniques, and then a direct transformation algorithm that produces two standard normal variates with mean 0 and variance 1.

  • The Convolution AlgorithmIn the convolution algorithm, we make direct use of the Central Limit Theorem.The Central Limit Theorem states that the sum Y of n independent and identically distributed random variables ( say Y1, Y2,Yn), each with mean and finite variance 2) is approximately normally distributed with mean n and variance n2.If we want to generate a normal variate X with mean and variance 2, we first generate Z using this process generator then transform it using the relation X = + Z. Unique to normal distribution.

  • The Direct MethodThe direct methods for the normal distribution was developed by Box and Muller (1958).Its not as efficient as some of the newer techniques, it is easy to apply and execute. The algorithm generates two U(0,1) random numbers, r1 and r2, and then transforms them into two normal variates, each with mean 0 and variance 1, using the direct transformation.

  • It is easy to transform these standardized normal variates intro normal variates X1 and X2 from the distribution with mean and variance 2, using the equations

  • 9.6 An Example of a Stochastic SimulationCabot Inc. is a large mail order firm in Chicago.Orders arrive into the warehouse via telephones. At present, Cabot maintains 10 operators on-line 24 hours a day.The operators take the orders and feed them directly into a central computer, using terminals.Each operator has one terminal. At present, the company has a total of 11 terminals.That is, if all terminals are working, there will be 1 spare terminal.

  • Cabot managers believe that the terminal system needs evaluation, because the downtime of operators due to broken terminals has been excessive.They feel that the problem can be solved by the purchase of some additional terminals for the spares pool.It has been determined that a new terminal will cost a total of $75 per week.It has also been determined that the cost of terminal downtime, in terms of delays, lost orders, and so on is $1000 per week.

  • Given this information, the Cabot managers would like to determine how many additional terminals they should purchase.This model is a version of the machine repair problem.It is easy to find an analytical solution to the problem using the birth-death processes. However, in analyzing the historical data for the terminals, it has been determined that although the breakdown times can be represented by the exponential distribution, the repair times can be adequately represented only by the exponential distribution.

  • This implies that analytical methods cannot be used and that we must use simulation.To simulate this system, we first require the parameters of both the distributions.The data show that the breakdown rate is exponential and equal to 1 per week per terminal.In other words, the time breakdowns for a terminal is exponential with a mean equal to 1 week.Analysis for the repair times shows that this distribution can be represented by the triangular distribution which has a mean of 0.075 week.

  • The repair stuff on average can repair 13.33 terminals per week.To find the optimal number of terminals, we must balance the cost of the additional terminals against the increased revenues generated as a result of the increase in the number of terminals.In this simulation we increase the number of terminals in the system, n, from the present total of 11 in increments of 1.

  • For this fixed value of n, we then run our simulation model to estimate the net revenue.Net revenue here is defined as the difference between the increase in revenues due to the additional terminals and the cost of these additional terminals.We keep on adding terminals until the net revenue position reaches a peak.To calculate the net revenue, we first computer the average number of on-line terminals, ELn, for a fixed number of terminals in the system, n.

  • Once we have a value of ELn, we can computer the expected weekly downtime costs, given by 1000(10-ELn).Then the increase in revenue as a result of increasing the number of terminals from 11 to n is 1000(ELn EL11). Mathematically, we compute ELn

  • whereT = length of simulationN(t) = number of terminals on-line at time t (0tT)Ai = area of rectangle under N(t) between ei-1 and ei (where ei is the time of the ith event)m = number of events that occur in the interval [0,T]Between time 0 and time e1, the time of the first event, the total on-line time for all the terminals is given by 10ei, since each terminal is on-line for a period of e1 time units.

  • If we now run this simulation over T time units and sum up the areas A1, A2, A3,, we can get an estimate for EL10 by dividing this sum by T. This statistic is called a time-average statistic.We would like to set up the process in such way that it will be possible to collect the statistics to computer the areas A1, A2, A3,. That is, as we move from event to event, we would like to keep track of at least the number of terminals on-line between the events and the time between events.

  • We first define the state of the system as the number of terminals in the repair facility.The only time the state of the system will change is when there is either a breakdown or a completion of a repair. Therefore, there are two events in this simulation: breakdown and completion of repairs.To set up the simulation, our first task is to determine the process generators for both the breakdown and the repair times.

  • We use the ITM to develop the process generators.For the exponential distribution the process generator is simply x = -log rIn case of the repair times, applying the ITM gives us and as the process generators.

  • For each n, we start the simulation in the state where there are no terminals in the repair facility.In this state, all 10 operators are on-line and any remaining terminals are in the spares pool.Our first action is the simulation is to schedule the first series of events, the breakdown times for the terminals presently on-line.Having scheduled these events, we next determine the first event, the first breakdown, by searching through the current event list.

  • We then move the simulation clock to the time of this event and process this breakdown.To process a breakdown, we take two separate series of actionsDetermine whether a spare is available.Determine whether the repair staff is idle.These actions are summarized in the system flow diagram showed in the book in Figure 17.Otherwise, we process a completion of a repair.

  • To process the completion of a repair, we also undertake two series of actions.At the completion of a repair, we have an additional working terminal, so we determine whether the terminal goes directly to an operator or to the spares pool.We check the repair queue to see whether any terminals are waiting to be repaired.We proceed with the simulation by moving from event to event until the termination time T.At this time, we calculate all the relevant measures of performance from the statistical counters.

  • Our key measure is the net revenue for the current value of n.If this revenue is greater than the revenue for a system with n-1 terminals, we increase the value of n by 1 and repeat the simulation with n +1 terminals in the system.Otherwise, the net revenue has reached a peak.The simulation outlined in this example can be used to analyze other policy options that management may have.

  • The simulation model provides a very flexible mechanism for evaluating alternative policies.