Excel Exam Simulation

profileAbdul-M
Module1.IntroductiontoModelingandsimulation.pdf

1

MODULE 1: INTRODUCTION TO SIMULATION

Module outline:

• What is Simulation?

• Simulation Terminology

• Components of a System

• Models in Simulation

• Typical applications

• References

WHAT IS SIMULATION? simulation may be defined as a technique that imitates the operation of a real world

system or processes as it evolves over time. It involves the generation of an artificial

history of the system and observation of that artificial history to obtain information and

draw inferences about the operating characteristics of the real system. Simulation

educates us on how a system operates and how the system might respond to changes. It

enables us to test alternative courses of action to determine their impact on system

performance. Before an alternative is implemented, it must be tested. Although

performing tests with the “real thing” would be ideal. This is seldom practically feasible.

The cost associated with changing/improving a system may be very high both in the

term of capital required to implement the change and losses due to interruption in

production operations and other losses. In most cases experimentation with the

proposed alternative is practically impossible. In addition, as the cost of proposed

changes (alternative solutions) increase, so does the cost of physically experimenting.

As an example, suppose a heavy-duty conveyor is being considered as an alternative to

the existing material handling method (by trucks) for improving productivity and

speeding up the production operations in a factory (seeFigre3). It is obvious that

installing the proposed conveyor on a test basis would probably not be cost effective.

Therefore, experimentation with alternative configurations would be practically

impossible. In stead, experimentation with a representative model of the system would

probably make more sense.

Simulation is a means of experimenting with a detailed model of a real system to

Determine how the system will respond to changes in its environment, structure, and its

underlying assumption [Harrel (1996)]. Management Scientist uses a wide variety of

analytical tools to model, analyze, and solve complex decision problems. These tool

include linear programming, decision analysis, forecasting, Queuing theory and

Alternative 1: Use lift-truck

2

Point A Point B

(Warehouse) (Factory)

Alternative 2: use a conveyor

Point A

(warehouse ) . . . . . . . . Point B

(Factory)

Figure 3. Material handling alternatives

Simulation. Many of these tools often require the user to make some simplifying model

assumptions or they apply only to special types of problems. For instance, linear

programming applies only to well-structured situations that can be modeled with linear

objective function and linear constraints. In addition, we assume that all data are known

with certainty. Most real world problems exhibit significant uncertainty, which

generally is quite difficult to deal with analytically.

For situations in which a problem does not meet the assumptions required by standard

analytical modeling methods, simulation can be a valuable approach to modeling and

solving the problem. A recent survey of management science practitioners show that

simulation and statistical have the highest rate of application over all other analytical

tools. (1). It should be noted that simulation should not be used indiscriminately as a

substitute for sound analytical models. Many situations exist where analytical tools are

the more appropriate. The modelers need to understand the advantages and

disadvantages of different methods and use them appropriately.

SIMULATION TERMINOLOGY

The art and science of simulation uses a unique set of vocabulary of terms which enables

practitioners communicate specific concepts. We must, therefore consider the meaning

of these terms before we can begin studying actual simulation techniques. The following

list contains the key words and concepts that every modeler should know.

System:

A system as defined here is a group of objects that are joined together in some regular

interaction or interdependence for the accomplishment of some purpose. An example is a

production system manufacturing Television units. The machines, components parts, and

workers operate jointly along the assembly line to produce a good quality television set.

Similarly, the physical facilities of a hospital, its nursing staffs, physicians, and

administrative staff would be an example of a health care system. A jet aircraft is an

3

excellent example of a complex system consisting of numerous mechanical, electronic,

chemical and human components. A major corporation, together with its customers and

its suppliers, represent another example of a system containing complex interacting

components

A system is often affected by changes occurring outside of the system. Such changes are

said to happen in the system environment (Gordon 1978). In modeling a system, it is

necessary to determine the boundary between the system and its environment.

Systems can be categorized as Discrete or continuous. A discrete system is one in which

the state variables (see below) change only at a discrete set of points in time. A bank is

an example of a discrete system since the number of customers in the bank (a state

variable), change only when a customer arrives or departs. Figure 1-1 shows how the

number of customers changes only at discrete points in time.

Number of customers 3 -

Waiting in line or Figure 1-1

being served 2 -

1 -

Time

In a continuous system the state variables change continuously over time. An example is

the temperature of a point inside or outside of a steel coil cooling after heat treatment.

Figure 1-2 shows how state variable (temperature) changes over time

Temperature (F)

of a point inside Figure 1-2

a steel coil while

cooling

Time

COMPONENTS OF A SYSTEM

Entity. An object of interest in the system (example: products in an inventory system)

Attribute: A property of an entity (i.e., Weight of the product)

State: The state of a system can be thought of the collection of all variables required to

describe the system at any point in time, with respect to the objective of the

study. The state of the system is determined by assigning a particular value to

each of these variables. In the case of jet aircraft (see above). The state of the

system would be determined by such factors (state variables) as the aircraft’s

Speed, altitude, direction of travel, weather condition, number of passengers

amount of fuel remaining, and operating status. Some of these factors will

remain constant whereas others will vary with time. As a result, the state of the

system can (and often does) change with time. Note that some of these factors

are deterministic, whereas others, like weather conditions, are stochastic.

Event: An instantaneous occurrence that may change the state of the system. In

the

case of the jet aircraft a sudden change in altitude constitutes an event

4

Activity: Time-consuming elements of a system whose starting and ending

coincide with event occurrence.

Decision Variables: Those variables whose values can be specified by the

decision maker at the beginning of a problem, independent of other variables.

The value assigned to a decision variable will normally affect the state of the

system under consideration. We can call state variables as dependent variables

and decision variables as independent variables. For instance, in simulating

average queue length in a service station, the number of pumps is a decision

variable while number of people waiting in line is a state variable. Table 1

of the text list some examples of the simulation terminology.

Cause–and-effect relationships: all systems are governed by certain

relationships that describe the interaction between state variables, decision

variables, and system parameters. These relationships may represent physical

laws, statistical correlations, economic principles, and etc. Mathematically, if

we represent sets of state variables, decision variables, and system parameters

as S, X, and P respectively, for a given system the cause –and-effect

relationship can be expressed as:

 (S, X, C) = 0

MODELS.

A model is used to provide some type of description of an actual system. Models can

range from exact physical mock-ups of the system to abstract mathematical

representations. Models of systems may be classified as being physical, graphical, or

symbolic. Physical models also called iconic models may be to the same scale as the

system itself. Example of this sort is an aircraft cockpit model used for pilot training.

Physical models may also be of smaller scale than the system they represent. An Example

is mock-up of building structures used by architects. Some scaled-down physical models

of three-dimensional systems may be two-dimensional, such as scaled templates used in

plant layout design.

Graphical models may be two or three-dimensional representation of systems. They

may be static, such as drawing on a paper, or dynamic such as animated films and

computer graphics. Graphic representations generally enhance communication and

understanding of the abstract models.

Symbolic (mathematical) models are abstract representation of systems and as such

they do not look like the system they represent. In many applications these models are a

more effective way to represent a system because of their ease of construction and

manipulation.

Mathematical models are used to describe the behavior of an actual system. A

simulation model is a particular type of mathematical model of a system. Such models

are comprised of s set of equations that represent the underlying cause-and-effect

relationships within the system.

Suppose the following variables** are used to determine yearly profit for a production

system

P = Gross yearly profit X = Sales volume (# of units)

5

S = Sales price per unit

F = Total fixed cost per year including taxes

C = Variable cost per unit

Assuming all other factors could be ignored, we can easily develop an expression

------------------------------------------------------------------------------------------------------ ** these are Decision variables or system Parameters

(mathematical model) for the gross profit for the business as follows:

P= (X)[S – C] –F (1)

Equations (1) constitute a mathematical model for the system. The model is used to

evaluate the state of the system as well as the performance of the system. Assigning a

set of values X, S, C, and F, the model will provide us with quantitative measures of

system’s performance and a set of values for the state variables). In addition, by

specifying different set of values for the four variable (assuming the can take random

values) and evaluating the model repeatedly for each case, we can determine how the

system responds to changes in decision variables or system parameters.

For example suppose:

X: May take any value between 200000 and 320000 (random variable)

S: The company may decide to sell the product for any value say $4/unit to $5.5/unit

C: variable cost/unit changes from one period to another from $3.5 to $4.1

T: total fixed cost plus taxes per year is constant or changes between $300K to 380K

Depending on what random o fixed value each variable assumes, the value of P, the

performance measure of the system will change. The profit (P) may take negative or

positive values.

Types of Simulation models

Simulation models may be classified as being static or dynamic. A static simulation

model, sometimes called Monte-Carlo Simulation represents a system at a particular

point in time. Monte-Carlo is basically a sampling experiment whose objective is to

estimate the distribution of an outcome variable. For example, we may be interested in

the distribution of net profit from a business for the coming year when sales volume, and

variable cost per unit are uncertain. Consider the following simple case:

Let: P= Gross yearly profit

X= Sales volume (# of units)

S= Sales price per unit

F= Total fixed cost per year including taxes

C= variable cost per unit

Assuming all other factors could be ignored, we can easily develop an expression

(mathematical model) for the gross profit for the business as follows:

P= (X)[S – C] –F

We could input many different values for these variables, X and C, into the model and

determine the value of gross profit (P) for each combination of inputs. If we do this, we

will have created a distribution of the possible values of the gross profit. The output

values (and the distribution) provide an n indication of the likelihood of what we might

expect. Monte-Carlo simulation is often used to estimate the impact of policy changes

and risk involved in decision-making. See more examples of Monte-Carlo simulation in

Chapter 2

6

Dynamic simulation models represent systems as they change over time. System

simulation Explicitly models sequences of events that happen over time. Therefore,

queuing, inventory, manufacturing problems are addressed with system simulation. As

an example, consider the following simple case. The Dynaco Company produces a

product in a two stages manufacturing system as shown below.

Input M Output

Machine #1 Machine #2

Each machine may break down randomly. A review of the historical records on the time

between breakdowns and repair time for each machine, provide the following

information.

Time Between Breakdowns (TBB) Repair Time (RT)

In hours in minutes

Machine #1 Machine #2 Machine #1 Machine #2

TBB Probability TBB Probability RT Probability RT Probability

5 0.08 5 0.04 10 -20 0.27 10 -20 0.16

10 0.18 10 0.15 20 -30 0.35 20 -30 0.30

15 0.24 15 0.37 30 -40 0.29 30 -40 0.41

20 0.39 20 0.43 40-50 0.06 40 -50 0.11

25 0.08 25 0.01 50- 0.03 50- 0.02

30 0.02 30 0.00

35 0.01

The Company is interested in estimating the Average production volume per week, as

well as the average breakdown cost/week (assume they know repair cost per hour). This

is a dynamic situation since the state of the system could change from one hour to the

next. However the state of the system will change only when the normal operation is

interrupted at discrete points in time because of breakdown of one machine or

simultaneous breakdown of both machines. Therefore, this case must be analyzed using

discrete event (system) simulation. In order to answer these questions, it is necessary to

simulate the operation of the system for n units of time and collect data on units

produced, downtimes, and other desired indexes of operations. In chapter 2 we have

provided a number of examples concerning system simulation.

Simulation models that contain no random variables are classified as deterministic

models. These models have a known set of inputs, which will result in a unique set of

outputs. Deterministic arrival would occur at a shipping/receiving dock if all trucks

arrived at the scheduled arrival time (i.e., one truck every 40 minutes, starting 12:00

noon). A stochastic simulation model has one or more random variables as inputs that

will result in random outputs. Since the outputs are random, they can be considered only

an estimate of the true characteristics of a model. For example, the simulation of a two

stages production system (see above) would involve random times between breakdowns

7

(random occurrence time) and random repair times. Thus, the output measures_ the

average production rate per week, the average breakdown cost per week- must be treated

as statistical estimates of the true values of those measures.

It should be noted that a discrete simulation model is not always used to model a discrete

system, nor is a continuous simulation model is used to model a continuous system. In

addition, simulation models may be mixed, both discrete and continuous. The choice of

whether to use a discrete or continuous (or both) simulation model is a function of the

characteristics of the system and the objectives of the study. Because dividing large

batches into smaller elements can closely approximate many continuous processes,

discrete-event simulation modeling method may be employed for many (but certainly not

all) simulation studies of continuous processes. This course primarily emphasizes

discrete, dynamic, and stochastic simulation models. It only provides limited coverage of

the static, continuous and deterministic simulation models.

TYPICAL APPLICATIONS

The application of simulation is vast. The Winter Simulation Conference (WSC) is an

excellent source o learn more about the latest in Simulation theory and applications.

Information bout upcoming WSC ca be obtained from http://www.wintersim.org. During

the early 1980s, a survey was made of major U.S. firms to learn more about their use of

simulation (Reference #2). One major finding was the identification of the functional

areas of the company where simulation was being applied. The results are shown in

Table 1 below. The survey showed that the development of simulation models has

spread beyond Operations research (or Management Science) departments. Other

functional area departments and corporate planning departments use simulation modeling

extensively. More recent reports indicate that the use of simulation continue to grow

rapidly in manufacturing, corporate planning , and finance areas. Growth in these areas

has been aided by the development of specialized programming languages for each area.

Another important recent development has been the increasing use of computer graphics

to generate animated displays of the movement of entities through the simulated system.

The computer graphics provide greater insight into the performance of the system for any

given design. They also add credibility to the results of the simulation study.

There have been numerous applications of simulation in a variety of contexts. Some of

the areas of application, are listed blow:

Manufacturing and Production

Logistic, Transportation and Distribution

Military Operations

Business Process Simulation

Construction Engineering

Health Care

Human Systems

Financial Planning

………………

For a more detailed list of application areas, see Chapter one in your textbook or visit

WSC site.

8

REFERENCES

1. Banks, J., and J. S. Carson, II, Discrete-Event Simulation, Prentice-Hall, 2001

2. Christy, DS. P., and H. J. Watson, “ The Application of Simulation: A survey of

Industry Practice, ” Interfaces, 13(5): 47-52 October 1983

9

Module 2: Brief Introduction to basics. Probability. Simulation, and Random numbers

10

Module 2: Brief Introduction to basics. Probability. Simulation, and Random numbers

• The concept of theoretical and experimental probability

• Simulation, an example

• Random variables

• Assignments

PART I: The concept of Probability: Probability is the study of chances or the likelihood of an event

happening. Directly or indirectly, it plays a role in all of our activities.

For Example, we may say that, it will probably rain today, because most

of the day in August were rainy. However, in Science we need more

accurate way of measuring probability.

A)-Experimental Probability One way to find the probability of an event is to conduct an experiment.

EXAMPLE

A bag contains 10 red marbles, 8 blue marbles and 2 yellow marbles.

Find the experimental probability of getting a blue marble

SOLUTION

11

1)- Take a marble from the bag.

2)- Record the color and return the marble.

3)- Repeat a few times (maybe 10 times).Example:

Trial # 1 2 3 4 5 6 7 8 9 10

Outcome B R R B B R B R B B

4)- Count the number of times a blue marble was picked (Suppose it is

6). The experimental probability of getting a blue marble from the bag

is 6/10 = 3/5 (Discussion: Is this correct?)

B)-Theoretical Probability We can also find the theoretical probability of an event. The equation

used to determine the theoretical probability of an event is:

Example:

A bag contains 10 red marbles, 8 blue marbles and 2 yellow marbles.

Find the theoretical probability of getting a blue marble.

Solution:

There are 8 blue marbles. Therefore, the number of favorable outcomes

= 8. There are a total of 20 marbles. Therefore, the number of total

outcomes = 20

Example:

Find the probability of rolling an even number when you roll a die

containing

the numbers 1-6. Express the probability as a fraction, decimal, ratio

and percent.

Solution:

The possible even numbers are 2, 4, 6. Number of favorable outcomes

=3.

Total number of outcomes =6

Solution:

The possible even numbers are 2, 4, 6. Number of favorable

outcomes = 3.

12

Total number of outcomes = 6

The probability = (fraction) = 0.5 (decimal) = 1to 2 (ratio) = 50%

PART II: Simulation, An example

Consider the following Experiments

Class Exercise: Repeat this Experiment 12 times. Determine the experimental probability of getting an ace. What is the theoretical

probability of getting an ace 6 . compare the outcome from the two.

A Simple Experiment; Toss a die 12 times. Suppose we get the following data;

Trial# 1 2 3 4 5 6 7 8 9 10 11 12

Outcome 3 5 2 6 1 4 5 3 5 4 2 5

Computer Simulation of this experiment: Use the Excel Spreadsheet and generate the outcomes as follows A B C D E F

1 Trial

#

Outcome

2 1 = randbetween(1,6) =If(B2=1,1,0)

3 2

4 3

5 4

6 5

7 6

8 7

9 8

10 9 copy copy

11 10

12 11

13 12

Experiment 1: Tossing a die Outcome: Result of experiment (what we expect to happen)

Possible outcomes from this Experiment (Exp. #1) are the

numbers 1, 2, 3, 4, 5, and 6

Sample Space: List of all possible outcomes

Sample space, S = {1, 2, 3, 4, 5, 6}.

13

14 Totals

=Sum(C2:C13)

RESULTS: Value in Cell C14 C14 Experimental probability = = Total # of outcomes 12 This is the same as determining % of time we get an ace in tossing a die

12 times.

Theoretical Probability= 6 /(12*6) = 1/6 (Explain why?)

PART III: Random Variables NOTE: In order to fully understand this tutorial, you need to know what we

mean by an experiment, the outcomes of an experiment, and probability. For

a brief refresher, see the Appendix 1 attached to this module

Q)- What is a random variable? A)- In many experiments the outcomes of the experiment can be assigned

numerical values. For instance, if you roll a die, each outcome has a value

from 1 through 6. If you ascertain the midterm test score of a student in your

class, the outcome is again a number. A random variable is just a rule that

assigns a number to each outcome of an experiment. These numbers are

called the values of the random variable. We often use letters like X, Y and Z

to denote a random variable. Here are some examples

Examples

1. Experiment: Select a mutual fund; X = the number of companies in

the fund portfolio. The values of X are 2, 3, 4, …

2. Experiment: Select a soccer player; Y = the number of goals the

player has scored during the season. The values of Y are 0, 1, 2, 3, …

3. Experiment: Survey a group of 10 soccer players; Z = the average

number of goals scored by the players during the season.

The values of Z are 0, 0.1, 0.2, 0.3, …., 1.0, 1.1, …

QUESTIONS #1:

4. Experiment: Flip a coin three times. Let X= Total number of heads

you observed. In this experiment, the possible values X (a random

variable) are:

5. Experiment: Throw two dice; X = the sum of the numbers facing up. The

values of X are:

14

6. Experiment: Throw one die over and over until you get a six; X = the

number of throws.

The values of X are.

Discrete and Continuous Random Variables A discrete random variable can take on only specific, isolated numerical values, like the outcome of

a roll of a die, or the number of dollars in a randomly chosen bank account. Discrete random

variables that can take on only finitely many values (like the outcome of a roll of a die) are called

finite random variables. Discrete random variables that can take on an unlimited number of values

(like the number of stars estimated to be in the universe) are infinite discrete random variables.

A continuous random variable, on the other hand, can take on any values within a continuous range

or an interval, like the temperature in Central Park, or the height of an athlete in centimeters.

Examples

Random Variable Values Type

Flip a coin three times; X = the

total number of heads.

{0, 1, 2, 3} Finite

There are only four possible

values for X.

Select a mutual fund; X = the

number of companies in the

fund portfolio.

{2, 3, 4, …} Discrete Infinite

There is no stated upper limit

to the size of the portfolio.

Measure the length of an object;

X = its length in centimeters.

Any positive real number Continuous

The set of possible

measurements can take on any

positive value.

QUESTIONS #2:

Random Variable Check the Type

Throw two dice over and over until you roll a double six;

X = the number of throws. Finite

Discrete Infinite

Continuous

Take a true-false test with 100 questions;

X = the number of questions you answered correctly. Finite

Discrete Infinite

Continuous

Invest $10,000 in stocks;

X = the value, to the nearest $1, of your investment after a

year.

Finite

Discrete Infinite

Continuous

Select a group of 50 people at random;

X = the exact average height (in m) of the group. Finite

Discrete Infinite

Continuous

Using Excel to generate Random Numbers

15

Excel has two useful functions when it comes to creating random numbers.

The RAND function, and the RANDBERWEEN function .

Rand()

The RAND function creates a random decimal number between 0 and 1.

1. Select cell A1.

2. Type RAND() and press Enter. The RAND function takes no arguments.

3. To create a list of random numbers, select cell A1, click on the lower right

corner of cell A1 and drag it down.

Note that cell A1 has changed. That is because random numbers change

every time a cell on the sheet is calculated.

Randbetween (a, b)

The RANDBETWEEN function returns a random whole number

between two boundaries.

1. Select cell A1.

16

2. Type RANDBETWEEN(50,75) and press Enter.

3. If you want to create random decimal numbers between 50 and 75, modify the RAND function as follows:

Assignment 1:

For each of the following experiments, simulate the situation and

1)- Answer the questions asked, in the sequence listed below.

2)- Attach a copy of your excel worksheet. At the end/bottom of each excel sheet , write

down the (excel)

equation you used to generate each column of data, and your final answers.

3)- Write your name on the answer sheets and make sure what you submit is clean and

readable.

Experiment 1 : Tossing a coin

Simulate Tossing a coin 30 times and answer these questions:

1) -Possible outcomes are: ………………………………………………

2)-Sample space, S = ………………………………………………………

3)- Experimental Probability of getting “Tail” ……………………...........

4)- Theoretical Probability of getting “Tail” ……………………………

Experiment 2: Picking a card.

In this experiment, a card is picked from a stack of six cards, which spell the word

PASCAL. (Each letter is written on one card). Simulate the experiment and answer

the following questions:

1) -Possible outcomes are: ………………………………………………

17

2)-Sample space, S = ………………………………………………………

3)- Experimental Probability of getting “A”…………………………… …

4)- Theoretical Probability of getting “A” ………………………………..

Experiment 3: Suppose the ABC trucking Company delivers raw material to your factory. Each

truck carries about 18 tons of raw material. The time between subsequent arrivals of

trucks is random and changes between 30 to 75 minutes. Let us assume that the first

truck always arrives at 8:00 AM.

1)- Simulate the delivery operation for one day (8 hours /day) and

determine how many tons of raw material is delivered in a day. What

time (clock time) the last truck will arrive?

2)- Repeat the simulation in question 1 (above) 5 times and from the output data,

determine Maximum, Minimum, and average tons of raw material delivered

per day.

3)- From the 5 trials in question 2, determine Average number of trucks (arriving) per

day

APPENDIX MODULE 2

Random variables and probability

This lesson is about random variables and the basic language used to describe

populations and samples from populations.

I. Random Variable:

At the end of Chapter 2 we defined A random variable as follows: A

function that assigns a real number to each outcome in the sample space

of random experiment.

Example: X denotes the outcome of experiment, Tossing a die. Then X

can take (randomly) any of the values 1, 2, 3, 4, 5, and 6.

18

Note: The outcome of an experiment need not be a number, for

example, the outcome when a coin is tossed can be 'heads' or 'tails'.

However, we often want to represent outcomes as numbers. A random

variable is a function that associates a unique numerical value with

every outcome of an experiment. The value of the random variable will

vary from trial to trial as the experiment is repeated. There are two

types of random variable - discrete and continuous

A discrete Random Variable is one which may take on only a countable number of distinct values such as 0, 1, 2, 3, 4, ... Discrete random variables are usually (but not necessarily) counts. Examples of discrete random variables include the number of students in registration office, the Friday night attendance at a cinema, the

number of cars passing a toll both. Continuous random variable is one which takes an infinite number of possible values. Continuous random variables are usually measurements. Examples include height, weight, pressure, the time required to run a mile.

Examples 1. A coin is tossed ten times. The random variable X is the number

of tails that are noted. X can only take the values 0, 1, ..., 10, so X is a discrete random variable.

2. A light bulb is burned until it burns out. The random variable Y is its lifetime in hours. Y can take any positive real value, so Y is a continuous random variable.

Introduction to Probability The study of descriptive statistics was concerned with what has

occurred, probability is concerned with what will occur. Many of the

concepts are the same, although some of the vocabulary changes.

Descriptive statistics is concerned with (relative) frequency in the past,

probability with (relative) frequency in the future.

• Vocabulary

• Axioms

• Where do probabilities come from?

Vocabulary

Experiment:

something which generates an outcome (e.g., pick a card, roll a die,

weigh a student, look outdoors)

Outcome: (also called simple event)

19

result of an experiment (e.g., jack of spades, 3 pips, 145 pounds,

partly cloudy)

Sample space: (denoted by S)

set of all possible outcomes of an experiment (e.g., for picking a card

there are 52 possible outcomes, hence 52 points in the sample space)

Event: a set of outcomes, or equivalently, a subset of the sample

space (e.g., for picking a card, events include getting a spade,

getting a deuce, getting a face card)

Note: Sometimes identifying outcomes is subtle. If you roll a pair of dice, is the total number of pips, the pair of values on the two dice, or the ordered

pair of values on the two dice the outcome?

Axioms Of Probability

A probability space entails that a probability be assigned to each outcome.

• The probability of each outcome [denoted P (xi ), where “xi ” is the

ith outcome] is always between 0 and 1.inclusive

• The probability of an event is the sum of the probabilities of the

outcomes (simple events) in the Event.

• P(S)=1; Something has to happen, the probability of the sample space

is 1.

Where do probabilities come from?

• Probabilities may be given, often in the form of a table. For example,

if an experiment has three possible outcomes: Accept , Reject, or

Compromise, one might be given the following table:

Accept Reject Compromise xi (A) ( R) (C)

P (xi ), 0.35 0.25 0.40

Note: Even if say, the 0.40 entry had been missing, you would

have been able to figure it out, since probabilities sum to 1.

• Probabilities my be historical, if it has rained during 1/3 of the days in

June during the past, one may say that the probability of rain for a day

in June is 1/3.

• Probabilities may be theoretical, if a die is fair (and there is any

justice in the universe), since there are six possible outcomes, the

probability of getting 3 pips on the top face is 1/6.

20

Example: Consider the following (incomplete) table of probabilities

associated with rolling an unfair die:

xi 1 2 3 4 5 6

P (xi ) 0.2 0.1 0.2 ? 0.3 0.1

What is the probability of rolling a 5?

What is the probability of rolling an even number (2 or 4 or 6)?

Expressing Probability

A probability is usually expressed in term of a random variable. For the

die rolling example X denotes the outcome. The probability statement can be

written in either of the forms:

• Pr( x=1) = 0.2,

• Pr( x <3) = P1( x=1) + Pr(x=2) = 0.2 +0.1 =0.3

• Pr(2 ≤ x< 4) = Pr(x=2) + Pr (x=3) = 0.1+0.2 =0.30

• Pr(x ≥ 5) = Pr(x=5) + Pr(x=6) = ).3 +0.1 = 0.4 Also, the following expression may be used for the example:

• Pr(x=0) = 0

• Pr(x>6) = 0 If the set of all possible outcomes is denoted as “s” where the set

s: {1, 2, 3, 4, 5, 6], then we can use the following expressions:

• Pr(x ε s ) = 1 • if “s” is divided into a number of mutually exclusive (non-

intersecting) sun-sets s1, s2, ….sk, Then,

s = s1, + s2, + …. + sk, OR s = s1 U s2 U s3…. +U sk

Pr(x ε s ) = Pr (x ε s1 U s2 U s3…. +U sk )

21

22

Module 3: Monte Carlo Simulation

• Introduction to Monte Carlo Simulation

• Random numbers from some common probability distribution

Module 3: Monte Carlo Simulation

• Introduction to Monte Carlo Simulation

• Random numbers from some common probability distribution

PART 1: Introduction to Monte Carlo simulation Computer simulation has to do with using computer models to imitate real life or make

predictions. When you create a model with a spreadsheet like Excel, you have a certain

number of input parameters and a few equations that use those inputs to give you a set of k

outputs (response variables). Figure 1 depicts such a system X1 Y1 X2 y2 ……… ………. OUTPUT INPUT ……… ………. ……… Yk

A production

System

23

X n

This type of model may be deterministic, meaning that you get the same results no matter

how many times you re-calculate. For example the equation for calculating the future value

“F” of a investment of $X now with an interest rate of r% in “n” years F=P(1+r/100)n is a

deterministic model. However, in most systems, some or all input variables(Xi) are

stochastic resulting in output values (Yi) that change stochastically depending on the input

variables

Monte Carlo simulation is a method for iteratively evaluating a deterministic model using

sets of random numbers as inputs. By using random inputs, you are essentially turning the

deterministic model into a stochastic model. This method is often used when the model is

complex, nonlinear, or involves more than just a couple uncertain parameters. A simulation

can typically involve over 10,000 evaluations of the model, a task which in the past was

only practical using super computers.

Example

we used simple uniform random numbers as the inputs to the model. However, a uniform

distribution is not the only way to represent uncertainty. Before describing the steps of the

general MC simulation in detail, a little word about uncertainty propagation:

The Monte Carlo method is just one of many methods for analyzing uncertainty

propagation, where the goal is to determine how random variation, lack of knowledge, or

error affects the sensitivity, performance, or reliability of the system that is being modeled.

Monte Carlo simulation is categorized as a sampling method because the inputs are

randomly generated from probability distributions to simulate the process of sampling from

an actual population. So, we try to choose a distribution for the inputs that most closely

matches data we already have, or best represents our current state of knowledge. The data

generated from the simulation can be represented as probability distributions (or histograms)

or converted to error bars, reliability predictions, tolerance zones, and confidence intervals.

(See Figure 2).

24

Random (Uncertainty) Inputs

Figure 2: the basic principal of stochastic uncertainty propagation

The steps in Monte Carlo simulation of a system shown in Figure 2 are fairly simple, and

can be easily implemented in Excel for simple models. All we need to do is follow the five

simple steps listed below:

Step 1: Create a parametric model of the system, y = f(x1, x2, ..., x n).

Step 2: Generate a set of random inputs, xi1, xi2, ..., x n. (if Xi is a random variable)

Step 3: Evaluate the model and store the results as yi.

Step 4: Repeat steps 2 and 3 for i = 1 to m.

Step 5: Analyze the results using histograms, summary statistics, confidence intervals, etc

Example 1: Monte Carlo Simulation ABC Bakery company, bakes 2500 Loaf of bread per day. Historical data shows that their

daily demand changes randomly between 1700 and 3300 loaves. Any unsold product (since

it is considered perishable) will be sold for $0.85 each at the end of the day. Each unit of

product cost the bakery $1.25 to $1,5 (depending on the variable cost of raw material). The

selling price per unit varies between $1.8 to $3., depending on the type of customers and

quantity discount policy of the bakery. Simulate the operations for 52 weeks and

determine:

25

1)- Average, Maximum and Minimum profit per week (a week = 6 days, & 52 weeks per

year)

2). Maximum # of unsold units per day

3)- Average profit per year

4)-Is it economically preferred to bake 2700 units per day instead of current practice, baking

2500 units per day?

SOLUTION;

Step 1: Modeling the system.

In order to develop the mathematical model of the system, we introduce the following

notations with their attributes

VARIABLE GIVEN VALUES

IN = Daily units baked 2500 Units

V = Daily sales volume (Units). Random (between 1700 to m3300 )

BC = Cost per unit Random (between $1.25 to $1.5)

RP = Selling price (leftover stock). $.85 per unit

NR= Number not sold (leftover, end day). Random, to be determined

SP= Average Selling Price per unit Random (between $1.8- $3.1)

P= Profit To be determined

Table 1. Information on input /output variables

The Model:

Profit = Revenue – costs

Revenue = V*SP +(2500 -V)*RP if V<2500

= 2500*SP if V≥2500

Cost= 2500* BC

a)-Profit (P) = [V*SP +(2500-V)RP ] – 2500*BC = V*(SP-RP)+2500(RP-BC) ➔ if V < 2500

b)- Profit (P) = 2500*SP -2500*BC = 2500 *(SP-BC) ➔ if V ≥ 2500

Note: all variables colored red are random and their values must be generated)

STEP 2: Generating sets of random inputs

The key to Monte Carlo simulation is generating the set of random inputs. As with any

modeling and prediction method, the "garbage in equals garbage out" principle applies. In

this first example, we are going to avoid the questions "How do I know what distribution to

use for my inputs?" and "How do I make sure I am using a good random number

generator?" and get right to the details of how to implement the method in Excel.

26

For this example, we're going to use a Uniform Distribution to represent the four

uncertain parameters. In Table 1 ( above), uses "Min" and "Max" to indicate the uncertainty

in V, BC, and SP. To generate a random number between "Min" and "Max", we use

the following formula in Excel (using Excel functions for generating random values from

different distribution is briefly explained in the next part of this module)

1)- To generate random values of V, use the function

= RABDBETWEEN(1900,3300)

2)- To generate random values of BC, use the function

= 1.25 + (1.5 -1.25)* RAND()

3)- To generate random values of V, use the function

= 1.8+(3.1 -1.8)*RAND()

Step 3 & 4

The resulting spreadsheet (with 40 iterations) is:

A B C D E F G H

# or Trials U1 U2 V BC SP Leftover Profit

1 0.778753 0.43468 2997 1.444688 2.365084 0 2300.989

2 0.471153 0.636231 3018 1.367788 2.627101 0 3148.281

3 0.271368 0.95276 2185 1.317842 3.038588 315 3612.459

4 0.713508 0.064095 2892 1.428377 1.883323 0 1137.365

5 0.841656 0.739523 2258 1.460414 2.76138 242 2789.86

6 0.989832 0.239861 2644 1.497458 2.11182 0 1535.905

7 0.559288 0.180459 3211 1.389822 2.034597 0 1611.938

8 0.019489 0.059686 3249 1.254872 1.877592 0 1556.8

9 0.896959 0.738236 2226 1.47424 2.759707 274 2690.409

10 0.772848 0.756428 1788 1.443212 2.783357 712 1973.812

11 0.275169 0.302007 2491 1.318792 2.19261 9 2172.46

12 0.133053 0.647142 2688 1.283263 2.641284 0 3395.052

13 0.391422 0.828734 1713 1.347856 2.877354 787 2228.219

14 0.532818 0.606079 2326 1.383204 2.587903 174 2709.351

33 0.847157 0.988055 2419 1.461789 3.084471 81 3875.712

34 0.991692 0.276098 2345 1.497923 2.158928 155 1449.629

35 0.364092 0.055693 3161 1.341023 1.872401 0 1328.444

36 0.558141 0.728121 3152 1.389535 2.746557 0 3392.553

37 0.12574 0.114619 2188 1.281435 1.949005 312 1326.034

38 0.555752 0.883073 2954 1.388938 2.947995 0 3897.642

27

39 0.456048 0.755079 2444 1.364012 2.781602 56 3435.806

40 0.021982 0.101226 2501 1.255496 1.931593 0 1690.245

The spreadsheet columns are generated as follows

Column B and C; use the equation =RAND()

Column D: Used the equation = RANDBETWEEN(1700, 3300)

Column E. Used the equation = 1.25 +U1*(150-1.25)

Column F. Used the equation; =1.8+U2 *(3.1-1.8)

Column G (Leftover). = If(V<2500, (2500-V), 0)

Column H, profit

= IF(G2=0,(2500*(F2-E2)),( D2*(F2-0.85)+2500*(0.85-E2)))

Step 5

Analysis of the results:

Average Profit/day== $2396.786 $14380.71 per week

Max. daily Profit== $4439.648

Min. daily Profit $731.1422

Average profit/tear $747797.1

Maximum Leftover 787 units

The resulting profit from alternative decision, baking 2700 units per day, could be

determined following the same procedure. If the objective of the bakery is to improve profit,

the output from the simulation for the two alternatives will provide the information needed

to select the best alternative.

Example 2 and Assignment

In August, Walton Bookstore must decide how many of next year’s nature calendars

should be ordered. Each calendar costs the bookstore $2.00 and is sold for $4.50. After

January 1, any unsold calendars are returned to the publisher for a refund of $.75 per

calendar. Walton believes that the number of calendars sold by January 1 follows the

probability distribution shown in Table 2. Walton wishes to maximize the expected net

profit from calendar sales. Use simulation to determine how many calendars the bookstore

should order in August.

No. of Calendars sold Probability

100 .30

150 .20

Table 2 – Demand Distribution for Calendars at Walton Bookstore

28

200 .30

250 .15

300 .05

A). Notes/Hints on how to develop simulation model for this case In order to simulate the operations, a first step involve listing, in a sequential order, how the

system works. In this special case, the sequence of operations is:

Sequence of Operations

• We order n units (here called ORQ) of the product. Note that for this type of products the suppliers

usually sell the material in bundles (not one by one). Each bundle may include 20, 30, 50 and so on.

Therefore, if m=50 units/bundle, we can order, one bundle, 2 bundles, 3 bundles or in general n

bundles. That means ORQ can take values 50, 100. 150, and so on. Each unit cost $2.00

• During the week, we sell X units of the product. X is a random variable and we may have some idea

about its Max and Min value. We sell each unit for $4.5

• If we do not sell all the calendars ordered (ORQ units), we can return the unsold units to the

producer/publisher and get $0.75 for each

• We develop a mathematical model for the “Profit” and use it to calculate weekly profit.

Variables, constants, parameters,

ORQ: This is a variable which must be determined by the decision maker➔ is called

Decision Variable. Although the decision maker is completely free to determine the

value of this

variable, it is necessary to assign a value for this variable that is close to the expected

(or

guesstimated) number of units we can sell with the objective of maximizing profit for

the

business.

X: Number of units sold, is Random variable. This variable can take any value between 0

and a

Maximum, Xm. The value of Xm (The maximum number of units the merchant can

possibly sell) is usually determined by trial and error, from past data, guestimate and so

on.

Sales price/unit, cost/unit, and credit the business owner receive for an unsold unit are all

constants. On the other hand, Revenue, Total Cost, or profit, are parameters.

29

Model of the system The basic model for the profit (the objective) is:

Profit = Revenue – Cost or, P = R – C Where;

• Cost (C ) = ($2)*(ORQ) • Revenue ( R )=

A: If ORQ < X ➔ All units ordered are sold, then R= ($4.5)(ORQ)

B: If ORQ > X ➔ Some of the Calendars must be returned (Ordered more that could

sell). Number of units returned = ORQ-X

➔ R = ($4.5)*(X) + ($0.75)*(ORQ-X) = $3.75X + $0.75 ROQ

• Therefore, Profi In case A above is: P = ($4.5 *ORQ) –($2 * ORQ ) = 2.5 ORQ, and In case B is: P ={($3.75* X +$0.75*ORQ) - $2*ORQ}= $ (3.75X-1.25ORQ)

Flow Chart.

Figure 1 below shows a flow chart of the system. It demonstrates the sequence of

processes in the simulation Model for the Walton bookstore.

Complete the simulation of example 2 and determine optimum value for ORQ

------------------------------------------------------------------------------------------------------------------

(1): For a better answer, you may assume that, calendars come in smaller bundles (i.e., 20 units/bundle). Try it

Figure 1: Flow Chart of the Simulation Model

A NO ORQ > X ? YES

Start>Set QRD= its Min value.

Set j = 1, ( This mean first trial

value of ORQ

Generate X = random value of

demand for the Calendar

All calendars

delivered by the

suppliers are sold

Profit =

=2.5ORQ

Supply is more than

demand. ➔ (ORQ-X)

units must be returned

ASSIGNMENT 2:

30

B

No Is Current ORQ >Xm ?

A B

A B Yes

PART II. Random numbers in Excel (Continue from Module 2)

Excel functions for generating random numbers

These are the distributions that you will most commonly be using in this

class (for risk Analysis). There are a variety of other distributions available,

which use similar syntax. The functions to use for generation random

variate from other distributions will be provided if/when needed

A-Most commonly used distributions

1). RAND( ) Returns a real (with decimal) pseudo-random number uniformly distributed between 0 and 1. Either implicitly or explicitly,

NOTE: this function and its output is used as the basis for all the other built-in random

number generating functions in Excel. We usually call this random number base as

“U”

F(u)

Profit =

3.75X-1.25ORQ

Add 50 units to ORQ

for the next trial (1)

Keep ORQ constant & run the above program (A to B)

SAY 40 TIMES. Calculate Mean profit for the 40

iterations

Compare Mean profit for different values

of ORQ tried. ORQ for the trial with Max.

profit ➔ Answer to the problem

Output

Stop

31

Fig. 1A: Probability distribution of U

0 1

U

Example 1: Generating n random values for “U” (Note that 0 ≤ U≤ 1)

Solution: In Excel Spreadsheet, in columns A and B , enter the headings. Then, in

column A enter trial numbers 1, 2, 3,….N. In column B in Cell B2 Enter “ = rand(), then

copy it (as shown below). A typical random outcome for this process is shown in last

column in Table 3

Table 3

ROW A B Typical outcome for

1 Trial # Excel Function to use “U” in column B

2 1 = Rand() 0.2273

3 2 0.9421

4 3 0.6393

. . …

. . copy … . N …

2). RANDBETWEN(A , B) Returns a whole (no decimal) pseudo-random number uniformly distributed between A

and B. Note that this function is used only when we want to generate whole /round numbers

(means; no decimal). To generate real random numbers (numbers with decimal), use the

following function

Example 2: Suppose labor cost (LCT) in a project is Uniformly distributed between $230

and $450. Generate n random values for the variable CT Note: Similar to the RAND( ) function, RANDBETWEEN(230, 450) assumes that the

numbers between 230 and 450 have the same probability, implying that CT has a Uniform

probability distribution as shown in figure 2 below

f (ct)

Fig. 1B: Probability distribution of U

230 450 CT

Solution: In Excel Spreadsheet, in columns A, B, enter the headings and then follow the

same procedure as in previous section, entering the “=Randbetween(a , b) function in cell

B2 and copying it as shown in Table 4 below.

Table 4 Row A B Typical outcome for

Trial # random CT “CT” in Column B

1 = Randbetween(230, 450) 273

2 421

3 393

. copy …

32

. ...

N …

Note that, the numbers 230 and 450 and all real numbers between them have the same

probability, implying that these numbers are distributed uniformly as shown in Figure 1B

ahown above.

The function randbetween(a, b) generate whole number between a and b. Therefore, it

should not be used to Generate real numbers (numbers with decimal). For instance, if we

are interested in generating say interest rate between 3% and 6%, we should not use the

randbetween (3,6) function since the outcome will be limited to 3, 4, 5, and 6% which in

practice does not make sense. In such cases, we have to use a different function which is

discussed in the following section.

3). A+(B-A)*RAND( )

Returns a real pseudo-random number uniformly distributed between A and B , where A

and B are Min. and Max, values the variable can assume

Example 3: Suppose interest rate (I) in a long-term project is going to be uniformly

distributed between 5 to 8%. Generate n random values for the variable I

Solution: In Excel Spreadsheet, in columns A, B, and C , enter the headings and the

Random variate generating functions (in Red) as follows in Table 3 . the logic is

explained in Figure 1.

Table 3

Column A Column B Column C

Run # U3 Cost (CT)

1

2

.

n

.

= RAND( )

Copy

= 5 + (8-5)*B1

Copy

0 U 1

A

X X : the random

number

33

Between A & B

Figure 2

In Figure 2, we can write:

(X-A)/(U-0) = (B-A) / (1 – 0) Solving this equation, you get:

X = A +(B – A)*(U) (1)

Conclusion. If A and B are given, to generate a random number between A and B,

generate a “U”, and then use equation 1 to determine the value “X”. Note that you

generate “U” by using the Excel function = Rand( )

4)- Generate random values of a discrete random variable? Suppose the demand for a calendar is governed by the following discrete random variable:

Demand Probability

10000 0.10

20000 0.35

40000 0.30

60000 0.25

How can we have Excel play out, or simulate, this demand for calendars many times?

The trick is to associate each possible value of the RAND function with a possible

demand for calendars. The following procedure is used to ensures that a demand of

10,000 will occur 10 percent of the time, and so on.

1)- calculate the cumulative probability distribution of demand data.

Demand Probability Cumulative Probability 10000 0.10 0.10 or (10%)

20000 0.35 0.45 or (45%)

40000 0.30 0.75 or (75%)

60000 0.25 1,00 or (100%)

2)- Generate “n “ values of RAND( )

3)- Since both variables, the cumulative probability of a variable and RAND(), are

between 0 and 1, we can generate random values of the cumulative distribution by using

the function RAND( ). This will allow us to associate each value of demand with a range

of values of cumulative probability distribution (which is the same as RAND()), as

follows

If 0.00 < Rand( ) ≤ 0.10, Demand = 10000

If 0.10 < Rand( ) ≤ 0.45, Demand = 20000

If 0.45 < Rand( ) ≤ 0.75, Demand = 40000

34

If 0,75 < Rand( ) ≤ 1,00, Demand = 60000

To generate random values from this probability distribution we use the RAND()

function and generate random values as shown in the following example..

Example. Suppose you used the function “RAND( )” and generate the following 5

RAND values ; 0.5642, 0.9203, 0.1875, 0.3346, and 0.8712. . Then: • First randomly generated demand corresponding to RAND() =0.5642 ➔ 40000,

• 2nd randomly generated demand corresponding to RAND() =0.9203 ➔ 60000,

• 3rd randomly generated demand corresponding to RAND() =0.1870 ➔ 20000,

• …………………………………….. and so on

Using an Excel spreadsheet, you can apply the method and generate the above random

outcomes or in general, “n” random numbers as shown below. (Table 4)

The key to our simulation is to use a random number RAND( ) to initiate a lookup/search

for the value of demand. Random numbers greater than or equal to 0 and less than 0.10

will yield a demand of 10,000; random numbers greater than or equal to 0.10 and less

than 0.45 will yield a demand of 20,000; random numbers greater than or equal to 0.45

and less than 0.75 will yield a demand of 40,000; and random numbers greater than or

equal to 0.75 will yield a demand of 60,000. You need to repeat the experiment (Copy)

large number of times to ensure that values generated have a the given (Original)

probability

Table 4

Column A Column B Column C

Repetition Rand( ) Random number generated

1 0.5642 =iF (B2< IF=IF( =IF( B2<0.1, 10000, IF(B2<0.45, 20000, If(B2<.75, 40000, 60000)))

2

3

..

.. copy

n

copy

35

5). NORMINV(RAND( ), m, s)

Returns a pseudo-random number that is normally distributed with mean m and standard

deviation s.

Example 2: Suppose cost (CT) in a project is normally distributed with mean= $550 and standard deviation $40. Generate n random values for the variable CT

Solution: In Excel Spreadsheet, in columns A, B, and C , enter the headings and the Random variate generating functions (in Red) as follows ( Table 5)

Table 5

CColumn A Column B Column C

Run # U1 Cost (CT)

B-Generating Random Numbers from Some Other distributions

BINOMINV (RAND (), N, p) Returns a pseudo-random number that is binomially

distributed with sample size N and success probability p.

POISINV (RAND( ), m). Returns a pseudo-random number that is Poisson distributed

with mean m.

LNORMINV (RAND( ), m, s) Returns a pseudo-random number that is log-

normally distributed with mean m and standard deviation s.

BETINV(RAND(), m, s, l, u) Returns a pseudo-random number that is beta distributed

with mean m and standard deviation s, and bounded between l and u (the beta distribution

has a central tendency, like the normal, but only a finite range of allowable values; it is

often used with l = 0 and u = 1).

Assignment:

Assignment 4

36

1) Do Case A and A-1 , Exercises Set 1 2) Do Problems # 18 and 23, Exercise Set 1

Chapter 4. Mont Carlo Simulation

37

Module 4: Some Common applications Table o content

1- Inventory System Simulation 2- The M-N Inventory System 3- Machine reliability study 4- Evaluation of integral

5 - Simulation of hitting a Target Case I: Inventory system simulation.

Introduction. The Inventory management is one of the crucial aspects for any manufacturing firm and

well known topic in both corporate and academic world. Inventory management involves

a set of decisions that aim at matching existing demand with the supply of products and

materials over space and time in order to achieve profitable operations. An inventory is

considered as one of the major assets of a business and it represents an investment that is

tied up until the item is sold or used in the production of an item. It costs money to store,

track and insure inventory. Inventories that are not well managed can create significant

financial problems for a business, whether the problem results in an inventory glut or an

inventory shortage. Proper management of inventories would help to utilize capital more

effectively.

Why Is Inventory Control Important?

If your business requires maintaining an inventory, you might sometimes feel like you're

walking a tightrope. Not having enough inventory means you run the risk of losing sales,

while having too much inventory is costly in more ways than one. That's why having an

efficient inventory control system is so important.

Avoiding Stock-outs.

38

One of the worst things you can do in business is to turn away customers -- people who

are ready to give you their money -- because you've run out of the item they want. "Stock

outs" not only cost you money from missed sales, they can also make you lose customers

for good, as people resolve to take their business somewhere that can satisfy their needs.

An efficient inventory control system tracks how much product you have in stock and

forecasts how long your supplies will last based on sales activity. This allows you to

place orders far enough ahead of time to prevent stock-outs.

Overstock Hazards

When inventory isn't managed well, you can also wind up with overstock -- too much of

certain items. Overstock comes with its own set of problems. The longer an item sits

unsold in inventory, the greater the chance it will never sell at all, meaning you'll have to

write it off, or at least discount it deeply. Products go out of style or become obsolete.

Perishable items spoil. Items that linger in storage get damaged or stolen. And excessive

inventory has to be stored, counted and handled, which can add ongoing costs.

Working Capital Issues

Inventory is expensive to acquire. When you pay, say, $15 for an item from a supplier,

you do so with the expectation that you will soon sell the item for a higher price, allowing

you to recoup the cost plus some profit. As long as the item sits on the shelf, though, its

value is locked up in inventory. That's $15 you can't use elsewhere in your business. So

inventory control isn't just about managing the "stuff" going in and out of your company;

it's also about managing your working capital, keeping you from having too much

precious cash tied up in operations.

Manufacturer's Angle

Inventory control isn't just a concern for companies that deal in finished goods, such as

retailers and wholesalers. It's also critical for manufacturers, who maintain three types of

inventory: raw materials, works in process and finished goods. If you run out of an

essential ingredient or component, production will halt, which can be extremely costly. If

you don't have a supply of finished goods on hand to fill orders at they come in, you risk

losing customers. Staying on top of inventory is essential if you're to keep the line

running and keep products moving out the door.

I-2: Analysis, Modeling and Simulation

Careful inventory management is critical to the financial health of businesses

whose primary venture is manufacturing or retailing. In retail and

39

manufacturing companies, huge amounts of time and $'s are expended in

keeping and managing inventory. A simple graphical representation of

inventory system is shown in Figure 1 below

Basic concepts involved in inventory management. we will build an inventory

model to answer the following two questions:

• How much do we order? (see figure 1)

• When to order? - with the goal of minimizing the total inventory costs. •

X: Flow rate in (order)

Inventory fluctuation in the Tank

is a function of (X-Y)

Y: Flow rate out (Demand)

I

X: flow rate (i.e., gallons /hour)

Y = Demand rate ( used by customers)

Figure 1. A simple inventory system

In most basic inventory models we are going to make several important

assumptions in order to keep the model simple.

Assumptions:

• Only one item is considered.

• An entire order arrives at once.

• No shortages may or may not be allowed.

• The demand is probabilistic and its probability distribution is known

• The time value of money is zero.

• Price for items is not a function of order quantity (no Quantity discount)

• Lead-time is known and constant.

There are three basic types of inventory - raw materials, work-in-process,

finished goods. Our analysis may apply to any of the three with minor

40

variations. The principle remains the same. In inventory analysis, we work

with two variables

a) Independent demand which in most cases is represented as a random

variable since we do not have any control on number of customers and

their demand level. Independent demand is most frequently associated

with finished goods where the demand is more or less unknown.

b) Dependent demand refers to those items (i.e., inventory level, demand

for labor hours and so on) which are determined as a function of the

independent demand.

The costs associated with inventory fall into two broad categories or

components. All the costs associated with keeping stock in inventory is

“lumped together as carrying cost (we may also call it the holding cost

component). All the costs associated with ordering and delivering the stock is

"lumped" together, and called the ordering cost component. Some costs which

may be included in the holding cost component are:

• opportunity cost

• taxes

• insurance

• storage

• shrinkage

Some costs which may be included in the ordering cost component are:

• ordering costs

• set-up costs

• transportation costs

• small lot costs

• stock-outs and backorders

To simulate a simple inventory system, we first build a mathematical

(analytical) model. Following typical conventions, we need some descriptions

and shorthand notation for variables used in the model (These notations are

those used in different textbook in modeling a general inventory system. The

analysis may use alternative notations).

Order quantity (Q) - Number of units ordered, also called the lot or batch size.

41

Demand (D) - Usually the annual demand. You may need to convert available

information to annualized data.

Item Cost (C) - Purchase price of raw materials or value of finished goods or

WIP.

Carrying charge rate (i) - Composite % or decimal fraction of the item's cost

that reflects the cost of keeping one unit in inventory for one year. Usually, but

not always, expressed in % per unit per year.

Holding Cost per unit (H) - Cost, in dollars, to keep one unit in inventory for

one year, H = i x C. Make sure you don't confuse this with the holding cost

component.

Ordering Cost (Co) - Cost to place one order, not to be confused with the

Ordering Cost Component. Frequently, this is designated S, the set-up cost,

when dealing with WIP or finished goods inventory.

Lead Time (LT) - The time that elapses between placing an order and receipt

of that order.

Re-Order Point (ROP) - The on-hand inventory level at which we should place

the order for the next batch.

Stock-out Cost (S)- The cost incurred when there is insufficient inventory.

1-3. M-N Inventory System simulation &&Assignment An M-N inventory system, generally used by small companies, is a system that has an

inventory review every N time periods (i.e., every 20 days), and when we replenish, we

always bring the inventory level to A maximum of M units. At each N time units, the

inventory level is checked and an order placed to bring the inventory up to level M. The

operation of the system (shown in Figure 2 below) is based on the following

assumptions

1)- The lead time (for ordering and receiving) is assumed zero

2)- There are two customers, Company A and B. Demand by these customers (called X

and Y) are

random. Note that since X and Y are random, then total demand Z= X+Y is also

random

3)- Shortages are backordered. This means, if we do not have it now, we will supply

the customer

next period. 4)- At the end of time period “0” (initial inventory for period 1) = I0.

42

Time

Inventory level Figure 2. An M-N Inventory System

M

Io

Let: BINi = Beginning

Inventory, period i

EINi = Ending

Inventory, period i

Xi & Yi = Demand for the product by internal customers (Y), and external customers (X) in

period i ORDi = Amount to order @ the end of period I (This is shown as Qi in the graph)

EXCi = Excess inventory, end

of period i SHTi = Shortage

end of period i

n = # of replications

N = Time between orders ( we order every N

units of time) M = Max Inventory Level

allowed

J = Number of time shortage happened

What you need to do:

a). Develop the equations (Models) of the system

b)- Use spreadsheet and simulation the system 100 tomes.

c)- From the output, for a given “M”, determine what % of time the end of period

inventory will be

negative (need backordering). Develop a histogram of the variable “ENIi”

d)- If we want s safety stock of 50 units, what the optimum value of “M” should be?

HINT: How to use Spreadsheet To simulate this type of systems?

Step 1; We start in period 0 (this is for setting initial condition and getting ready to

start period ( 1, 2, 3,…). Now let:

X1+Y1

X2+Y2

X3+Y3

X4+Y4

Q1 Q2 Q3

Q4 Q5

0 1

2

3 4

N N

N N

43

Row A B

Period Starting

1 Inventory

C D E F

Order Demand Ending Shortage

Quantity Inventory Units

Excess

Units

2

3

0

1

0

= E2 =M-E2

0

=Z

Io

=M-D3

0 0

=IF(E3>0, 0,E3) =IF(E3<0, 0,E3)

copy

EIN0 = I0, then ORD0 = M-Io (this is because we are assuming that at the end of

each period we will order enough material to bring the total inventory to “M” for the

start of next day). Enter in top row of excel the following information for period “0”.

BIN0 =0, Z0 = 0, EIN0=I0, ORD0 =M -I0, EXC0 =0, and SHT0 =0

Step 2; for periods 1, 2, 3,…n, find the value of different elements as follows;

BINi = EIN i --1 +ORD i –1 [i.e., beginning inventory on period 10 equals ending

inventory of

period 9 plus what we receive (ordered before) beginning of

period 10]

Xi is generated randomly This is generated randomly from the probability distribution of Z

EINi = BINi – Zi [i.e., ending inventory of say period 10 is equal to it beginning –

Demand in period I ]

ORDi = M – EINi [i.e., The amount we order (say at the beginning of period 10)

must be

enough to bring inventory level to “M” units

If EINi > 0, then EXCi = EINi, and SHTi = 0 and vice-vera

n excel worksheet, the simulation will proceed as in Table 1below.

,

Table 1

Note that in simulating an inventory system, the objective may be to determine response to many

(other than what is discussed here) managerial questions, including; calculating average or an

appropriate value for M, or testing validity of assumptions (on which this simulation is based),

44

and so on. In those cases, we have to modify some or all of the above equations (models)

Step 3; Run the simulation n times (n.>50). And

Step 4: Calculate system metrics/performance measures, including, A). Percent of time there was

shortage

B). Maximum or average shortage quantity

C). Probability distribution of shortage

quantity D). Probability distribution of

order quantity

E) If we desire to have “K” units in inventory as safety stock, what the optimum value

of “M” should be

F). Others …………………………………

ASSIGNMENTS 4-1:

Problem. Consider an M-N inventory system, discussed above, with the following input data:

• I0 =120 units (initial Inventory)

• M=480 units

• N= 1 week (5 working days)

• X= Uniform distribution with Min =270 units/week and Max=350

Y(units/week) 160 175 195

Pr(Y) 0.40 0.32 0.28

What you need to do:

a). Develop the equations (Models) of the system

b)- Use spreadsheet and simulation the system 100 tomes.

c)- From the output, determine what % of time the end of period inventory

will

be negative (need backordering). Develop a histogram of the variable “ENIi”

d)- If we want a safety stock of 50 units, what the optimum value of “M” should be?

Problem 3-1B: The newspaper seller's problem

1) The paper seller buys the papers for 33 cents each and sells for 50 cents each.

2) The papers not sold at the end of the day are sold as scrap for 5 cents each.

45

3) Newspapers can be purchased in bundles of 10. Thus the paper seller can buy 40, 50,

60, and so on. In the simulation shown in Table 2.18 the case of purchasing 70

newspapers is demonstrated.

4) There are three types of news days, ``good'', ``fair'', and ``poor'' with probabilities of

0.35, 0.45 and 0.20.

5) The demand distribution is listed in Table 2.15 on page 37.

6) Profit is calculated as

Use simulation and determine the optimum (profit maximization) number of

newspaper we need to order each day. Each simulation must be run at least 40 times

Example 3-1C: Simulation of an (M,N) inventory system.

• M is the maximum inventory level, assume it is 11 units.

• N is the length of review period, assume it is 5 days.

• The initial inventory is 3 units, and an initial order of 8 units is scheduled to arrive in

2 days. This is the initial setting of the simulation.

• Table 2.21 on page 41 shows the detail

Case 3. Simulating machine reliability

II-1)- What is Reliability?

Reliability refers to the % of time a machine is up and working (A machine may be

down for a number of reasons). For a brief discussion of reliability and related subjects,

see he Appendix 1 at the end of this section.is presented below.

EXAMPLE: Machine A is (on average) down 40 minutes per day (day of work = 8 hours). The reliability factor = (8*60 -40)/(8*60) = 91.67 %

This says that, the machine is only 91.67% reliable and

about

8.33% of time will be Idle

II-2) how to use simulation to determine reliability of a

machine?

EXAMPLE: A machine has two different bearing that fail in service. The distribution of life (time between breakdowns are as follows

life in minutes (ti)➔ 40 100 120 Probability ➔ 0.3 0.45 0.25

46

When a bearing fails, maintenance department is called to install a new bearing.

Maintenance jobs are started immediately after a breakdown. The time it takes to fix the

problem is as follows

Time to install a bearing (RTi)➔ 5 Min. 10Min. 15Min.

Probability ➔ 0.35 0.45 0.20 Note: When a Bearing fails, the company incurs two types of costs:

1) The machine becomes idle. This cost the company $20 an hour 2) We pay for a new bearing. The cost for bearing = $45

What is required.

1) Determine the reliability of the machine

2) Number of stoppage per day

3) Average cost of maintenance per day

4) What % of time the maintenance operator is busy working for this machine.

SOLUTION

First let us show the operation of the system on a time line

Let ti = time between arrival of successive failures on bearing 1 and tĩ = time between arrival of successive failures on bearing 1

Repair Time T=960 Min

t1 t2 t3 Clock

0 Fail(A) Fail(B) Fail (A) Fail (A) Fail (B) Time

(T)

t1̃ t2̃

Legend:

: This Symbol is used for Repair Time

: The (length of ) inter-arrival s (Brown color for Bearing type A, and Green for

B)

: Continuous Clock Time

Now we can generate ti and tĩ and on each case convert the numbers to clock hours. As

shown above This may be done as follows

Repair time Number of Generate ti Clock# 1 generate tĩ Clock # 2 Bearing Bearing

Tria;s (Min) (Min) (min) (min) #1 (min) #2 (min)

47

------------------- ------------- ---------------- -------------- --------------- ------------- ---------------

1 300 310 200 205 10 5

2 450 765 300 520 5 15

3 200 980 300 830 15 10

4 -- -- 200 1045 - 15

Conclusions:

a- # of breakdowns = 7

b- Downtime = 75 minutes

c- Cost = $20*75/60 = $25 Machine cost = (7) *$45 = $340 (for 2 shifts). Total cost = 340+ 25 = $365

d- Operator busy time = (960 -75)/960 =93.6%

A Spreadsheet simulation format

Assignment 4-2A: Run the simulation for 15 hours per day and answer the questions a, b, c,

and d (above) with the following additional assumptions:

1)- When there is a breakdown, in addition to repair time we spend X

minutes for testing and resetting up the system (X has a normal distribution

with mean 10 and standard deviation of 5 minutes)

2)- After every 4 hours of operations, we need to change a filter on the

machine which takes 20 minutes each time

A B C D E F Number of

breakdown

ti (Time between

Breakdowns

Repair time

(RT)

Clock time

After repair

Clock time

Before repair

Cumulative

Down time

0 0 0 480 0 0

1

2

3

………

n

Totals ➔

48

APPENDIX 1: A brief Review of Reliability and Availability

Maintainability: It is the effort and cost of performing maintenance. It is affected by factors such as, the ease of access to equipment for maintenance, availability of spare parts and the skill level

required doing the maintenance. One measure of maintainability is Mean Time To Repair (MTTR). A high MTTR is an indication of low maintainability

MTTR= (Downtime for repair)/( Number of repairs)

Here, Downtime for repair includes

a) Time waiting for repair TW

b) Time spent doing the repairs TR c) Time spent for testing and getting the equipment ready to resume production (of good

parts)

Note that in some organizations repair time is defined as the downtime for repair only.

Reliability: It is the probability that the equipment will perform properly under normal operating conditions for a given period of time. In some cases reliability is not defined over time but over another measurement such as miles traveled etc.

One measure of reliability (R) is the probability of successive performance

or R = ( Number of successes) / (Number of repetitions) Example 1: A machine produces 500 parts of which 480 are good, and then the machine is 480/500 = 96% reliable

Example 2: A machine used to test circuit boards for defects work 99% of the times

(it misses 1% of all defective boards), then the machine is 99% reliable.

Availability: Availability is the proportion of time equipment is actually available to perform work out of the time it should be available one measure of availability (A) =MTBF / (MTBF- MTTR)

It is obvious that availability is increased through a combination of increasing MTBF,

49

decreasing MTTR or both. This relationship, while taking into account the repair-related

sources of downtime (MTTR), it ignores non-repair sources of downtime as a result,

it overstates the actual equipment availability. A better measure of availability is

A=( Actual running time)/ ( Planned running time)

Where, Planned Running Time= Total Plant Time- Planned Down Time Actual

Running Time= Planned Running Time- All Downtimes

Example: Suppose a plant two 8 hrs shift per weekday. During each shift there two hours of planned downtime Planned running time= 16-2(2)= 12 hrs Suppose the machine is stopped each day, an average of 110 minutes for setups and 75

minutes for breakdowns and repairs, then: Actual running time= 12(60)-(110+75=535 mins

The availability of equipment is thus A= 535/12(60)= 0.743 or 74.3%

Quality: Quality is defined as the degree by which product/services satisfy the user’s requirements. Quality of a product/service and reliability are dependent on each other. A high-quality product will have a high reliability and vice versa.

Failure: Failure here simply means that equipment/component’s performance is not satisfactory.

It can also mean that equipment /component malfunctioning in some respects or is

completely broken. A failure may be treated as random or deterministic by studying the

physics of the failure process. The more reliable equipment/component is, the less likely it will fail. The likelihood of

failure is shown with failure pattern (also called bath-tub-curve) which will be discussed later.

Mean Time Before Failure: A measure reliability and equipment failure is the mean time between failure (MTBF).

For equipment that can be repaired, MTBF represents the average time between failures. For equipment’s that cannot be repaired, it is average time to the first failure. If we assume a constant failure rate, then

MTBF=( Total running time)/ (Number of failure)

MTBF is usually determined on the basis of historical data on product/equipment downtime as shown below

50

| tw1 | tD1 | tw2 | tD2 | tw3 | tD3 | | tDn | Time

line Note: tW = System working, tD = System idle MTBF = { ∑ Twi }/ n

Example: Twenty machines are operated for 100 hours. One machine fails after 60 hours and another after 70 hours. What is MTBF?

MTBF={ (20)(100)-[(100-70) +(100-60)]} /2 = 1930/2= =965 hours/failure

Alternatively MTBF= (18)(100)+70+60/2= 1930/2 = 965 hours/failure

Failure Distribution Reliability function It is generally assumed that the probability distribution of tW is Exponential. And item will not fail before t. Then

R(t)= e-λt (Here R(t) is the reliability function)

Where, 0 < = R(t) < =1

e = natural logarithmic base

t = specified time

λ=failure rate= 1/MTBF

Example: If MTBF for a machine is 965 hours/failure, what is the reliability of the machine at 500

hours, 900 hours? λ=1/965= 0.0010362

R(500)= e-(500)(0.0010362) = 0.596 R(900)=e-(900)(0.0010362) = 0.39 Case 4::Evaluation of Integral, Method 1

Consider the following polynomial. It is desired to evaluate the area under the curve

from x=0 to x =3. Use the method we discussed in class on Thursday. To assist you in

this process, below, I have provided a briefly explanation of the method and how you

should apply it to this (or any) function.

Y

Ymax.: A B

YE E

Figure 1.

51

YR

Ymin C X E D X

Xmin Xmax

Objective: Determining area under the above curve (integral) between Xmin and

Xmax. This is the area under the curve between point C and Point D. Suppose the

equation of the curve [Y = f(X) ] is very complex and could not be integrated, using

simple integration rules. Therefore, we have decided to use digital simulation to answer

the problem.

Procedure: In Fig 1, p = a ratio defined as:

a)-p = (Area under the curve) (Total area of rectangle ABDC). (1)

b)-The area of the rectangle = (Xmax - Xmin)*( Ymax – Ymin).

c)- If p is known, then from equation (1),,

Area under the curve= (p)*(Area of rectangle) =(p)*( CD x CA)

= (p)*[ (Xmax – Xmin )(Ymax - Ymin) ]

How to estimate p ? Step 1: Generate a random number between Xmax and Xmin. Call it XE

Step 2: Substitute XE in Y = f(X) and find the value of Y. This is called YE

Step 3: Generate a random number between Ymax and Ymin. Call it YR (See Figure 2)

Step 4: Compare YR. with YE.. If YR ≤ YE, then, the point (XE, YR) is inside the

curve,

(or under the curve) otherwise it is outside the curve. See Figure 2.

Example: In Fig. 2, point (XE, YR) is point F which is under the curve.

Step 5: Do steps 1 to 4 above, m times and count n = Number of times that, the

point was under the curve. After repeating m times, you can find p = n/m

Y

Ymax A B

E

YE

Figure 2: YR F

52

Ymin C X E D X

Xmin Xmax

How to determine the area of the rectangle ?

Area of the rectangle ABDC = (Xmax - Xmin)*( Ymax – Ymin). Note that in this equation;

• Xmax and Xmin are given quantities.

• Ymin = 0

• Ymax must be determined as follows:

To determine the value of Ymax, we can use one of the following methods: A). Find the derivative of the function Y = f(X) and set the derivative equal to zero.

Assuming

it is possible to solve the equation; the solution will enable us to find all max and

min

points of the function.

B). Use enumeration method. Determine the value of Y for different/all possible

values of X (see below) . Pick the largest value of Y and call it Ymax . For

instance we may change the values of X as follows

Values assigned to X : Xmin, 0.10 +Xmin , 0.20 +Xmin, 0.30 +Xmin,,……. Xmax

Note that since we are assuming it is not possible to use mathematical methods (i.e., using

derivative of the function) to determine the coordinates of the point where the function takes its

maximum value, we have to use an alternative method such as the one discussed in the previous

paragraph. It should be noted that, when we use this method, the Ymax obtained is an

approximation and may not necessarily be equal to the real maximum. However, it is possible to

get as close to the real Maximum as possible if we minimize the incremental increase from one

(assigned) X value to the next one in the process.

Example Suppose the function we want to use simulation and determine the integral of that function is

given as: Y = 2X – X ² where 0 ≤ X ≤2. This implies that Xmax =2 and Xmin = 0 We can

find Ymax by assigning a series of possible values to X and calculating the value of Y for each

X as follows:

Assign X = 0 0.1 0.2 0.3,………… 1, 1.1 1.2……………2

Calculate Y = 0 0.19 0.36 0.51 ………...1, 0.99 0.96…………..0

Ymax

Y

53

Therefore:

Xmax =2,

Xmin = 0 ,

Ymax =1, Ymax Ymin =0.

Figure 3

X

0 1 2 (Xmax )

Therefore for this example, Area of rectangle = (2-0)*( 1-0) = 2

ASSIGNMENTS 4-3 Use either method 1 or method 2 (discussed below) to estimate area under each curve.

A)-Use Monte Carlo simulation to approximate the integral B)- Use Monte Carlo simulation to approximate the area under the curve

4/(1+x2 Between x = 0.5 and x =2

III-2:Evaluation of Integral, Method 2(1)

An Overview

In this part we introduce an alternative method for estimating the area of a shape using

the Monte Carlo technique. The principle of a basic Monte Carlo estimation is this:

imagine that we want to integrate a one-dimensional function f(x) from aa to bb such as:

b F= ∫ f(x)dx. a

As you may remember, the integral of a function f(x) can be interpreted as calculating the

area below the function's curve. This idea is illustrated in Figure 1. Now imagine that we

just pick up a random value, say x in the range [a,b], evaluate the function f(x) at x and

multiply the result by (b-a). Figure 2 shows what the result looks like: it's another

rectangle (where f(x) is the height of that rectangle and (b-a) its width), which in a way

you can also look at a very crude approximation of the area under the curve. If we

evaluate the function at x1 (figure 3) we quite drastically underestimate this area. If we

54

evaluate the function at x2, we over-estimate the area. But as we keep evaluating the

function at different

Figure 1: the integral over the domain [a,b] can be seen as the area under the curve.

Figure 2: the curve can be evaluated at x and the result can be multiplied by (b - a).

If we pick random points between a and b, adding up the area of the rectangles and

averaging the sum, the resulting number gets closer and closer to the actual result of the

integral. It's not surprising in a way as the rectangles which are too large compensate for

the rectangles which are too small. And in fact, we can prove that summing them up and

averaging their areas actually converges to the integral "area" under the curve, as the

number of samples used in the calculation increases. This idea is illustrated in the

following figure. The function was evaluated in four different locations (In the simulation

process, xi values must be generated randomly). The result of the function as these four

values of x randomly chosen, are then multiplied by (b-a), summed up and averaged (we

divide the sum by 4). The result can be considered as an approximation of the actual

integral.

55

Of course, as usual with Monte Carlo methods, this approximation converges to the

integral result as the number of rectangles or samples used increases.

We can formalize this idea with the following formula:

N-1

FN = (1/N) (b−a) ∑ f(Xi) (1) 0 N in equation (1), is the number of samples used (or number of trials in simulation) in

the study to estimate the area under the curve. FN is an approximation of area using N

samples. As N increases, the error of estimate approaches zero. This equation is called

a basic Monte Carlo estimator

------------------------------------------------------------------------------

(1). https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/monte-

carlo-methods-in-practice/monte-carlo-integration

Case #5. Simulation of hitting a target

In this case study we simulate a bombing mission where the actual location a bomb hits

varies

from its target by a random amount defined by Normal distribution. The normal

distribution is used to estimate the random location the bomber hits each time. Recall

that the Normal distribution is symmetric around its mean with likely range determined

56

by its standard deviation. This is a classic use of normal distribution where the deviation

from the mean (target) represent error/ missing the target.

Case study 1, & Assignment: A Military Bomber must hit a target shown as a blue box

in Figure 1. We want to use Digital Simulation to estimate % of time the bomber will hit

the target.

Assumptions: 1)- Bomber flies on Y access (as shown below)

2)- Real target is point “O” with X=Y=0

Y Target inside this Square

a). Deviation in X direction follows a Normal distribution with:

Mean = 0. & Standard Deviation = 150 meter

b). Similarly, deviations in Y direction follows a Normal Distribution with:

Mean = 0. & Standard deviation = 200 meter

General Procedure to simulate the system.

1)- generate X and Y randomly (2)

2)- find out whether the point (X,Y) is inside the box or not,

3)- If it is inside the bob, add to count (numbers inside)

57

4)- Repeat steps 1, 2,, and 3, above “N” times. Suppose only M time your point was inside

the box.

➔ Probability of hitting the target = M/N

Case Study 2.

In general, How to determine a randomly generated point is inside the target area or not.

Consider the following Example.

EXAMPLE: Suppose You have generated X and Y Randomly (Point A ). And were

planning to hit the Target, which is inside the triangle OBC Y

B

Y1 A

Yc

X

0 X1 C

Point is INSIDE or OUTSIDE the Target Area?

To determine answer to this question, we assume that the equation of Border lines ( like

Line BC) Are given. For example, in this case (above). Equation are:

• Line OC: Y=0

• Line OB: X=0

• Line BC: Y= 7 -1.75X ➔ Coordinated of B and C are: B:(0, 7), C: (4, 0)

Now you can use the following procedure to determine a point hit by the Bomber

(generated randomly) is inside or outside the OBC target area:

a)- Check to see if X1 (randomly generated) > XMax, if yes, point A is outside the

triangular area If it is not go to step b

b)- Substitute X1 in the equation of the line BC. This will allow us to calculate Yc .

Now randomly generate Y1. (note that 0 < Y1 < Ymax )

c)- If y1 >Yc, then the point is outside the triangular area, if not it is inside.

D), Continue the procedure n times and count number of time points are inside……

58

Problem #1: Simulate the system (Case study 1, Above) 50 times and estimate % of

time the Bomber will hit the target. Based on your simulation, which direction (Y or X)

is the least reliable/causes more Miss than the other

Problem # 2: Solve problem #12 on page 81 of the textbook. Note that you have to run

the model40 times (not 5 time as the problem statement indicates).

Assignment 4-4