0% found this document useful (0 votes)
26 views80 pages

Batch 1 - Simulation and Modelling

r

Uploaded by

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

Batch 1 - Simulation and Modelling

r

Uploaded by

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

TAITA TAVETA UNIVERSITY

SCHOOL OF SCIENCE AND INFORMATICS

COURSE CODE: SMA 2450/SIC 2448

COURSE TITLE: SIMULATION AND MODELLING

LECTURER: Dr. Kasyoki


Course content

Pre-Requisites: SMA 2101 Calculus I, SMA 2102 Calculus II, SMA 2200 Calculus III, STA 2100
Probability and Statistics I & STA 2200 Probability and Statistics II

Course Description:
Systems modeling: terminology, and types of models. Role of models, model building techniques.
Simulation: discrete and continuous event simulations, design of simulation experiments, and simulation
languages. Essential Mathematics: probability and distribution theory, statistical estimation, and inference.
Random number generators: Pseudo-random number generators, test of randomness, and sequences for
random number generation. Model development (models in calculus, statistics and algebra) and simulation:
use of simulation software such as MATLAB, translation of models into high level language and simulation.
Monte Carlo Simulation: output analysis, sample event, parameter estimation, maximum likelihood, and
least mean square error.
Teaching and Learning Methodology:
Lectures, tutorials, practical sessions, class discussions, individual/group projects.
Instructional Materials/Equipment:
Whiteboards/smart boards, whiteboard markers, duster, flipcharts, computers, projector, other
computer laboratory resources, and hand-outs.
Course Assessment Procedures:
Continuous Assessment Tests (15%); Practicals (10%); Assignments (5%); End-of-Semester Examination
(70%).
Course Textbooks:
1. Banks, J., Carson, J. S., Nelson, B. L. & Nicol, D. M. (2009), Discrete-Event System Simulation, 5th
ed., Prentice Hall, ISBN-13: 978-0136062127.
2. Law, A. M. & Kelton, W. D. (2007). Simulation Modeling & Analysis, 4th ed., McGraw-Hill Inc.,
ASIN: B013HIO2E6.
Reference Textbooks:
1. Chung, C. A. (2003), Simulation Modeling Handbook: A Practical Approach, CRC Press, ISBN-13:
978-0849312410.
2. Bekey, G. A. and Kogan, B. Y. (2003), Modeling and Simulation: Theory and Practice, Academic
Publishers, ASIN: B010BDCLCA.
MODELLING AND SIMULATION CONCEPTS

1.0 Introduction
The ability of man to define what may happen in the future and to choose among
alternatives lie at the heart of contemporary societies. Our knowledge of the way things
work, in society or nature are trailed with clouds of imprecision, and vast harms have
followed a belief in certainty. To reduce the level of disparity between outcome and reality,
we require a decision analysis and support tool to enable us to evaluate, compare and
optimize alternative. Such a tool should be able to provide explanations to various
stakeholders and defend the decisions. One such tool that has been successfully employed
is simulation which we use to vary the parameter of a model and observe the outcome.
Simulation has been particularly valuable:
a. When there is significant uncertainty regarding the outcome or consequences of a
particular alternative under consideration. It allows you to deal with uncertainty and
imprecision in a quantifiable way.
b. When the system under consideration involves complex interactions and requires
input from multiple disciplines. In this case, it is difficult for any one person to easily
understand the system. A simulation of the model can in such situations act as the
framework to integrate the various components in order to better understand their
interactions. As such, it becomes a management tool that keeps you focused on the
"big picture" without getting lost in unimportant details.
c. when the consequences of a proposed action, plan or design cannot be directly and
immediately observed (i.e., the consequences are delayed in time and/or dispersed in
space) and/or it is simply impractical or prohibitively expensive to test the alternatives
directly.

2.0 Main Content

2.1 Modelling and Simulation Concepts

Modern science would be inconceivable without computers to gather data and run model
simulations. Whether it involves bringing back pictures of the surface of the planet Mars or
detailed images to guide brain surgeons, computers have greatly extended our knowledge
of the world around us and our ability to turn ideas into engineering reality. Thus
modelling and computer simulation are important interdisciplinary tools.

2.2 Definitions
2.2.1 Modelling is the process of generating abstract, conceptual,
graphical and/or mathematical models. Science offers a growing
collection of methods, techniquesand theory about all kinds of
specialized scientific modelling.
Modelling also means to find relations between systems and models. Stated
otherwise, models are abstractions of real or imaginary worlds we create to
understand their behaviour, play with them by performing "what if"
experiments,make projections, animate or simply have fun.
2.2.2 A model in general is a pattern, plan, representation (especially in
miniature), or description designed to show the main object or
workings of an object, system, orconcept.
2.2.3 A model (physical or hypothetical) is a representation of real-world
phenomenon or elements (objects, concepts or events). Stated
otherwise a model is an attempt toexpress a possible structure of
physical causality.
Models in science are often theoretical constructs that represent any particular thing
with a set of variables and a set of logical and or quantitative relationships between
them. Models in this sense are constructed to enable reasoning within an idealized
logical framework about these processes and are an important component of
scientific theories.
2.2.4 Simulation -is the manipulation of a model in such a way that it
operates on timeor space to compress it, thus enabling one to
perceive the interactions that would not otherwise be apparent
because of their separation in time or space.
2.2.5 Modelling and Simulation is a discipline for developing a level of
understanding ofthe interaction of the parts of a system, and of the
system as a whole. The level of understanding which may be
developed via this discipline is seldom achievable viaany other
discipline.
2.2.6 A computer model is a simulation or model of a situation in the
real world or animaginary world which has parameters that the
user can alter.
For example Newton considers movement (of planets and of masses) and writes equations,
among which f = ma (where f is force, m mass and a acceleration), that make the dynamics
intelligible. Newton by this expression makes a formidable proposition, that force causes
acceleration, with mass as proportionality coefficient. Another example, a model airplane
is a physical representation of the real airplane; model of airplanes are useful in predicting
the behaviour of the real airplane when subjected to different conditions; weather, speed,
load, etc. Models help us frame our thinking about objects in the real world. It should be
noted that more often than not we model dynamic (changing) systems.

2.3 What is Modelling and Simulation?


Modelling is a discipline for developing a level of understanding of the interaction of the
parts of a system, and of the system as a whole. The level of understanding which may be
developed via this discipline is seldom achievable via any other discipline.

A simulation is a technique (not a method) for representing a dynamic real world system
by a model and experimenting with the model in order to gain information about the
system and therefore take appropriate decision. Simulation can be done by hand or by a
computer. Simulations are generally iterative in their development. One develops a model,
simulates it, learns from the result, revises the model, and continues the iterations until an
adequate level of understanding is attained.
Modelling and Simulation is a discipline, it is also very much an art form. One can
learnabout riding a bicycle from reading a book. To really learn to ride a bicycle one must
become actively engaged with a bicycle. Modelling and Simulation follows much the same
reality. You can learn much about modelling and simulation from reading books and
talking with other people. Skill and talent in developing models and performing
simulations is only developed through the building of models and simulating them. It is
very much ―learn as you go‖ process. From the interaction of the developer and the
models emerges an understanding of what makes sense and what doesn't.

2.4 Type of Models


There are many types of models and different ways of classifying/grouping them. For
simplicity, Models may be grouped into the following – Physical, Mathematical,
Analogue, Simulation, Heuristic, Stochastic and Deterministic models.
a. Physical Models
These are call iconic models. Good examples of physical models are model cars, model
railway, model airplane, scale models, etc. A model railway can be used to study the
behaviour of a real railway, also scale models can be used to study a plant layout design. In
simulation studies, iconic models are rarely used.

b. Mathematical Models
These are models used for predictive (projecting) purposes. They are abstract and take the
form of mathematical expressions of relationships. For examples:

1. x2 + y2 = 1 (mathematical model of a circle of radius 1)

2. Interest = Principal x Rate x Time


……………………………
100
3. Linear programming models and so on.

Mathematical models can be as simple as interest earnings on a savings account or as


complex as the operation of an entire factory or landing astronauts on the moon. The
development of mathematical models requires great deal of skill and knowledge.

c. Analogue Models
These are similar to iconic models. But here some other entities are used to represent
directly the entities of the real world. An example is the analogue computer where the
magnitudes of the electrical currents flowing in a circuit can be used to represent quantities
of materials or people moving around in a system. Other examples are; the gauge used to
check the pressure in a tyre. The movement of the dial represent the air pressure in the tyre.
In medical examination, the marks of electrical current on paper, is the analogue
representation of the working of muscles or organs.

d. Simulation Models
Here, instead of entities being represented physically, they are represented by sequences of
random numbers subject to the assumptions of the model. These models represent
(emulate) the behaviour of a real system. They are used where there are no suitable
mathematical models or where the mathematical model is too complex or where it is not
possible to experiment upon a working system without causing serious disruption.

e. Heuristic Models
These models use intuitive (or futuristic) rules with the hope that it will produce workable
solutions, which can be improved upon. For example, the Arthur C Clerk‘s heuristic model
was the forerunner of the communications satellite and today‘s international television
broadcast.

f. Deterministic Models
These are models that contain certain known and fixed constants throughout their
formulation e.g., Economic Order Quantity (EOQ) for inventory control under uncertainty.

g. Stochastic models
These are models that involve one or more uncertain variables and as such are subject to
probabilities.

2.5 Advantages of Using Models


 They are safer.
 They are less expensive. For example, Practical Simulators are used to train pilots.
 They are easier to control than the real world counterparts.

2.6 Applications
One application of scientific modelling is the field of "Modelling and Simulation",
generally referred to as "M&S". M&S has a spectrum of applications which range from
concept development and analysis, through experimentation, measurement and
verification, to disposal analysis. Projects and programs may use hundreds of different
simulations, simulators and model analysis tools

2.7 Modelling Procedure


In modelling we construct a suitable representation of an identified real world problem,
obtain solution(s) for that representation and interpret each solution in terms of the real
situation. The steps involved in modelling are as follows:
1. Examine the real world situation.
2. Extract the essential features from the real world situation.
3. Construct a model of the real (object or system) using just the essential features
identified.
4. Solve and experiment with the model.
5. Draw conclusions about the model.
6. If a further refinement necessary, then re-examine the model and readjust parameters
and continue at 4, otherwise continue at 7.
7. Proceed with implementation.

Explanation of the Steps


Begin with the real world situation, which is to be investigated with a view to solving some
problem or improving that situation.

The first important step is to extract from the real world situation the essential features to be
included in the model. Include only factors that make the model a meaningful representation
of reality, while not creating a model, which is difficult by including many variables that do
not have much effect. Factors to be considered include ones over which management has
control and external factors beyond management control. For the factors included,
assumptions have to be made about their behaviour.

Run (simulate) the model and measure what happens. For example, if we have simulation of
a queuing situation where two servers are employed, we can run this for hundreds of
customers passing through the system and obtain results such as the average length of the
queue and the average waiting time per customer. We can then run it with three servers, say,
and see what new values are obtained for these parameters. Many such runs can be carried
out making different changes to the structure and assumptions of the model.

In the case of a mathematical model we have to solve a set of equations of some sort, e.g.
linear programming problem where we have to solve a set of constraints as simultaneous
equations, or in stock control – where we have to use previously accumulated data to predict
the future value of a particular variable.

When we have solved our mathematical model or evaluated some simulation runs, we can
now draw some conclusions about the model. For example, if we have the average queue
length and the average waiting time for a queuing situation varied in some ways, we can use
this in conjunction with information on such matters as the wage-rates for servers and value
of time lost in the queue to arrive at decisions on the best way to service the queue.

Finally, we use our conclusions about the model to draw some conclusions about the original
real world situation. The validity of the conclusions will depend on how well our model
actually represented the real world situation.

Usually the first attempt at modelling the situation will almost certainly lead to results at
variance with reality. We have to look back at the assumptions in the model and adjust them.
The model must be rebuilt and new results obtained. Usually, a large number of iterations of
this form will be required before acceptable model is obtained. When an acceptable model
has been obtained, it is necessary to test the sensitivity of that model to possible changes in
condition.

The modelling process can then be considered for implementation when it is decided that the
model is presenting the real world (object or system) sufficiently well for conclusions drawn
from it to be a useful guide to action.

The model can be solved by hand, especially if it is simple. It could take time to arrive at an
acceptable model. For complex models or models which involve tremendous amount of data,
the computer is very useful.

4.0 Self-Assessment Exercise(s)


Answer the following questions:
1. Differentiate between Model, Modelling, Simulation and Computer model.
2. What are the steps followed in modelling?
3. State why we use models

7.0 Further Readings


 Devore, J. L. (2018). Probability and statistics for engineering and the sciences. Toronto,
Ontario: Nelson.
 Georgii, H. (2013). Stochastics: Introduction to probability and statistics. Berlin: De
Gruyter.
 Giri, N. C. (2019). Introduction to probability and statistics. London: Routledge.
 Johnson, R. A., Miller, I., & Freund, J. E. (2019). Miller & Freunds probability and
statistics for engineers. Boston: Pearson Education.
 Laha, R. G., & Rohatgi, V. K. (2020). Probability theory. Mineola, NY: Dover
Publications.
 Mathai, A. M., & Haubold, H. J. (2018). Probability and statistics: A course for
physicists and engineers. Boston: De Gruyter.
 Pishro-Nik, H. (2014). Introduction to probability, statistics, and random processes. Blue
Bell, PA: Kappa Research, LLC.
 Spiegel, M. R., Schiller, J. J., & Srinivasan, R. A. (2013). Schaums outline of probability
and statistics. New York: McGraw-Hill.
SIMULATION CONCEPTS

1.0 Introduction
Real world phenomenon are very dynamic thus difficult to exactly predict. To make
decisions in such circumstances, we need a tool or verifiable procedures that guide
decision makers to an informed and provable decision and action. In this unit we will look
at one such tool; simulation which has become cornerstone to many probabilistic projects.

2.0 Main Content


2.8 What is Simulation?
The term simulation is used in different ways by different people. As used here,
simulation is defined as the process of creating a model (i.e., an abstract representation or
exact copy) of an existing or proposed system (e.g., a project, a business, a mine, a forest,
the organs in your body, etc.) in order to identify and understand those factors which
control the system and/or to predict (forecast) the future behaviour of the system. Almost
any system which can be quantitatively described using equations and/or rules can be
simulated.

The underlying purpose of simulation is to shed light on the underlying mechanisms that
control the behaviour of a system. More practically, simulation can be used to predict
(forecast) the future behaviour of a system, and determine what you can do to influence
that future behaviour. That is, simulation can be used to predict the way in which the
system will evolve and respond to its surroundings, so that you can identify any necessary
changes that will help make the system perform the way that you want it to.

For example, a fisheries biologist could dynamically simulate the salmon population in a
river in order to predict changes to the population, and quantitatively understand the
impacts on the salmon of possible actions (e.g., fishing, loss of habitat) to ensure that they
do not go extinct at some point in the future.
Also flight simulator on PC is also a computer model of some aspect of the flight; it shows
on the screen the controls and what the pilot is supposed to see from the ―cockpit‖ (his
armchair).

Simulation therefore, is a technique (not a method) for representing a dynamic real world
system by a model and experimenting with the model in order to gain information about
the system and hence take appropriate decision. Simulation can be done by hand or by a
computer.

Simulation is a powerful and important tool because it provides a way in which alternative
designs, plans and/or policies can be evaluated without having to experiment on a real
system, which may be prohibitively costly, time-consuming, or simply impractical to do.
That is, it allows you to ask "What if?" questions about a system without having to
experiment on the actual system itself (and hence incur the costs of field tests, prototypes,
etc.).

2.1 When to Use simulation


Simulation is used in systems that change with time, such as a gas station, where cars come
and go (called dynamic systems) and involve randomness. In such a system nobody can
guess at exactly which time the next car should arrive at the station. Modelling complex
dynamic systems theoretically need too many simplifications and the emerging models
may not therefore be valid. Simulation does not require many simplifying assumptions,
making it the only tool even in absence of randomness.
Simulation is used to observe the dynamic behaviour of a model of real or imaginary
system. Indeed, by simulating a complex system we are able to understand the behaviour at
low cost. Otherwise we would have to carry out a complicated theoretical research or to
build a device (an electric heater, a building or a plane), and observe how it changes to get
hints for improvements in the design.
If you run a shop, an hospital or a bank, then computer simulation may show you
bottlenecks, service time, flows, and queues of clients and provide important information
on how to improve your business.
Note that often we describe a real world system by:
1. A physical model
2. A mathematical or analytic model
3. An analogue model.

What happens when a system is not amenable to treatment using the above model?
Constructing a real physical system could be very expensive and what more testing it with
live human beings and observing what happens could be fatal. Training a new pilot using
an airplane is suicidal. This is why simulation is designed and utilized.
Thus simulation is the answer to our question. Many operations Research analysts consider
simulation to be a method of last resort. This is because it may be useful when other
approaches cannot be used, for example when a real world situation is complex. Note that
nothing prevents you from using simulation approach to analytic problem. Results can at
least be compared!
Thus, before designing and implementing a real life system, it is necessary to find out via
simulation studies whether the system will work otherwise the whole exercise will be a wild
goose chase. Inevitably huge sums of money might have been wasted.

Unlike the situation in mathematical programming, so far there are no clear cut underlying
principle guiding the formulation of simulation models. Each application is ad-hoc to a large
extent. In general there are three basic objectives of simulation studies:
1. To Describe a Current System – Suppose that a manufacturing company has suddenly
observed a marked deterioration in meeting due-dates of customers order. It may be
necessary to build a simulation model to see how the current procedures for
estimating due dates, scheduling production and ordering raw materials are giving
rise to observed delays.
2. To explore a Hypothetical System – such as installing a new system, which will cost a
lot of money, it might be better to build a hypothetical model of the system and learn
from its behaviour.
3. To Design an Improved System – for example consider a supermarket that has
onepayment counter. Due to increase in patronage, it is considering to increase
the number of pay points. A simulation experiment may identify if one, two or more
additional points are needed or not needed.

2.2 Types of Simulations


Computer models can be classified according to several criteria including:
 Stochastic or deterministic (and as a special case of deterministic, chaotic)
 Steady-state or dynamic
 Continuous or discrete (and as an important special case of discrete, discrete event or
DE models)
 Local or distributed.
For example:
 Steady-state models use equations defining the relationships between elements of the
modelled system and attempt to find a state in which the system is in equilibrium.
Such models are often used in simulating physical systems, as a simpler modelling
case before dynamic simulation is attempted.
 Dynamic simulations model changes in a system in response to (usually changing)
input signals.
 Stochastic models use random number generators to model the chance or random
events; they are also called Monte Carlo simulations.

There are two basic types of simulation for which models are built, and the process of
choosing the subset of characteristics or features is different for each. The distinction
between the two types is based on how time is represented; either as a continuous variable or
as a discrete variable.

2.2.1 Continuous simulation


Continuous simulations treat time as continuous and express changes in terms of a set of
differential equations that reflect the relationships among the set of characteristics. Thus the
characteristics or features chosen to model the system must be those whose behaviour is
understood mathematically.
Continuous simulation is used in systems where the state changes all the time, not just at the
time of some discrete events. For example, the water level in a reservoir due to in and
outflow changes all the time. In such cases continuous simulation is more appropriate,
although discrete events simulation can serve as an approximation.
A meteorological modelling falls is another example in this category. The characteristics of
weather models are wind components, temperature, water vapour, cloud formation,
precipitation, and so on. The interaction of these components over time can be modelled by a
set of partial differential equations, which measure the rate of change of each component
over some three-dimensional region.

A continuous dynamic simulation performs numerical solution of differential-algebraic


equations or differential equations (either partial or ordinary). Periodically, the simulation
program solves all the equations, and uses the numbers to change the state and output of the
simulation. Applications include flight simulators, racing-car games, chemical process
modelling, and simulations of electrical circuits. Originally, these kinds of simulations were
actually implemented on analog computers, where the differential equations could be
represented directly by various electrical components such as operational amplifiers. By the
late 1980s, however, most "analogue" simulations were run on conventional digital
computers that emulate the behaviour of an analog computer.
A typical Continuous (stochastic) system has a large number of control parameters that can
have a significant impact on the performance of the system. To establish a basic knowledge
of the behaviour of a system under variation of input parameters, sensitivity analysis is
usually performed, which applies small changes from one state to the nominal values of input
parameters. For such simulation, variations of the input parameter cannot be made infinitely
small. The sensitivity of the performance measure with respect to an input parameter is
therefore defined as (partial) derivative.
Sensitivity analysis is concerned with evaluating sensitivities (gradient) of performance
measures with respect to parameter of interest. It provides guidance for design and
operational decisions and plays a pivotal role in identifying the most significant system
parameters, as well as bottleneck of subsystems.
In designing, analysing and operating such complex systems, one is interested not only in
performance evaluation but also in sensitivity analysis and optimisation.

2.2.2 Discrete-event simulation,


Discrete event models are made up of entities, attributes, and events. An entity represents
some object in the real system that must be explicitly defined. That is, the characteristic or
feature of the system or an object. For example, if we were modelling a manufacturing plant,
the different machines, and the product being created, would be entities. An attribute is some
characteristic of a particular entity. The identification number, the purchase date, and the
maintenance history would be attributes of a particular machine. An event is an interaction
between entities. For example, the sending of the output from one machine as input to the
next machine would be an event.

Suppose we are interested in a gas station. We may describe the behaviour of this system
graphically by plotting the number of cars in the station; the state of the system. Every time a
car arrives the graph increases by one unit while a departing car causes the graph to drop by
one unit. This graph (called sample path), could be obtained from observation of real station,
but could also be artificially constructed. Such artificial construction and analysis of the
resulting sample path (or more sample paths in more complex cases) consists of the
simulation.

The path consists of only horizontal and vertical lines, as cars arrivals and departures
occurred, at distinct points in time, what we refer to as events. Between two consecutive
events, nothing happens – the graph is horizontal. When the number of events are finite, we
call the simulation discrete event.

Discrete event systems (DES) are dynamic systems, which evolve in time by the occurrence
of events at possible irregular time intervals. DES abound in real-world applications.
Examples include traffic systems, flexible manufacturing systems, computer communication
systems, production lines, flow networks etc. Most of these systems can be modelled in terms
of discrete events whose occurrence causes the system to change from one state to another.
Simulations may be performed manually. Most often, however, the system model is written
either as a computer program or as some kind of input into simulator software.

A discrete event simulation (DE) manages events in time. Most computer, logic-test and
fault-tree simulations are of this type. In this type of simulation, the simulator maintains a
queue of events sorted by the simulated time they should occur. The simulator reads the
queue and triggers new events as each event is processed. It is not important to execute the
simulation in real time. It's often more important to be able to access the data produced by
the simulation, to discover logic defects in the design, or the sequence of events.

A special type of discrete simulation which does not rely on a model with an underlying
equation, but can nonetheless be represented formally, is agent-based simulation. In agent-
based simulation, the individual entities (such as molecules, cells, trees or consumers) in the
model are represented directly (rather than by their density or concentration) and possess an
internal state and set of behaviours or rules which determine how the agent's state is updated
from one time-step to the next.

2.3 Steps In Constructing A Simulation Model.


2.3.1 Formulate the model (see modelling)
2.3.2 Design the Experiment – Workout details of experimental procedures
before runningthe model subsystems, parameters, relationships, data
structures, etc.
2.3.3 Develop the Computer Programs – Each historical evolution of the
model, includinggeneration of random events and generation of
objects, will take place within the computer. if a model has a simple
structure, you can use BASIC, FORTRAN, PASCAL or C and so
on to develop the computerized version. However, it is betterto use a
simulation language such as SIMULATIONSCRIPT, GPSS,
SIMULATIONULA (SIMULA), SIMULATIONNET (SIMNET)
II, QMS, etc.

2.3.1 To Extract the terms in Simulation


Let us consider building a simulation of gas station with a single pump served by a single
service man. Assumptions: arrival of cars as well as their times are random.
At first identify the:
State: number of cars waiting for service and number of cars served at any moment.
Event: arrival of cars, start of service, end of service.
Entities: these are the cars.
Queue: the queue of cars in front of the pump waiting for service.
Random realization: interval times, service times.
Distribution: we shall assume exponential distributions for the interval time and service time.

Next, specify what to do at each event. The above example would look like this:
At event of entity arrival: Create next arrival. If the server is free, send entity for start of
service. Otherwise it joins the queue. At event of service start: Server becomes occupied.
Schedule end of service for this entity. At event of service end: Server becomes free. If any
entity is waiting in the queue: remove the first entity from the queue; send it for start of
service.

Some initiation is still required, for example, the creation of the first arrival. Lastly, the
above is translated into code. This is easy with appropriate library function, which has
subroutine for creation, scheduling, proper timing of events, queue manipulations, random
variate generation and statistics collection.

2.3.2 Simulation terminologies:


State – A variable characterizing an attribute in the system such as level of stock in inventory
or number of jobs in waiting for processing.
Event: - An occurrence at a point in time which may change the state of the system, such as
arrival of a customer or start of work on a job.
Entity: An object that passes through the system, such as cars in an intersection or orders in
a factory. Often an event (e.g., arrival) is associated with an entity (e.g., customer).
Queue: A queue is not only a physical queue of people, or cars, etc it can also be a task list, a
buffer of finished goods waiting for transportation or any place where entities are waiting for
something to happen for any reason.
Creating: Is causing an arrival of new entity into the system at some point in time.
Scheduling: is the act of assigning a new future event to an existing entity. Random
variable: is a quantity that is uncertain, such as interval time between two incoming flights
or number of defectives parts in a shipment.
Random Variate: is an artificially generated random variable.
Distribution: is the mathematical law, which governs the probabilistic features of a random
variable.

2.4 Applications of Computer Simulation


Computer simulation has become a useful part of modelling many natural systems in
physics, chemistry and biology, and human systems in economics and social science (the
computational sociology) as well as in engineering to gain insight into the operation of those
systems. A good example of the usefulness of using computers to simulate can be found in
the field of network traffic simulation. In such simulations the model behaviour will change
each simulation according to the set of initial parameters assumed for the environment.
Computer simulations are often considered to be human out of the loop simulations.

Computer graphics can be used to display the results of a computer simulation. Animations
can be used to experience a simulation in real-time e.g. in training simulations. In some cases
animations may also be useful in faster than real-time or even slower than real-time modes.
For example, faster than real-time animations can be useful in visualizing the build up of
queues in the simulation of humans evacuating a building.
There are many different types of computer simulation; the common feature they all share is
the attempt to generate a sample of representative scenarios for a model in which a complete
enumeration of all possible states of the model would be prohibitive or impossible. Several
software packages also exist for running computer-based simulation modelling that makes
the modelling almost effortless and simple.

a. Simulation in computer science


In computer science, simulation has an even more specialized meaning: Alan Turing uses the
term "simulation" to refer to what happens when a digital computer runs a state transition
table (runs a program) that describes the state transitions, inputs and outputs of a subject
discrete-state machine. The computer simulates the subject machine.

In computer programming, a simulator is often used to execute a program that has to run on
some inconvenient type of computer, or in a tightly controlled testing environment For
example, simulators are usually used to debug a micro program or sometimes commercial
application programs. Since the operation of the computer is simulated, all of the information
about the computer's operation is directly available to the programmer, and the speed and
execution of the simulation can be varied at will.

Simulators may also be used to interpret fault trees, or test very large scale integration
(VLSI) logic designs before they are constructed. In theoretical computer science the term
simulation represents a relation between state transition systems.

b. Simulation in training
Simulation is often used in the training of civilian and military personnel. This usually occurs
when it is prohibitively expensive or simply too dangerous to allow trainees to use the real
equipment in the real world. In such situations they will spend time learning valuable lessons
in a "safe" virtual environment. Often the convenience is to permit mistakes during training
for a safety-critical system.
Training simulations typically come in one of three categories:
 live simulation (where real people use simulated (or "dummy") equipment in the real
world);
 virtual simulation (where real people use simulated equipment in a simulated world
(or "virtual environment")), or
 constructive simulation (where simulated people use simulated equipment in a
simulated environment). Constructive simulation is often referred to as "wargaming"
since it bears some resemblance to table-top war games in which players command
armies of soldiers and equipment which move around a board.

c. Simulation in Education
Simulations in education are somewhat like training simulations. They focus on specific
tasks. In the past, video has been used for teachers and students to observe, problem solve
and role play; however, a more recent use of simulation in education include animated
narrative vignettes (ANV). ANVs are cartoon-like video narratives of hypothetical and
reality-based stories involving classroom teaching and learning. ANVs have been used to
assess knowledge, problem solving skills and dispositions of children, and pre-service and in-
service teachers.

Another form of simulation has been finding favour in business education in recent years.
Business simulations that incorporate a dynamic model enable experimentation with business
strategies in a risk free environment and provide a useful extension to case study discussions.

d. Medical Simulators
Medical simulators are increasingly being developed and deployed to teach therapeutic and
diagnostic procedures as well as medical concepts and decision making to personnel in the
health professions. Simulators have been developed for training procedures ranging from the
basics such as blood draw, to laparoscopic surgery and trauma care.
Many medical simulators involve a computer connected to a plastic simulation of the
relevant anatomy. Sophisticated simulators of this type employ a life size mannequin which
responds to injected drugs and can be programmed to create simulations of life- threatening
emergencies. In others simulations, visual components of the procedure are reproduced by
computer graphics techniques, while touch-based components are reproduced by haptic
feedback devices combined with physical simulation routines computed in response to the
user's actions. Medical simulations of this sort will often use 3D CT or MRI scans of patient
data to enhance realism.
Another important medical application of a simulator -- although, perhaps, denoting a
slightly different meaning of simulator -- is the use of a placebo drug, a formulation which
simulates the active drug in trials of drug efficacy.

e. City Simulators / Urban Simulation


A City Simulator is a tool used by urban planners to understand how cities are likely to
evolve in response to various policy decisions. UrbanSim. The City Simulator developed at
the University of Washington and ILUTE developed at the University of Toronto are
examples of modern, large-scale urban simulators designed for use by urban planners. City
simulators are generally agent-based simulations with explicit representations for land use
and transportation.
f. Flight simulators
A flight simulator is used to train pilots on the ground. It permits a pilot to crash his
simulated "aircraft" without being hurt. Flight simulators are often used to train pilots to
operate aircraft in extremely hazardous situations, such as landings with no engines, or
complete electrical or hydraulic failures. The most advanced simulators have high-fidelity
visual systems and hydraulic motion systems. The simulator is normally cheaper to operate
than a real trainer aircraft.

g. Marine simulators
This bears resemblance to flight simulators. The marine simulators are used to train ship
personnel. Simulators like these are mostly used to simulate large or complex vessels, such as
cruise ships and dredging ships. They often consist of a replication of a ships' bridge, with
operating desk(s), and a number of screens on which the virtual surroundings are projected.

Simulation in Engineering (Technology) Process


Simulation is an important feature in engineering systems or any system that involves many
processes. For example in electrical engineering, delay lines may be used to simulate
propagation delay and phase shift caused by an actual transmission line. Similarly, dummy
loads may be used to simulate impedance without simulating propagation, and is used in
situations where propagation is unwanted. A simulator may imitate only a few of the
operations and functions of the unit it simulates. Contrast with: emulate.

Most engineering simulations entail mathematical modelling and computer assisted


investigation. There are many cases, however, where mathematical modelling is not reliable.
Simulation of fluid dynamics problems often requires both mathematical and physical
simulations. In these cases the physical models require dynamic similitude. Physical and
chemical simulations have also direct realistic uses, rather than research uses; in chemical
engineering, for example, process simulations are used to give the process parameters
immediately used for operating chemical plants, such as oil refineries.

Discrete Event Simulation is often used in industrial engineering, operations management


and operational research to model many systems (commerce, health, defence, manufacturing,
logistics, etc.); for example, the value-adding transformation processes in businesses, to
optimize business performance. Imagine a business, where each person could do 30 tasks,
where thousands of products or services involved dozens of tasks in a sequence, where
customer demand varied seasonally and forecasting was inaccurate- this is the domain where
such simulation helps with business decisions across all functions.

h. Simulation and games


Strategy games - both traditional and modern - may be viewed as simulations of abstracted
decision-making for the purpose of training military and political leaders. In a narrower
sense, many video games are also simulators, implemented inexpensively. These are
sometimes called "sim games". Such games can simulate various aspects of reality, from
economics to piloting vehicles, such as flight simulators (described above).

i. The "classroom of the future"


The "classroom of the future" will probably contain several kinds of simulators, in addition
to textual and visual learning tools. This will allow students to enter school better prepared,
and with a higher skill level. The advanced student or postgraduate will have a more concise
and comprehensive method of retraining -- or of incorporating new academic contents into
their skill set -- and regulatory bodies and institution managers will find it easier to assess the
proficiency and competence of individuals.

In classrooms of the future, the simulator will be more than a "living" textbook; it will
become an integral a part of the practice of Education and training. The simulator
environment will also provide a standard platform for curriculum development in educational
institutions.

2.5 Model Evaluation


An important part of the modelling process is the evaluation of an acquired model. How do
we know if a mathematical model describes the system well? This is not an easy question to
answer. Usually the engineer has a set of measurements from the system which are used in
creating the model. Then, if the model was built well, the model will adequately show the
relations between system variables for the measurements at hand. The question then
becomes: How do we know that the measurement data are a representative set of possible
values? Does the model describe well the properties of the system between the measurement
data (interpolation)? Does the model describe well events outside the measurement data
(extrapolation)?

A common approach is to split the measured data into two parts; training data and
verification data. The training data are used to train the model, that is, to estimate the model
parameters (see above). The verification data are used to evaluate model performance.
Assuming that the training data and verification data are not the same, we can assume that if
the model describes the verification data well, then the model describes the real system well.

However, this still leaves the extrapolation question open. How well does this model
describe events outside the measured data? Consider again Newtonian classical mechanics-
model. Newton made his measurements without advanced equipment, so he could not
measure properties of particles travelling at speeds close to the speed of light. Likewise, he
did not measure the movements of molecules and other small particles, but macro particles
only. It is then not surprising that his model does not extrapolate well into these domains,
even though his model is quite sufficient for ordinary life physics.

The reliability and the trust people put in computer simulations depends on the validity of the
simulation model, therefore verification and validation are of crucial importance in the
development of computer simulations. Another important aspect of computer simulations is
that of reproducibility of the results, meaning that a simulation model should not provide a
different answer for each execution. Although this might seem obvious, this is a special point
of attention in stochastic simulations, where random numbers should actually be semi-
random numbers. An exception to reproducibility are human in the loop simulations such as
flight simulations and computer games. Here a human is part of the simulation and thus
influences the outcome in a way that is hard if not impossible to reproduce exactly.

Case Studies
Operations study to add a new plane arrival at La Guardia southwest terminal
LaGuardia airport planned to add a new flight to the schedule of the southwest terminal. The
airport administration wanted to understand how the introduction of a new flight would
influence terminal capacity.
Problem
In order to understand the scale of the problem, the developers conducted a preliminary static
pedestrian flow analysis based on data of how long before the flight passengers arrived at the
airport. In the picture, the solid line represented the number of seats in the waiting area, the
red stacks represented the number of passengers in the terminal before introducing the new
flight, and additional passengers from the new flight were represented by purple areas. The
graph showed that if the new plane took off in the afternoon at 5:00 pm, the already crowded
waiting area would have to bear an additional burden that could lead to a significant problem.
The developers used the AnyLogic Pedestrian Library to create a crowd simulation model of
the terminal in order to examine the use of seats under different scenarios. The basic model
displayed the operation of all terminal areas before the introduction of the new flight, and
then various assumptions could be checked against this model. The best situation was when
people were waiting for departure at their gates, but the consultants wanted to check how far
they would have to move away from their gates to wait for their departure.
To set up the crowd simulation model, the developers used tables of passenger preference for
waiting areas.
The model showed how far from their gate people would have to wait. The results of
modeling the base scenario, without the new flight, showed that some of the peaks were
reduced compared with the static analysis. This was due to passengers lining up 30 minutes
before their flights. The model also showed where the people would actually wait. From this,
it could be verified that there was no overflow and that the situation was stable.
In the afternoon, the waiting area was a lot more heavily utilized. There were a lot of
passengers mixing in different areas and waiting for different gates. With the new flight at
this peak time, some of these areas would get extremely overloaded. This pedestrian
simulation was very useful in showing the operations of this terminal and how adding the
new flight would affect the passengers in this area, including how far they would have to
move to wait for their flights.
Solution
Designing large transport facilities requires careful consideration and agreement on every
detail. That means that such projects must go through a great deal of decision making. The
initial task of engineers usually produces alternatives and functional designs. These consider
physical requirements and standards, but whether business or operating objectives will be met
can be hard to determine accurately. It is here that AnyLogic based modeling helps by
enabling faster decision-making and significantly improving insight into the various tasks
that engineers face when planning large transport facilities.

4.0 4.0 Self-Assessment Exercise(s)


Answer the following questions:
 What are the objectives of simulation?
 In one sentence for each distinguish between different types of simulation
 Briefly describe simulation in five application areas.

2.6 Conclusion
Simulation is used to shed light on the underlying mechanisms that control the behaviour of a
system. It can be used to predict (forecast) the future behaviour of a system, and determine
what you can do to influence that future behaviour. We simulation when we require
information to solve bottlenecks, service time, flows, and queues of clients and provide
important information on how to improve your business.

We simulate when a system is not amenable to treatment using any of the physical model,
mathematical or analogue models. Other reasons to resort to simulation include when it is
very expensive to construct a real physical system and what more testing it with live human
beings and observing what happens could be fatal. Training a new pilot using an airplane is
suicidal. These are where and when simulations are designed and utilized.

2.7 Summary
In this unit we:
 defined simulation as the process of creating a model (i.e., an abstract representation
or exact copy) of an existing or proposed system (e.g., a project, a business, a mine, a
forest, the organs in your body, etc.) in order to identify and understand those factors
which control the system and/or to predict (forecast) the future behaviour of the
system.
 Stated that simulation is required when a system is not amenable to treatment using
any existing model or when it is very expensive to construct a real physical system or
when testing it with live human beings could be fatal.
 classified simulation into:
o Stochastic or deterministic (and as a special case of deterministic, chaotic)
o Steady-state or dynamic
o Continuous or discrete (and as an important special case of discrete, discrete
event or DE models)
o Local or distributed
 Stated that simulations are done by: Formulating the model, Design the Experiment
and Developing the Computer Programs.
 Listed areas of applications of Simulation to include: Computer science, Medicine,
Education, City/Urban planning, Training etc.

Further Readings
 Gordon, S. I., & Guilfoos, B. (2017). Introduction to Modeling and Simulation with
MATLAB® and Python. Milton: CRC Press.
 Zeigler, B. P., Muzy, A., & Kofman, E. (2019). Theory of modeling and simulation:
Discrete event and iterative system computational foundations. San Diego (Calif.):
Academic Press.
 Kluever, C. A. (2020). Dynamic systems modeling, simulation, and control. Hoboken,
N.J: John Wiley & Sons.
 Law, A. M. (2015). Simulation modeling and analysis. New York: McGraw-Hill.
 Verschuuren, G. M., & Travise, S. (2016). 100 Excel Simulations: Using Excel to Model
Risk, Investments, Genetics, Growth, Gambling and Monte Carlo Analysis. Holy
Macro! Books.
 Grigoryev, I. (2015). AnyLogic 6 in three days: A quick course in simulation modeling.
Hampton, NJ: AnyLogic North America.
 Dimotikalis, I., Skiadas, C., & Skiadas, C. H. (2011). Chaos theory: Modeling, simulation
and applications: Selected papers from the 3rd Cghaotic Modeling and Simulation
International Conference (CHAOS2010), Chania, Crete, Greece, 1-4 June, 2010.
Singapore: World Scientific.
 Velten, K. (2010). Mathematical modeling and simulation: Introduction for scientists and
engineers. Weinheim: Wiley-VCH.
Random Numbers

1.0 Introduction
The use of Random numbers lies at the foundation of modelling and simulations.
Computer applications such as simulations, games, graphics, etc., often need the ability to
generate random numbers for such application.

The quality of a random number generator is proportional to its period, or the number of
random numbers it can produce before a repeating pattern sets in. In large-scale
simulations, different algorithms (called shift-register and lagged-Fibonacci) can be used,
although these also have some drawbacks, combining two different types of generators
may produce the best results.

2.0 Main Content

Random Number can be defined as numbers that show no consistent pattern, with each
number in a series and are neither affected in any way by the preceding number, nor
predictable from it.
One way to get random digits is to simply start with an arbitrary number with a specified
number of digits, for example 4 digits. The first number is called the seed. The seed is
multiplied by a constant number of the same number of digits(length), and the desired
number of digits is taken off the right end of the product. The result becomes the new seed. It
is again multiplied by the original constant to generate a new product, and the process is
repeated as often as desired. The result is a series of digits that appear randomly distributed
as though generated by throwing a die or spinning a wheel. This type of algorithm is called a
congruential generator.

Generating a random number series from a single seed works fine with most simulations that
rely upon generating random events under the control of probabilities (Monte Carlo
simulations). However, although the sequence of numbers generated from a given seed is
randomly distributed, it is always the same series of numbers for the same seed. Thus, a
computer poker game that simply used a given seed would always generate the same hands
for each player.

What is needed is a large collection of potential seeds from which one can be more or less
randomly chosen. If there are enough possible seeds, the odds of ever getting the same series
of numbers become diminishingly small.

One way to do this is to read the time (and perhaps date) from the computer‘s system clock
and generate a seed based on that value. Since the clock value is in milliseconds, there are
millions of possible values to choose from. Another common technique is to use the interval
between the user‘s keystrokes (in milliseconds). Although they are not perfect, these
techniques are quite adequate for games.
The so-called true random number generators extract random numbers from physical
phenomena such as a radioactive source or even atmospheric noise as detected by a radio
receiver.

3.0 Pseudorandom Number Generation


In this section we look at how random numbers may be generated by human beings for use in
simulating a system or by computer for use while simulating an event.

What we usually do is to take for instance ten pieces of papers and number them
0,1,2,3,4,5,6,7,8, and 9 , fold and place them in a box. Shake the box and thoroughly mix the
slips of paper. Select a slip; then record the number that is on it. Replace the slip and repeat
this procedure over and over. The resultant record of digits is a realized sequence of random
numbers. Assuming you thoroughly mix the slips before every draw, the nth digit of the
sequence has an equal or uniform chance of being any of the digits 0, 1, 2,3,4,5,6,7,8, 9
irrespective of all the preceding digits in the recorded sequence.

In some simulations, we use random numbers that are between 0 and 1. For example, if you
need such numbers with four decimal digits, then you can take four at a time from the
recorded sequence of random digits, and place a decimal point in front of each group of
four. To illustrate, if the sequence of digits is 358083429261… then the four decimal placed
random numbers are .3580, .8342, and .9261.

3.1 Random Numbers in Computer


How does computer generate a sequence of random numbers?
One way is to perform the above ―slip-in-a-box‖ experiment and then store the recorded
sequence in a computer-backing store.
The RAND Corporation using specially designed electronic equipment, to perform the
experiment, actually did generate a table of a million random digits. The table can be
obtained on tape, so that blocks of the numbers can be read into the memory of a high- speed
computer, as they are needed. Their approach is disadvantageous since considerable
computer time was expended in the delays of reading numbers into memory from a tape
drive.

Experts in computer science have devised mathematical processes for generating digits that
yield sequences satisfying many of the statistical properties of a truly random process. To
illustrate, if you examine a long sequence of digits produced by deterministic formulas, each
digit will occur with nearly the same frequency, odd numbers will be followed by even
numbers about as often as by odd numbers, different pairs of numbers occur with nearly the
same frequency, etc. Since such a process is not really random, it is called pseudo-random
number generator.

The other ways of generating pseudo-random numbers are:


1. Computer simulation languages and indeed some programming languages such as
R/MATLAB have built-in pseudo-random number generators. In computer
simulation situations where this facility is not available in the language you are using,
you will have to write you own pseudo-random number generator (see how to do this
later).
2. The results of experiments such as the one previously describe above are published in
books of statistical tables. In hand simulation, it may be appropriate to use a
published table of random numbers.
3. The conventional six-sided unbiased die may also be used to generate a sequence of
random digits in the set (1, 2, 3, 4, 5, 6) where each digit has a probability 1/6 of
occurrence.

Exercise
Suggest one or two experimental set-ups (analogous to the slip-in-a-box approach) for
generating uniform random digits.

3.2 Using the RND Function in BASIC


The BASIC programming language has a numeric function named RND, which generates
random numbers between 0 and 1. Each time RND is executed, a pseudo random number
between 0 and 1 is generated. Using RND function at any time will always generate the same
sequence of pseudo random numbers unless we vary the random number seed using the
BASIC statement:

RANDOMIZE

This way, we can control the sequence of random numbers generated. RANDOMIZE will
result to the following prompt on the VDU:

Random Number Seed (-32768 to 32767)?

Suppose your response to the above prompt is 100. Then the computer would use this
number, 100, to generate the first random number. This number generated is used to generate
the next random number. Thus by specifying the seed for the first random number, we are in
a way controlling all random numbers that will be generated until the seed is reset. A control
such as this can be very useful in validating a simulation program or other computer
programs that use random numbers.
Consider the following BASIC program:
FOR K% = 1 TO 5
PRINT RND NEXT K%
END

If the above program is run, some seven-digit decimal numbers like the following will be
displayed: .6291626, .1948297, .6305799, .8625749, .736353. The particular
digits displayed depend on the system time.

Every time you run the above program, different sequence of numbers will be displayed.
Now add a RANDOMIZE statement to the program:

RANDOMIZE TIMER FOR K% = 1 TO 5


PRINT RND NEXT K%
END

If you run this program with 300 as a response to the prompt for the random number seed,
the following may be displayed: .1851404, .9877729, .806621, .8573399,
.6208935
Exercise
Find out whether the same set of random numbers will be displayed each time the above
program is run with seed 300.

3.3 Simulating Randomness


Suppose we want to simulate the throwing of a fair die. A random number between 0 and 1
will not always satisfy our needs. If the die is fair, throwing it several times will yield a series
of uniformly distributed integers 1,2,3,4,5 and 6. Consequently we need to be able to
generate a random integer with values in the range 1 and 6 inclusive.

Now the function RND generates a random number between 0 and 1. Specifically, the
random variable X is in the range: 0 < X < 1
The expression X = RND *6
Will generate a number in the range: 0 < X < 6
We must convert these numbers to integers as follows: X% = INT (RND*6)
The expression produces an integer in the range: 0<X<5

But we need the range: 0<X<6

Therefore if we need to add 1 to the above expression in simulating the tossing of a die.
Thus,

X% = INT (RND*6) + 1
In general, to generate a random integer between P and N we use the expression:
INT(RND*N+1-P) + P;
where N>P

While for integer number between 0 and N – 1 we use the expression INT (RND *N).

Example 1
A simple QBASIC program that will stimulate the tossing of two dice and display the value
obtained after each toss, and the total value of the dice is shown below.

CLS
REM DI and D2 represent the individual dice. RANDOMIZE
DO
D1% = INT(RND*6) + 1
D2% = INT(RND*6) + 1
TOTAL% = D1% + D2%
PRINT ―Die 1:‖; D1%; ―Die 2:‖; D2%
PRINT: PRINT
INPUT ―Toss Again (Y/N)?‖, Y$
LOOP UNTIL UCASE$(Y$) = ―N‖

END

Exercise
Run the program of example 1several times using different random number seeds to determine if the
integers generated for the individual die are uniformly distributed between 1and 6 inclusive.

If we want the computer to be generating the random number seed automatically, we use
RANDOMIZE TIMER

In place of RANDOMIZE.

Example 2
Another QBASIC program to simulate the tossing of a fair coin 10 times. The program
displays a H when a head appears and a T when a tail appears.

CLS
REM Program to simulate the tossing of a coin 10 times
REM and print the outcome
RANDOMIZE TIMER
FOR K% = 1 TO 10
RANDNO = RND
IF RANDNO <= 0.5 PRINT ―H‖
IF RANDNO > 0.5
PRINT ―T‖
NEXT K%
END

Example 3
Suppose the output of the program of example 3 is: HHTHHTTTHH
and that there are two players X and Y involved in the tossing of the coin. Given that player
X wins N50.00 from player Y if a head appears and loses it to player Y if a tail appears.
Determine who won the game and by how much.

Solution
From the output there are 6 heads and 4 tails.
Player X wins N50.00 x 6 = N300.00 from player Y. He loses N50.00 x 4 = N200.00 to
player Y.
Thus, player X won the game with N300.00 – N200.00 = N100.00.

3.4 Properties of a Good Random Number Generator


The random numbers generated should;
a. have as nearly as possible a uniform distribution.
b. should be fast
c. not require large amounts of memory.
d. have a long period.
e. be able to generate a different set of random numbers or a series of numbers.
f. not degenerate.

4.0 4.0 Self-Assessment Exercise(s)


Write a QBASIC program to generate thirty random integer numbers distributed between 20
and 50. Your program should ensure that no number is repeated.
Write a QBASIC program to accept a set of characters from the keyboard and then move the
characters randomly across the screen. The movement of the characters should stop once a
key is pressed on the keyboard. The set of characters should also change colors randomly at
the point of the movement.
What is a seed and explain how you can generate random numbers using a seed.
Define a period and state how to improve a period.

5.0 Conclusion
In this unit, you have been introduced to Random Numbers generation. You have also learnt
the how to manipulate the RND function of QBASIC.

6.0 Summary
What you have learnt in this unit concern:
 The different ways of generating pseudorandom numbers,
 The properties of good random number generator.
 The use of QBasic RND function to simulate randomness,
 The other Random number generating methods,

7.0 Further Readings


 Devore, J. L. (2018). Probability and statistics for engineering and the sciences. Toronto,
Ontario: Nelson.
 Georgii, H. (2013). Stochastics: Introduction to probability and statistics. Berlin: De
Gruyter.
 Giri, N. C. (2019). Introduction to probability and statistics. London: Routledge.
 Johnson, R. A., Miller, I., & Freund, J. E. (2019). Miller & Freunds probability and
statistics for engineers. Boston: Pearson Education.
 Laha, R. G., & Rohatgi, V. K. (2020). Probability theory. Mineola, NY: Dover
Publications.
 Mathai, A. M., & Haubold, H. J. (2018). Probability and statistics: A course for
physicists and engineers. Boston: De Gruyter.
 Pishro-Nik, H. (2014). Introduction to probability, statistics, and random processes. Blue
Bell, PA: Kappa Research, LLC.
 Spiegel, M. R., Schiller, J. J., & Srinivasan, R. A. (2013). Schaums outline of probability
and statistics. New York: McGraw-Hill.

23
Unit 3: Congruential Random Number Generator

Contents
1.0 Introduction
2.0 Intended Learning Outcomes (ILOs)
3.0 Main Content
3.1 The Congreuential Method
3.2 Choice of a, c and m
3.3 RANECU Random Number Generator
3.4 Other Methods of Generating Random Numbers
3.4.1 Quadratic Congruential Method,
3.4.2 Mid-square method,
3.4.3 Mid-product Method
3.4.4 Fibonnachi Method
4.0 Self-Assessment Exercise(s)
5.0 Conclusion
6.0 Summary
7.0 Further Readings

1.0 Introduction
As has been stated earlier, if you want to write a simulation program and you neither have
a simulation language at your disposal nor a programming language with a random number
generating function, you must design and write a random number generating function and
call it whenever you need it.
Classical uniform random number generators have some major defects, such as, short
period length and lack of higher dimension uniformity. However, nowadays there are a
class of rather complex random number generators which are as efficient as the classical
generators which enjoy the property of a much longer period and of higher dimension
uniformity.

2.0 Intended Learning Outcomes (ILOs)


By the end of this unit, the reader should be able to:
 Explain the use Congruential method for generating Random numbers;
 Choose appropriate parameters for congruential method;
 Translate the method to computer programs;
 Use other very similar random number generating methods such as: Mid square, Mid
product, Fibonacci

24
3.0 Main Content
3.1 The Congruential Method
The Congruential Method is widely used. The method is based on modulus arithmetic,
which we now discuss briefly.
We say that two numbers x and y are congruent modulo m if (x-y) is an integral multiple
of m. Thus we can write: x = y(modulo m)
For example, let m = 10, then we can write:
13 ≡ 3 (modulo 10)
84 ≡ 4 (modulo 10)

The congruential method generates random numbers by computing the next random
number from the last random number obtained, given an initial random number say, X0,
called the seed.

The method uses the formula:


Xn+1 = (aXn + c)(modulo m) where X0 = Seed and; a, c < m,
Where a, c and m are carefully chosen positive integer constants of which a and c must be
less than m, X0 is the seed or the last random number generated in the sequence. Stated in
the computer language, the above formula becomes:

X (N+ 1) = (A* X (N) + C) MOD M (FORTRAN)


or
R = (A* SEED + C) MOD M (QBASIC)

From the above formula, it follows that the random number generated must be between 0
and (m-1) since MOD (modulo) produces remainder after division. Hence the above
formula will produce the remainder after dividing (aXn + C ) by m. So to generate a
random number between p and m we use:

Xn+1= (aXn + C)(modulo m + 1-p) + p, for m > p.

If the value of c is zero, the congruential method is termed Multiplicative Congruential


Method. If the value of c is not zero, the method is called Mixed Congruential Method.

The multiplicative congruential method is very handy. It is obtained using the general
formula:

rn = arn-1 (modulo m) Xn+1=aXn (MOD m)

where the parameters a, m and the seed r0 are specified to give desirable statistical
properties of the resultant sequence. By virtue of modulo arithmetic, each rn must be one of
the numbers 0,1,2,3… m-1. Clearly, you must be careful about the choice of a and r0. The

25
values of ‗a‘ and r0 should be chosen to yield the largest cycle or period, that is to give the
largest value for n at which rn = r0 for the first time.

Example 4
To illustrate the technique, suppose you want to generate ten decimal place numbers u1,
u2, u3,…. It can be shown that if you use
un = rn x 10-1
where rn = 100003rn-1 (modulo 1010), and r0 = any odd number not divisible by 5,
then the period of the sequence will be 5 x 108, that is rn = r0 for the first time at n = 5 x
108 and the cycle subsequently repeats itself. 3650721436

As an example, using our mixed congruential formula


Xn+1 = (aXn+c) (modulo m),
And suppose m = 8, a = 5, c = 7 and X0 (seed) = 4 we can generate a random sequence of
integer numbers thus:

n Xn+1 = (5Xn+7)mod 8
0 X1 = (5*X0+7)mod 8 = (5*X4+7)mod 8 = 27 mod 8 = 3
1 X2 = (5*X1+7)mod 8 = (5*X3+7)mod 8 = 22 mod 8 = 6
2 X3 = (5*X2+7)mod 8 = (5*X6+7)mod 8 = 37 mod 8 = 5
3 X4 = (5*X3+7)mod 8 = (5*X5+7)mod 8 = 32 mod 8 = 0
4 X5 = (5*X4+7)mod 8 = (5*X0+7)mod 8 = 7 mod 8 = 7
5 X6 = (5*X5+7)mod 8 = (5*X7+7)mod 8 = 42 mod 8 = 2
6 X7 = (5*X6+7)mod 8 = (5*X2+7)mod 8 = 17 mod 8 = 1
7 X8 = (5*X7+7)mod 8 = (5*X1+7)mod 8 = 12 mod 8 = 4

Note that the value of X8 is 4, which is the value of the seed X0. So if we compute X9, X10,
etc the same random numbers 3,6,5,0,7,2,1,4 will be generated once more.

Note also that if we divide the random integer values by 8, we obtain random numbers in
the range 0 < Xn+1 < 1 which is similar to using the RND function of BASIC.

3.1 Choice of a, c and m


The method of this random number generation by linear congruential method, works by
computing each successive random number from the previous. Starting with a seed, Xo,
the linear congruential method uses the following formula:

Xi+1 = (A*Xi + C) mod M

In his book, The Art of Computer Programming, Donald Knuth presents several rules for
maximizing the length of time before the random number generator comes up with the
same value as the seed. This is desirable because once the random number generator comes
up with the initial seed, it will start to repeat the same sequence of random numbers (which

26
will not be so random since the second time around we can predict what they will be).
According to Knuth's rules, if M is prime, we can let C be 0.
The LCM defined above has full period if and only if the following conditions are
satisfied:
a) m and c are relatively prime
b) If q is a prime number that divides m , then q divides a-1
c) If 4 divides m, then 4 divides a-1

Therefore, the values for a, c and m are not generated randomly, rather they are carefully
chosen based on certain considerations. For a binary computer with a word length of r bits,
the normal choice for m is m = 2r-1. With this choice of m, a can assume any of the values
1, 5,9,13, and c can assume any of the values 1, 3, 5, 7… However, experience shows that
the congruential method works out very well if the value of a is an odd integer not divisible
by either 3 or 5 and c chosen such that c mod 8 = 5 (for a binary computer) or c mod 200 =
21 (for a decimal computer).

Example 5
Develop a function procedure called RAND in QBASIC which generates a random number
between 0 and 1 using the mixed congruential method. Assume a 16-bit computer.

Solution
FUNCTION RAND (SEED)
CONST M = 32767, A = 2743, C = 5923
IF SEED < 0 THEN SEED = SEED + M
SEED = (A* SEED + C) MOD M
RAND = SEED/M
END FUNCTION

Note that in the main program that references the above function in (a), the TIMER function
can be used to generate the SEED to be passed to the function RAND as illustrated in
example 2.

Example 5
Write a program that can generate that can generate 20 random integer number distributed
between 1 and 64 inclusive using mixed congruential method.

Solution
QBASIC

DECLARE RAND (X)


CLS: REM Mixed Congruential Method
DIM SHARED SEED
SEED = TIMER
FOR K% = 1 TO 20

27
SEED = RAND (SEED) ‗Call of function RAND PRINT SEED: SPC(2)
NEXT K%
END ‗End of main program

FUNCTION RAND (SEED) ‗Beginning of function subprogram


CONST M = 64 A = 27, C = 13
IF SEED = THEN SEED = SEED + M
SEED = (a* SEED + C) MOD M + 1
RAND = SEED
END FUNCTION ‗End of the function program RAND

(b) Using FORTRAN

PROGRAM RANDNUM
COMMON SEED
CLS ‗Clear screen
DO 50 K = 1, 25
WRITE (*, 5)
FORMAT(/)
50 CONTINUE
WRITE(*,*) ‗Enter the seed‘
READ(*,*) SEED
DO 30 J = 1, 20
SEED = RAND
WRITE (*, 6) SEED
6 FORMAT (I4)
30 CONTINUE
END

FUNCTION RAND
COMMON SEED
PARAMETER (M = 64, A = 27, C =13)
IF (SEED.LT.0) SEED = SEED + M
HOLD = (A*SEED + C)
SEED = AMOD (HOLD,M) + 1
RAND = SEED
RETURN END

3.3 RANECU Random Number Generator


A FORTRAN code for generating uniform random numbers on [0,1]. RANECU is
multiplicative linear congruential generator suitable for a 16-bit platform. It combines three
simple generators, and has a period exceeding 81012.
It is constructed for more efficient use by providing for a sequence of such numbers
(Length), to be returned in a single call. A set of three non-zero integer seeds can be supplied,

28
failing which a default set is employed. If supplied, these three seeds, in order, should lie in
the ranges [1,32362], [1,31726] and [1,31656] respectively. The program is given below.

SUBROUTINE RANECU (RVEC,LEN)


C Portable random number generator for 16 bit computer.
C Generates a sequence of LEN pseudo-random numbers, returned
C in RVEC.
DIMENSION RVEC(*)
SAVE ISEED1,ISEED2, ISEED3
DATA ISEED1,ISEED2,ISEED3/1234, 5678, 9876/
C Default values, used if none is suppliednvia an ENTRY
C call at RECUIN
DO 100 I = 1,LEN
K=ISEED1/206
ISEED1 = 157 * (ISEED1 - K * 206) - K * 21
IF(ISEED1.LT.0) ISEED1=ISEED1+32363
K=ISEED2/217
ISEED2 = 146 * (ISEED2 - K*217) - K* 45
IF(ISEED2.LT.O) ISEED2=ISEED2+31727
K=ISEED3/222
ISEED3 = 142 * (ISEED3 - K *222) - K * 133
IF(ISEED3.LT.0) ISEED3=ISEED3+31657
IZ=ISEED1-ISEED2
IF(IZ.GT.706)IZ = Z - 32362 IZ = 1Z+ISEED3
IF(IZ.LT.1)IZ = 1Z + 32362
RVEC(I)=REAL(IZ) * 3.0899E – 5
100 CONTINUE
RETURN
ENTRY RECUIN(IS1, IS2, IS3)
ISEED1=IS1
ISEED2=IS2
ISEED3=IS3
RETURN
ENTRY RECUUT(IS1,IS2,IS3)
IS1=ISEED1
IS2=ISEED2
IS3=ISEED3
RETURN
END

3.4 Other Methods of Generating Random Numbers


Some other methods of generating random numbers are Quadratic Congruential Method,
Mid-square method, Mid-product Method and Fibonnachi Method.

29
3.4.1 The Quadratic congruential method
This method uses the formula:
Xn=1 = (dX 2 + cX + a) modulo mn n

Where d is chosen in the same way as c and m should be a power of 2 for the method to yield
satisfactory results.

3.4.2 The Mid-square method


The first random number is generated from the seed by squaring the seed and discarding all
the digits except the middle four digits. This number is subsequently used as the new seed to
generate the next random number in the same manner and so on.
The formula is: Xn+1 = X 2 n
The mid-square method is rarely used these days as it has the tendency to degenerate rapidly.
Also, if the number zero is ever generated, then all subsequent numbers generated will be
zero. Furthermore, the method is slow when simulated in the computer since many
multiplications and divisions are required to access the middle four digits.

3.4.3 The mid-product method


This method is similar to the mid-square method, except that a successive random number is
obtained by multiplying the current number by a constant c, and taking the middle digits.
The formula is: Xn+1 = cXn
The mid-product method has a longer period and it is more uniformly distributed than the
mid-square method.

3.4.4 The Fibonacci method


Fibonacci method uses the formula: Xn+1 = (Xn + Xn-1) modulo m
In this method, two initial seeds need to be provided. However, experience has shown that
the random numbers generated by using Fibonacci method fail to pass tests for randomness.
Therefore, the method does not give satisfactory results.
From the foregoing discussions, it is obvious that the last three methods – mid-square, mid-
product and Fibonacci are of historical significance and have detrimental and limiting
characteristics.

4.0 4.0 Self-Assessment Exercise(s)

1. Write a QBASIC program using Quadratic congruential method to generate 15


random integer numbers between 1 and 50.
2. Produce a table of random numbers using multiplicative congruential method, using a
=5, m =8 and X0 = 4. Draw an inference from your solution.
3. Write a QBASIC function that can be referenced as computer random number
between 30 and 100 using mixed congruential method.
4. Use the mixed congruential method to generate the following sequences of random
numbers:

30
a. A sequence of 10 one-digit random numbers given that
Xn+1 ≡ (Xn + 3)(modulo 10) and X0 = 2
b. A sequence of eight random numbers between 0 and 7 given that
Xn+1 ≡ (5Xn + 1)(modulo 8) and X0 = 4
c. A sequence of two-digit random numbers such that
Xn+1 ≡ (61Xn + 27)(modulo 100) and X0 = 40
d. A sequence of five-digit random numbers such that
Xn+1 ≡ (21Xn + 53)(modulo 100) and X0 = 33
5. Define a methods period and state how to improve a period. Show two examples of
such improvement.
6. Consider the multiplicative congruential method for generating random digits. In
each part below, assume modulo 10 arithmetic and determine the length of the
cycle:
a. Let a = 2 and r0 = 1, 3 and 5
b. Let a = 3 and r0 = 1,2 and 5

5.0 Conclusion
In this unit, you have been introduced to Random Numbers generation. You have also
learnt how to design random number generator.

6.0 Summary
What you have learnt in this unit concern:
 The Congruential methods of generating random numbers,
 The use of QBasic RND function to simulate randomness,
 The other Random number generating methods,
 The properties of good random number generator.

7.0 Further Readings


 Devore, J. L. (2018). Probability and statistics for engineering and the sciences. Toronto,
Ontario: Nelson.
 Georgii, H. (2013). Stochastics: Introduction to probability and statistics. Berlin: De
Gruyter.
 Giri, N. C. (2019). Introduction to probability and statistics. London: Routledge.
 Johnson, R. A., Miller, I., & Freund, J. E. (2019). Miller & Freunds probability and
statistics for engineers. Boston: Pearson Education.
 Laha, R. G., & Rohatgi, V. K. (2020). Probability theory. Mineola, NY: Dover
Publications.
 Mathai, A. M., & Haubold, H. J. (2018). Probability and statistics: A course for
physicists and engineers. Boston: De Gruyter.

31
 Pishro-Nik, H. (2014). Introduction to probability, statistics, and random processes. Blue
Bell, PA: Kappa Research, LLC.
 Spiegel, M. R., Schiller, J. J., & Srinivasan, R. A. (2013). Schaums outline of probability
and statistics. New York: McGraw-Hill.

32
Unit 4: Monte Carlo Methods

Contents
1.0 Introduction
2.0 Intended Learning Outcomes (ILOs)
3.0 Main Content
3.1 Overview of Monte Carlo Method
3.2 History of Monte Carlo Method
3.3 Applications of Monte Carlo Methods
4.0 Self-Assessment Exercise(s)
5.0 Conclusion
6.0 Summary
7.0 Further Readings

1.0 Introduction
Monte Carlo methods (or Monte Carlo experiments) are a class of computational algorithms
that rely on repeated random sampling to compute their results. Monte Carlo methods are
often used in simulating physical and mathematical systems. The methods are especially
useful in studying systems with a large number of coupled (interacting) degrees of freedom,
such as fluids, disordered materials, strongly coupled solids, and cellular structures. More
broadly, Monte Carlo methods are useful for modelling phenomena with significant
uncertainty in inputs, such as the calculation of risk in business. These methods are also
widely used in mathematics: a classic use is for the evaluation of definite integrals,
particularly multidimensional integrals with complicated boundary conditions. It is a widely
successful method in risk analysis when compared with alternative methods or human
intuition. When Monte Carlo simulations have been applied in space exploration and oil
exploration, actual observations of failures, cost overruns and schedule overruns are routinely
better predicted by the simulations than by human intuition or alternative "soft" methods.

2.0 Intended Learning Outcomes (ILOs)


By the end this unit, you should be able to:
 Describe Monte Carlo method
 Trace the origin of Monte Carlo method
 Give examples of the application of Monte Carlo method

3.0 Main Content


3.1 Overview of Monte Carlo Method
There is no single Monte Carlo method; instead, the term describes a large and widely- used
class of approaches.
A Monte Carlo algorithm is an algorithm for computers. It is used to simulate the behaviour
of other systems. It is not an exact method, but a heuristic one. Usually it uses randomness
and statistics to get a result.

It is a computation process that uses random numbers to produce an outcome(s). Instead of


having fixed inputs, probability distributions are assigned to some or all of the inputs. This
will generate a probability distribution for the output after the simulation is run

However, these methods tend to follow the algorithm below:


1. Define a domain of possible inputs.
2. Generate inputs randomly from the domain using a certain specified probability
distribution.
3. Perform a deterministic computation using the inputs.
4. Aggregate the results of the individual computations into the final result.

For example, to approximate the value of π using a Monte Carlo method:


1. Draw a square on the ground, then inscribe a circle within it. From planegeometry,
the ratio of the area of an inscribed circle to that of the surrounding square is π / 4.
2. Uniformly scatter some objects of uniform size throughout the square. For example,
grains of rice or sand.
3. Since the two areas are in the ratio π / 4, the objects should fall in the areas in
approximately the same ratio. Thus, counting the number of objects in the circle and
dividing by the total number of objects in the square will yield an approximation for π
/ 4.
4. Multiplying the result by 4 will then yield an approximation for π itself.

Notice how the π approximation follows the general pattern of Monte Carlo algorithms. First,
we define an input domain: in this case, it's the square which circumscribes our circle. Next,
we generate inputs randomly (scatter individual grains within the square), then perform a
computation on each input (test whether it falls within the circle). At the end, we aggregate
the results into our final result, the approximation of π.
Note, also, two other common properties of Monte Carlo methods: the computation's reliance
on good random numbers, and its slow convergence to a better approximation as more data
points are sampled. If grains are purposefully dropped into only, for example, the center of
the circle, they will not be uniformly distributed, and so our approximation will be poor. An
approximation will also be poor if only a few grains are randomly dropped into the whole
square. Thus, the approximation of π will become more accurate both as the grains are
dropped more uniformly and as more are dropped.

To understand the Monte Carlo method theoretically, it is useful to think of it as a general


technique of numerical integration. It can be shown, at least in a trivial sense, that every
application of the Monte Carlo method can be represented as a definite integral.
Suppose we need to evaluate a multi-dimensional definite integral of the form:

……..6
Most integrals can be converted to this form with a suitable change of variables, so we can
consider this to be a general application suitable for the Monte Carlo method.

The integral represents a non-random problem, but the Monte Carlo method approximates a
solution by introducing a random vector U that is uniformly distributed on the region of
integration. Applying the function f to U, we obtain a random variable f(U). This has
expectation:

………..(7)

where is the probability density function of U. Because ϕ equals 1 on the region of


integration, [7] becomes:

………..(8)

Comparing [6] and [8], we obtain a probabilistic expression for the integral Ψ:
……………..(9)

so random variable f(U) has mean Ψ and some standard deviation ζ. We define
………….(10)

as an unbiased estimator for Ψ with standard error ζ. This is a little unconventional, since
[10] is an estimator that depends upon a sample {U[1]}of size one, but it is a valid estimator
nonetheless.
To estimate Ψ with a standard error lower than ζ, let‘s generalize our estimator to
accommodate a larger sample {U[1], U [2], … , U [m]}. Applying the function f to each of these
yields m independent and identically distributed (IID) random variables f(U [1]), f(U [2]), … ,
f(U [m]), each with expectation Ψ and standard deviation ζ. The generalization of [10]
………….(11)

is an unbiased estimator for Ψ with standard error

…………..(12)
If we have a realization {u , u[2], … , u[m]} for our sample, we may estimate Ψ as:
[1]

…………….(13)
We call [11] the crude Monte Carlo estimator. Formula [12] for its standard error is
important for two reasons. First, it tells us that the standard error of a Monte Carlo analysis
decreases with the square root of the sample size. If we quadruple the number of
realizations used, we will half the standard error. Second, standard error does not depend
upon the dimensionality of the integral [6]. Most techniques of numerical integration such
as the trapezoidal rule or Simpson's method suffer from the curse of dimensionality.
When generalized to multiple dimensions, the number of computations required to apply
them, increases exponentially with the dimensionality of the integral. For this reason, such
methods cannot be applied to integrals of more than a few dimensions. The Monte Carlo
method does not suffer from the curse of dimensionality. It is as applicable to a 1000-
dimensional integral as it is to a one-dimensional integral.
While increasing the sample size is one technique for reducing the standard error of a
Monte Carlo analysis, doing so can be computationally expensive. A better solution is to
employ some technique of variance reduction. These techniques incorporate additional
information about the analysis directly into the estimator. This allows them to make the
Monte Carlo estimator more deterministic, and hence have a lower standard error.

Due to high mathematics required and burden of understanding at this level, we have to
stop this discussion here.

3.2 History of Monte Carlo Method


Physicists at Los Alamos Scientific Laboratory were investigating radiation shielding and
the distance that neutrons would likely travel through various materials. Despite having
most of the necessary data, such as the average distance a neutron would travel in a
substance before it collided with an atomic nucleus or how much energy the neutron was
likely to give off following a collision, the problem could not be solved with analytical
calculations. John von Neumann and Stanislaw Ulam suggested that the problem be solved
by modelling the experiment on a computer using chance. Being secret, their work
required a code name. Von Neumann chose the name "Monte Carlo". The name is a
reference to the Monte Carlo Casino in Monaco where Ulam's uncle would borrow money
to gamble.

Random methods of computation and experimentation (generally considered forms of


stochastic simulation) can be arguably traced back to the earliest pioneers of probability
theory but are more specifically traced to the pre-electronic computing era. The general
difference usually described about a Monte Carlo form of simulation is that it
systematically "inverts" the typical mode of simulation, treating deterministic problems by
first finding a probabilistic analogy. Previous methods of simulation and statistical
sampling generally did the opposite: using simulation to test a previously understood
deterministic problem. Though examples of an "inverted" approach do exist historically,
they were not considered a general method until the popularity of the Monte Carlo method
spread.

It was only after electronic computers were first built (from 1945 on) that Monte Carlo
methods began to be studied in depth. In the 1950s they were used at Los Alamos for early
work relating to the development of the hydrogen bomb, and became popularized in the
fields of physics, physical chemistry, and operations research. The Rand Corporation and
the U.S. Air Force were two of the major organizations responsible for funding and
disseminating information on Monte Carlo methods during this time, and they began to
find a wide application in many different fields.
Uses of Monte Carlo methods require large amounts of random numbers, and it was their
use that spurred the development of pseudorandom number generators, which were far
quicker to use than the tables of random numbers which had been previously used for
statistical sampling.

3.4 Applications of Monte Carlo Methods


As stated above, Monte Carlo simulation methods are especially useful for modelling
phenomena with significant uncertainty in inputs and in studying systems with a large
number of coupled degrees of freedom. Areas of application include:

a. Physical sciences:
Monte Carlo methods are very important in computational physics, physical chemistry, and
related applied fields, and have diverse applications from complicated quantum
calculations to designing heat shields and aerodynamic forms. The Monte Carlo method is
widely used in statistical physics, particularly Monte Carlo molecular modelling as an
alternative for computational molecular dynamics as well as to compute statistical field
theories of simple particle and polymer models. In experimental particle physics, these
methods are used for designing detectors, understanding their behaviour and comparing
experimental data to theory, or on vastly large scale of the galaxy modelling.

Monte Carlo methods are also used in the models that form the basis of modern weather
forecasting operations.

b. Engineering
Monte Carlo methods are widely used in engineering for sensitivity analysis and
quantitative probabilistic analysis in process design. The need arises from the interactive,
co-linear and non-linear behaviour of typical process simulations. For example,
 in microelectronics engineering, Monte Carlo methods are applied to analyze
correlated and uncorrelated variations in analog and digital integrated circuits. This
enables designers to estimate realistic 3 sigma corners and effectively optimise
circuit yields.
 in geostatistics and geometallurgy, Monte Carlo methods strengthen the design of
mineral processing flow sheets and contribute to quantitative risk analysis.

c. Visual Designs
Monte Carlo methods have also proven efficient in solving coupled integral differential
equations of radiation fields and energy transport, and thus these methods have been used
in global illumination computations which produce photorealistic images of virtual 3D
models, with applications in video games, architecture, design and computer generated
films.
d. Finance and business
Monte Carlo methods in finance are often used to calculate the value of companies, to
evaluate investments in projects at a business unit or corporate level, or to evaluate
financial derivatives. Monte Carlo methods used in these cases allow the construction of
stochastic or probabilistic financial models as opposed to the traditional static and
deterministic models, thereby enhancing the treatment of uncertainty in the calculation.

e. Telecommunications
When planning a wireless network, design must be proved to work for a wide variety of
scenarios that depend mainly on the number of users, their locations and the services they
want to use. Monte Carlo methods are typically used to generate these users and their
states. The network performance is then evaluated and, if results are not satisfactory, the
network design goes through an optimization process.

f. Games
Monte Carlo methods have recently been applied in game playing related artificial
intelligence theory. Most notably the game of Battleship have seen remarkably successful
Monte Carlo algorithm based computer players. One of the main problems that this
approach has in game playing is that it sometimes misses an isolated, very good move.
These approaches are often strong strategically but weak tactically, as tactical decisions
tend to rely on a small number of crucial moves which are easily missed by the randomly
searching Monte Carlo algorithm.

Monte Carlo simulation versus “what if” scenarios


The opposite of Monte Carlo simulation might be considered deterministic modelling
using single-point estimates. Each uncertain variable within a model is assigned a ―best
guess‖ estimate. Various combinations of each input variable are manually chosen (such as
best case, worst case, and most likely case), and the results recorded for each so-called
―what if‖ scenario.
By contrast, Monte Carlo simulation considers random sampling of probability distribution
functions as model inputs to produce hundreds or thousands of possible outcomes instead
of a few discrete scenarios. The results provide probabilities of different outcomes
occurring.
For example, a comparison of a spreadsheet cost construction model run using traditional
―what if‖ scenarios, and then run again with Monte Carlo simulation and Triangular
probability distributions shows that the Monte Carlo analysis has a narrower range than
the ―what if‖ analysis. This is because the ―what if‖ analysis gives equal weight to all
scenarios.

A randomized algorithm or probabilistic algorithm is an algorithm which employs a


degree of randomness as part of its logic. The algorithm typically uses uniformly
distributed random bits as an auxiliary input to guide its behaviour, in the hope of
achieving good performance in the "average case" over all possible choices of random bits.
Formally, the algorithm's performance will be a random variable determined by the
random bits; thus either the running time, or the output (or both) are random variables
In common practice, randomized algorithms are approximated using a pseudorandom
number generator in place of a true source of random bits; such an implementation may
deviate from the expected theoretical behaviour.

g. Uses in mathematics
In general, Monte Carlo methods are used in mathematics to solve various problems by
generating suitable random numbers and observing that fraction of the numbers which
obeys some property or properties. The method is useful for obtaining numerical solutions
to problems which are too complicated to solve analytically. The most common application
of the Monte Carlo method in mathematics are:

i. Integration
Deterministic methods of numerical integration usually operate by taking a number of
evenly spaced samples from a function. In general, this works very well for functions of
one variable. However, for functions of vectors, deterministic quadrature methods can be
very inefficient. To numerically integrate a function of a two-dimensional vector, equally
spaced grid points over a two-dimensional surface are required. For instance a 10x10 grid
requires 100 points. If the vector has 100 dimensions, the same spacing on the grid would
require 10100 points which is far too many to be computed. But 100 dimensions is by no
means unusual, since in many physical problems, a "dimension" is equivalent to a degree
of freedom.
Monte Carlo methods provide a way out of this exponential time-increase. As long as the
function in question is reasonably well-behaved, it can be estimated by randomly selecting
points in 100-dimensional space, and taking some kind of average of the function values at
these points. By the law of large numbers, this method will display convergence (i.e.
quadrupling the number of sampled points will halve the error, regardless of the number of
dimensions).

ii. Optimization
Most Monte Carlo optimization methods are based on random walks. The program will
move around a marker in multi-dimensional space, tending to move in directions which
lead to a lower function, but sometimes moving against the gradient.

Another popular application for random numbers in numerical simulation is in numerical


optimization (choosing the best element from some set of available alternatives). These
problems use functions of some often large-dimensional vector that are to be minimized
(or maximized). Many problems can be phrased in this way: for example a computer chess
program could be seen as trying to find the optimal set of, say, 10 moves which produces
the best evaluation function at the end. The travelling salesman problem is another
optimization problem. There are also applications to engineering design, such as design
optimization.
iii. Inverse problems
Probabilistic formulation of inverse problems leads to the definition of a probability
distribution in the space models. This probability distribution combines a priori (prior
knowledge about a population, rather than that estimated by recent observation)
information with new information obtained by measuring some observable parameters
(data). As, in the general case, the theory linking data with model parameters is nonlinear,
the aposteriori probability in the model space may not be easy to describe (it may be
multimodal, some moments may not be defined, etc.).

When analyzing an inverse problem, obtaining a maximum likelihood model is usually not
sufficient, as we normally also wish to have information on the resolution power of the
data. In the general case we may have a large number of model parameters, and an
inspection of the marginal probability densities of interest may be impractical, or even
useless. But it is possible to pseudorandomly generate a large collection of models
according to the posterior probability distribution and to analyze and display the models in
such a way that information on the relative likelihoods of model properties is conveyed to
the spectator. This can be accomplished by means of an efficient Monte Carlo method,
even in cases where no explicit formula for the a priori distribution is available.

h. Computational mathematics
Monte Carlo methods are useful in many areas of computational mathematics, where a
lucky choice can find the correct result. A classic example is Rabin's algorithm for
primality testing (algorithm which determines whether a given number is prime). It states
that for any n which is not prime, a random x has at least a 75% chance of proving that n is
not prime. Hence, if n is not prime, but x says that it might be, we have observed at most a
1-in-4 event. If 10 different random x say that "n is probably prime" when it is not, we
have observed a one-in-a-million event. In general a Monte Carlo algorithm of this kind
produces one correct answer with a guarantee that n is composite, and x proves it so, but
another one without, but with a guarantee of not getting this answer when it is wrong too
often; in this case at most 25% of the time.
Remark:
In physics, two systems are coupled if they are interacting with each other. Of special
interest is the coupling of two (or more) vibratory systems (e.g. pendula or resonant
circuits) by means of springs or magnetic fields, etc. Characteristic for a coupled
oscillation is the effect of beat.

4.0 4.0 Self-Assessment Exercise(s)


Answer the following questions:
1. How is Monte Carlo method different in approach from the typical mode of
simulation, in deterministic problems?
2. How is Monte Carlo method used in Engineering and Mathematics?
5.0 Conclusion
Monte Carlo methods, relies on repeated computation of random or pseudo-random numbers.
These methods are most suited to computations by a computer and tend to be used when it is
unfeasible or impossible to compute an exact result with a deterministic algorithm (i.e. an
algorithm whose behaviour can be completely predicted from the input)

6.0 Summary
In this unit we discussed the following:
 The algorithm of Monte Carlo method
 The history of Monte Carlo method which spurred the development of pseudorandom
number generator
 The application of Monte Carlo methods in areas such as physical sciences,
Engineering, Finance and Business, telecommunications, Games, Mathematics, etc.

7.0 Further Readings


 Devore, J. L. (2018). Probability and statistics for engineering and the sciences. Toronto,
Ontario: Nelson.
 Georgii, H. (2013). Stochastics: Introduction to probability and statistics. Berlin: De
Gruyter.
 Giri, N. C. (2019). Introduction to probability and statistics. London: Routledge.
 Johnson, R. A., Miller, I., & Freund, J. E. (2019). Miller & Freunds probability and
statistics for engineers. Boston: Pearson Education.
 Laha, R. G., & Rohatgi, V. K. (2020). Probability theory. Mineola, NY: Dover
Publications.
 Mathai, A. M., & Haubold, H. J. (2018). Probability and statistics: A course for
physicists and engineers. Boston: De Gruyter.
 Pishro-Nik, H. (2014). Introduction to probability, statistics, and random processes. Blue
Bell, PA: Kappa Research, LLC.
 Spiegel, M. R., Schiller, J. J., & Srinivasan, R. A. (2013). Schaums outline of probability
and statistics. New York: McGraw-Hill.
Unit 5: Statistical Distribution Functions

Contents
1.0 Introduction
2.0 Intended Learning Outcomes (ILOs)
3.0 Main Content
3.1 What is Statistics
3.2 What is a Statistical Distribution?
3.3 Measures of Central Tendency
3.4 Measures of Variation
3.5 Showing Data Distribution in Graphs
3.6 The Difference between a Continuous and a Discrete Distribution
3.7 Normal Distribution
3.7.1 Standard Normal Distribution
3.7.2 The Normal Distribution as a Model for Measurements
3.7.3 Conversion to a Standard Normal Distribution
3.7.4 Skewed Distributions µ
3.8 What is a Percentile?
3.9 Probabilities in Discrete Distributions
3.10 Probability and the Normal Curve
4.0 Self-Assessment Exercise(s)
5.0 Conclusion
6.0 Summary
7.0 Further Readings

1.0 Introduction
Although simulation can be a valuable tool for better understanding the underlying
mechanisms that control the behaviour of a system, using simulation to make predictions
of the future behaviour of a system can be difficult. This is because, for most real-world
systems, at least some of the controlling parameters, processes and events are often
stochastic, uncertain and/or poorly understood. The objective of many simulations is to
identify and quantify the risks associated with a particular option, plan or design.
Simulating a system in the face of such uncertainty and computing such risks requires that
the uncertainties be quantitatively included in the calculations. To do this we collect data
about the system parameters and subject them to statistical analysis.

2.0 Intended Learning Outcomes (ILOs)


After studying this unit the reader should be able to
 Define Statistics
 Explain Statistical Distributions
 Compute measures of Central Tendency and Variations
 Explain the Components of Statistical Distributions
o Normal Distributions,
o z-score
o percentile,
o Skewed Distributions
o Ways to transform data to Graphs

3.0 Main Content


3.1 What is Statistics?
The field of statistics is concerned with the collection, description, and interpretation of
data (data are numbers obtained through measurement). In the field of statistics, the term
―statistic‖ denotes a measurement taken on a sample (as opposed to a population). In
general conversation, ―statistics‖ also refers to facts and figures.

3.2 What is a Statistical Distribution?


A statistical distribution describes the numbers of times each possible outcome occurs in a
sample. If you have 10 test scores with 5 possible outcomes of A, B, C, D, or F, a
statistical distribution describes the relative number of times an A,B,C,D or F occurs. For
example, 2 A‘s, 4 B‘s, 4 C‘s, 0 D‘s, 0 F‘s.

3.3 Measures of Central Tendency


Suppose we have a sample with the following 4 observations: 4, 1, 4, 3.

Mean - the sum of a set of numbers divided by the number of observations.

Median - the middle point of a set of numbers (for odd numbered


samples). the mean of the middle two points (for even samples).

Mode - the most frequently occurring number.


Mode = 4 (4 occurs most).

The mean, median and mode are called measures of central tendency.

3.4 Measures of Variation


Range - the maximum value minus the minimum value in a set of
numbers. Range = 4-1 = 3.
Standard Deviation - the average distance a data point is away from the mean.
Standard deviation computes the difference between each data point and the mean. Take
the absolute value of each difference. Sum the absolute values. Divide this sum by the
number of data points. Median: first arrange data points in increasing order.

Mean, Median, Mode, Range, and Standard Deviations are measurements in a sample
(statistics) and can also be used to make inferences on a population.

3.5 Showing Data Distribution in Graphs


 Bar graphs use bars to compare frequencies of possible data values (see Fig a).
 Double bar graphs use two sets of bars to compare frequencies of data values
between two levels of data (e.g. boys and girls) (see fig b).
 Histograms use bars to show how frequently data occur within equal spaces within
an interval (see fig c & d).
 Pie Charts use portion of a circle to show contributions of data values (see fig c & d).

3.6 The Difference between a Continuous and a Discrete Distribution


Continuous distributions describe an infinite number of possible data values (as shown
by the curve). For example someone‘s height could be 1.7m, 1.705m, 1.71m, ...

Discrete distributions describe a finite number of possible values. (shown by the bars)

Fig 2: Distribution of Height in Males

3.7 Normal Distribution


A normal distribution is a continuous distribution that is ―bell-shaped‖. Data are often
assumed to be normal. Normal distributions can estimate probabilities over a continuous
interval of data values.
The normal distribution refers to a family of continuous probability distributions
described by the normal equation.

In a normal distribution, data are most likely to be at the mean. Data are less likely to be
farther away from the mean.
The normal distribution is defined by the following equation:

Y = [ 1/ζ * sqrt(2π) ] * e-(x - µ)2/2ζ2

where X is a normal random variable, µ is the mean, ζ is the standard deviation, π is


approximately 3.14159, and e is approximately 2.71828.
The random variable X in the normal equation is called the normal random variable. The
normal equation is the probability density function for the normal distribution.

The graph of the normal distribution depends on two factors - the mean and the standard
deviation. The mean of the distribution determines the location of the center of the graph,
and the standard deviation determines the height and width of the graph. When the
standard deviation is large, the curve is short and wide; when the standard deviation is
small, the curve is tall and narrow. All normal distributions look like a symmetric, bell-
shaped curve, as shown in figure 3a and 3b.

(a) (b)

Fig. 3: Graph of Normal Distribution Based on Size of Mean and Standard Deviation

The curve on the left is shorter and wider than the curve on the right, because the curve on
the left has a bigger standard deviation.

3.7.1 Standard Normal Distribution


The standard normal distribution is a special case of the normal distribution. It is the
distribution that occurs when a normal random variable has a mean of zero and a standard
deviation of one.
The normal random variable of a standard normal distribution is called a standard score
or a z-score. Every normal random variable X can be transformed into a z score via the
following equation:

z = (X - µ) / ζ

where X is a normal random variable, µ is the mean of X, and ζ is the standard deviation of
X.

3.7.2 The Normal Distribution as a Model for Measurements


Often, phenomena in the real world follow a normal (or near-normal) distribution. This
allows researchers to use the normal distribution as a model for assessing probabilities
associated with real-world phenomena. Typically, the analysis involves two steps.

 Transform raw data. Usually, the raw data are not in the form of z-scores. They
need to be transformed into z-scores, using the transformation equation presented
earlier: z = (X - µ) / ζ.
 Find the probability. Once the data have been transformed into z-scores, you can
use standard normal distribution tables, online calculators (e.g., Stat Trek's free
normal distribution calculator) to find probabilities associated with the z-scores.
The problem in the next section demonstrates the use of the normal distribution as a model
for measurement.

Example 1 - Ada earned a score of 940 on a national achievement test. The mean test
score was 850 with a standard deviation of 100. What proportion of students had a higher
score than Ada? (Assume that test scores are normally distributed.)

Solution - As part of the solution to this problem, we assume that test scores are normally
distributed. In this way, we use the normal distribution as a model for measurement.
Given an assumption of normality, the solution involves three steps.

 First, we transform Ada's test score into a z-score, using the z-scoretransformation
equation.
z = (X - µ) / ζ = (940 - 850) / 100 = 0.90
 Then, using a standard normal distribution table, we find the cumulative
probability associated with the z-score. In this case, we find P(Z < 0.90) = 0.8159.
 Therefore, the P(Z > 0.90) = 1 - P(Z < 0.90) = 1 - 0.8159 = 0.1841.
Thus, we estimate that 18.41 percent of the students tested had a higher score than Ada.

Example 2 - An average light bulb manufactured by the Acme Corporation lasts 300 days
with a standard deviation of 50 days. Assuming that bulb life is normally distributed, what
is the probability that an Acme light bulb will last at most 365 days?
Solution: Given a mean score of 300 days and a standard deviation of 50 days, we want to
find the cumulative probability that bulb life is less than or equal to 365 days. Thus, we
know the following:

 The value of the normal random variable is 365 days.


 The mean is equal to 300 days.
 The standard deviation is equal to 50 days.

We enter these values into the formula and compute the cumulative probability. The
answer is: P( X < 365) = 0.90. Hence, there is a 90% chance that a light bulb will burn out
within 365 days.

3.7.3 Conversion to a Standard Normal Distribution


The values for points in a standard normal distribution are z-scores. We can use a standard
normal table to find the probability of getting at or below a z-score. (a percentile).
 Subtract the mean from each observation in your normal distribution, the
new mean=0.
 Divide each observation by the standard deviation, the new standard
deviation=1.

3.7.4 Skewed Distributions µ


Skewness is the degree of asymmetry or departure from symmetry, of a distribution.
Skewed distributions are not symmetric. If the frequency curve of a distribution has a
longer tail to the right of the right of the central maximum than to the left, the distribution
is said to be skewed to the right, or have a positive skewness. If the reverse is the case, it is
said to be skewed to the left or negative skewness.
For skewed distributions, the mean tend to lie on the same side of the mode as the longer
tail. Thus a measure of the asymmetry is supplied by the difference:
Mean – mode. This can be made dimensionless if we divide it by a measure of dispersion,
such as the standard deviation, leading to the definition:

Skewness = mean - mod e µ- mod e


= (1)
SD s

To avoid using mode, we can use the empirical formula:

Skewness = 3(mean – median) 3(µ - median)


= (2)
SD s

Equations (1) and (2) are called; Pearson‘s first and second coefficients of skewness.
3.8 What is a Percentile?
A percentile (or cumulative probability) is the proportion of data in a distribution less
than or equal to a data point. If you scored a 90 on a math test and 80% of the class had
scores of 90 or lower; your percentile is 80. In the figure 4, b=90 and P(Z<b)=80.

Fig. 4: illustration of Percentiles

3.9 Probabilities in Discrete Distributions


Suppose for your 10 tests you received 5 As, 2 Bs, 2 Cs, 1 D and want to find the
probability of receiving an A or a B. Sum the frequencies for A and B and divide by the
sample size. The probability of receiving an A or a B is (5+2)/10 = .7 (a 70% chance).

3.10 Probability and the Normal Curve

The normal distribution is a continuous probability distribution. This has several


implications for probability.

 The total area under the normal curve is equal to 1.


 The probability that a normal random variable X equals any particular value is 0.
 The probability that X is greater than b equals the area under the normal curve
bounded by b and plus infinity (as indicated by the non-shaded area in the figure 4).
 The probability that X is less than a equals the area under the normal curve bounded
by b and minus infinity (as indicated by the shaded area in the figure below).

4.0 4.0 Self-Assessment Exercise(s)


Answer the following questions:
1. Why Convert to a Standard Normal Distribution?
2. What is the difference between a Continuous and a Discrete Distribution?
3. Given the following: mean=279.76, median=279.06, mode=277.5 and SD=15.6, find
the first and second coefficients of skewness
4. Find the mode, median and mean deviation of the following sets of data: (a) 3, 7, 9, 5
and (b) 8, 10, 9, 12, 4, 8, 2.
5.0 Conclusion
We use Statistical distributions to: investigate how a change in one variable relates to a
change in a second variable, represent situations with numbers, tables, graphs, and verbal
descriptions, understand measurable attributes of objects and their units, systems, and
processes of measurement, identify relationships among attributes of entities or systems
and their association.

6.0 Summary
In this unit:
 We defined Statistics as field of study that is concerned with the collection,
description, and interpretation of data.
 We saw that Statistical Distributions describe the numbers of times each possible
outcome occurs in a sample.
 We computed various measures of Central Tendency and Variations which can be
used to make inferences.
 And explained the following components of Statistical Distributions:
o Normal Distributions,
o z-score
o percentile,
o Skewed Distributions
o Ways to transform data to Graphs

7.0 Further Readings


 Devore, J. L. (2018). Probability and statistics for engineering and the sciences. Toronto,
Ontario: Nelson.
 Georgii, H. (2013). Stochastics: Introduction to probability and statistics. Berlin: De
Gruyter.
 Giri, N. C. (2019). Introduction to probability and statistics. London: Routledge.
 Johnson, R. A., Miller, I., & Freund, J. E. (2019). Miller & Freunds probability and
statistics for engineers. Boston: Pearson Education.
 Laha, R. G., & Rohatgi, V. K. (2020). Probability theory. Mineola, NY: Dover
Publications.
 Mathai, A. M., & Haubold, H. J. (2018). Probability and statistics: A course for
physicists and engineers. Boston: De Gruyter.
 Pishro-Nik, H. (2014). Introduction to probability, statistics, and random processes. Blue
Bell, PA: Kappa Research, LLC.
 Spiegel, M. R., Schiller, J. J., & Srinivasan, R. A. (2013). Schaums outline of probability
and statistics. New York: McGraw-Hill.
Unit 6: Common Probability Distributions

Contents
1.0 Introduction
2.0 Intended Learning Outcomes (ILOs)
3.0 Main Content
3.1 Distribution Functions and Simulation
3.2 Probability Definitions
3.3 Random Variables
3.4 Probability Function
3.5 Mathematical Treatment of Probability
3.6 Probability theory
3.7 The Limit theorems
3.8 Probability Distribution Functions
3.9 Summary of Common Probability Distributions
4.0 Self-Assessment Exercise(s)
5.0 Conclusion
6.0 Summary
7.0 Further Readings

1.0 Introduction
In this section we look at the branch of statistics that deals with analysis of random events.
Probability is the numerical assessment of likelihood on a scale from 0 (impossibility) to 1
(absolute certainty). Probability is usually expressed as the ratio between the number of ways
an event can happen and the total number of things that can happen (e.g., there are 13 ways
of picking a diamond from a deck of 52 cards, so the probability of picking a diamond is
13/52, or ¼). Probability theory grew out of attempts to understand card games and
gambling. As science became more rigorous, analogies between certain biological, physical,
and social phenomena and games of chance became more evident (e.g., the sexes of newborn
infants follow sequences similar to those of coin tosses). As a result, probability became a
fundamental tool of modern genetics and many other disciplines.

2.0 Intended Learning Outcomes (ILOs)


By the end of this unit, the reader should be able to:
 Explain the role of probability distribution functions in simulations
 Describe Probability theory
 Explain the fundamental concepts of Probability theory
 Explain Random Variable
 Explain Limiting theorems
 Describe Probability distributions in simulations
 List common Probability distributions.

3.0 Main Content


3.1 Distribution Functions and Simulation
Many simulation tools and approaches are deterministic. In a deterministic simulation, the
input parameters for a model are represented using single values (which typically are
described either as "the best guess" or "worst case" values). Unfortunately, this kind of
simulation, while it may provide some insight into the underlying mechanisms, is not well-
suited to making predictions to support decision-making, as it cannot quantitatively address
the risks and uncertainties that are inherently present.

However, it is possible to quantitatively represent uncertainties in simulations.


Probabilistic simulation is the process of explicitly representing these uncertainties by
specifying inputs as probability distributions. If the inputs describing a system are uncertain,
the prediction of future performance is necessarily uncertain. That is, the result of any
analysis based on inputs represented by probability distributions is itself a probability
distribution. Hence, whereas the result of a deterministic simulation of an uncertain system is
a qualified statement ("if we build the dam, the salmon population could go extinct"), the
result of a probabilistic simulation of such a system is a quantified probability ("if we build
the dam, there is a 20% chance that the salmon population will go extinct"). Such a result (in
this case, quantifying the risk of extinction) is typically much more useful to decision-makers
who might utilize the simulation results.

3.2 Probability Definitions


The word probability does not have a consistent direct definition. In fact, there are two broad
categories of probability interpretations, whose adherents possess different (and sometimes
conflicting) views about the fundamental nature of probability:

1. Frequentists talk about probabilities only when dealing with experiments that are
random and well-defined. The probability of a random event denotes the relative
frequency of occurrence of an experiment's outcome, when repeating the experiment.
Frequentists consider probability to be the relative frequency "in the long run" of
outcomes.
2. Bayesians, however, assign probabilities to any statement whatsoever, even when no
random process is involved. Probability, for a Bayesian, is a way to represent an
individual's degree of belief in a statement, or an objective degree of rational belief,
given the evidence
The scientific study of probability is a modern development. Gambling shows that
there has been an interest in quantifying the ideas of probability for millennia, but
exact mathematical descriptions of use in those problems only arose much later.
Probability Distribution
A probability distribution gathers together all possible outcomes of a random variable (i.e.
any quantity for which more than one value is possible), and summarizes these outcomes by
indicating the probability of each of them. While a probability distribution is often associated
with the bell-shaped curve, recognize that such a curve is only indicative of one specific type
of probability, the so-called normal probability distribution. However, in real life, a
probability distribution can take any shape, size and form.

Example: Probability Distribution


For example, if we wanted to choose a day at random in the future to schedule an event, and
we wanted to know the probability that this day would fall on a Sunday, as we will need to
avoid scheduling it on a Sunday. With seven days in a week, the probability that a random
day would happen to be a Sunday would be given by one-seventh or about 14.29%. Of
course, the same 14.29% probability would be true for any of the other six days.

In this case, we would have a uniform probability distribution: the chances that our random
day would fall on any particular day are the same, and the graph of our probability
distribution would be a straight line.

fig.1: Uniform Probability Distribution

Probability distributions can be simple to understand as in this example, or they can be


very complex and require sophisticated techniques (e.g., option pricing models, Monte
Carlo simulations) to help describe all possible outcomes.

3.3 Random Variables


Random variable is discrete random variables if it can take on a finite or countable number
of possible outcomes. The previous example asking for a day of the week is an example of
a discrete variable, since it can only take seven possible values. Monetary variables
expressed in dollars and cents are always discrete, since money is rounded to the nearest
$0.01.
A random variable is continuous random variable if it has has infinite possible outcomes.
A rate of return (e.g. growth rate) is continuous:
 a stock can grow by 9% next year or by 10%, and in between this range it could
grow by 9.3%, 9.4%, 9.5%
 Clearly there is no end to how precise the outcomes could be broken down; thus it‘s
described as a continuous variable.

Outcomes in Discrete vs. Continuous Variables


The rule of thumb is that a discrete variable can have all possibilities listed out, while a
continuous variable must be expressed in terms of its upper and lower limits, and greater-
than or less-than indicators. Of course, listing out a large set of possible outcomes (which
is usually the case for money variables) is usually impractical – thus money variables will
usually have outcomes expressed as if they were continuous.

Examples:
 Rates of return can theoretically range from –100% to positive infinity.
 Time is bound on the lower side by 0.
 Market price of a security will also have a lower limit of $0, while its upper limit will
depend on the security – stocks have no upper limit (thus a stock price‘s outcome >
$0),
 Bond prices are more complicated, bound by factors such as time-to-maturity and
embedded call options. If a face value of a bond is $1,000, there‘s an upper limit
(somewhere above $1,000) above which the price of the bond will not go, but
pinpointing the upper value of that set is imprecise.

3.4 Probability Function


A probability function gives the probabilities that a random variable will take on a given
list of specific values. For a discrete variable, if (x1, x2, x3, x4 …) are the complete set of
possible outcomes, p(x) indicates the chances that X will be equal to x. Each x in the list
for a discrete variable will have a p(x). For a continuous variable, a probability function is
expressed as f(x).

The two key properties of a probability function, p(x) (or f(x) for continuous), are the
following:
1. 0 < p(x) < 1, since probability must always be between 0 and 1.
2. Add up all probabilities of all distinct possible outcomes of a random variable, and the
sum must equal 1.

Determining whether a function satisfies the first property should be easy to spot since we
know that probabilities always lie between 0 and 1. In other words, p(x) could never be
1.4 or –0.2. To illustrate the second property, say we are given a set of three possibilities
for X: (1, 2, 3) and a set of three for Y: (6, 7, 8), and given the probability functions f(x)
and g(y).

x f(x) y g(y)
1 0.31 6 0.32
2 0.43 7 0.40
3 0.26 8 0.23

For all possibilities of f(x), the sum is 0.31+0.43+0.26=1, so we know it is a valid


probability function. For all possibilities of g(y), the sum is 0.32+0.40+0.23 = 0.95, which
violates our second principle. Either the given probabilities for g(y) are wrong, or there is a
fourth possibility for y where g(y) = 0.05. Either way it needs to sum to 1.

Probability Density Function


A probability density function (or pdf) describes a probability function in the case of a
continuous random variable. Also known as simply the ―density‖, a probability density
function is denoted by ―f(x)‖. Since a pdf refers to a continuous random variable, its
probabilities would be expressed as ranges of variables rather than probabilities assigned to
individual values as is done for a discrete variable. For example, if a stock has a 20%
chance of a negative return, the pdf in its simplest terms could be expressed as:

x f(x)
<0 0.2
>0 0.8

3.5 Mathematical Treatment of Probability


In mathematics, a probability of an event A is represented by a real number in the range
from 0 to 1 and written as P(A), p(A) or Pr(A). An impossible event has a probability of 0,
and a certain event has a probability of 1. However, the converses are not always true:
probability 0 events are not always impossible, nor probability 1 events certain. The rather
subtle distinction between "certain" and "probability 1" is treated at greater length in the
article on "almost surely".
The opposite or complement of an event A is the event [not A] (that is, the event of A not
occurring); its probability is given by P(not A) = 1 - P(A). As an example, the chance of

not rolling a six on a six-sided die is 1 – (chance of rolling a six) . .

Joint Probabilty

If both the events A and B occur on a single performance of an experiment this is called
the intersection or joint probability of A and B, denoted as and .

If two events, A and B are independent then the joint probability is:

for example, if two coins are flipped the chance of both being heads is: .

Mutually Exclusive Events


If either event A or event B or both events occur on a single performance of an experiment

this is called the union of the events A and B denoted as . If two events are
mutually exclusive then the probability of either occurring is:

.
For example, the chance of rolling a 1 or 2 on a six-sided die is

If the events are not mutually exclusive then

For example, when drawing a single card at random from a regular deck of cards, the chance

of getting a heart or a face card (J,Q,K) (or one that is both) is , because
of the 52 cards of a deck 13 are hearts, 12 are face cards, and 3 are both: here the possibilities
included in the "3 that are both" are included in each of the "13 hearts" and the "12 face
cards" but should only be counted once.

Conditional Probability

This is the probability of some event A, given the occurrence of some other event B.
Conditional probability is written P(A|B), and is read "the probability of A, given B". It is
defined by:

If P(B) = 0 then is undefined.

Summary of probabilities
Event Probability
A
Not A P(A) = 1-P(A)
A or B P(A U B) = P(A) + P(B)-P(A∩B)
= P(A)+P(B) If A and B are mutually exclusive
A and B P(A∩B) = P(A|B)P(B)
= P(A)P(B) If A and B are independent
A given B P(A|B) = P(A∩B)/P(B)

Two or more events are mutually exclusive if the occurrence of any one of them excludes
the occurrence of the others.
3.6 Probability theory

Like other theories, the theory of probability is a representation of probabilistic concepts in


formal terms—that is, in terms that can be considered separately from their meaning.
These formal terms are manipulated by the rules of mathematics and logic, and any results
are then interpreted or translated back into the problem domain.

There have been at least two successful attempts to formalize probability, namely the
Kolmogorov formulation and the Cox formulation. In Kolmogorov's formulation sets are
interpreted as events and probability itself as a measure on a class of sets. In Cox's
theorem, probability is taken as a primitive (that is, not further analyzed) and the emphasis
is on constructing a consistent assignment of probability values to propositions. In both
cases, the laws of probability are the same, except for technical details.

Probability theory is a mathematical science that permits one to find, using the
probabilities of some random events, the probabilities of other random events connected in
some way with the first.
The assertion that a certain event occurs with a probability equal, for example, to 1/2, is
still not, in itself, of ultimate value, because we are striving for definite knowledge. Of
definitive, cognitive value are those results of probability theory that allow us to state that
the probability of occurrence of some event A is very close to 1 or (which is the same
thing) that the probability of the non-occurrence of event A is very small. According to the
principle of ―disregarding sufficiently small probabilities,‖ such an event is considered
practically reliable. Such conclusions, which are of scientific and practical interest, are
usually based on the assumption that the occurrence or non-occurrence of event A depends
on a large number of factors that are slightly connected with each other.

Consequently, it can also be said that probability theory is a mathematical science that
clarifies the regularities that arise in the interaction of a large number of random factors.
To describe the regular connection between certain conditions S and event A, whose
occurrence or non-occurrence under given conditions can be accurately established, natural
science usually uses one of the following schemes:
(a) For each realization of conditions S, event A occurs. All the laws of classical
mechanics have such a form, stating that for specified initial conditions and
forces acting on an object or system of objects, the motion will proceed in an
unambiguously definite manner.
(b) Under conditions S, event A has a definite probability P(A/S) equal to p.
Thus, for example, the laws of radioactive emission assert that for each
radioactive substance there exists the specific probability that, for a given
amount of a substance, a certain number of atoms N will decompose within a
given time interval.

Let us call the frequency of event A in a given set of n trials (that is, of n repeated
realizations of conditions S) the ratio h = m/n of the number m of those trials in which A
occurs to the total number of trials n. The existence of a specific probability equal to p for
an event A under conditions S is manifested in the fact that in almost every sufficiently
long series of trials, the frequency of event A is approximately equal to p.

Statistical laws, that is, laws described by a scheme of type (b), were first discovered in
games of chance similar to dice. The statistical rules of birth and death (for example, the
probability of the birth of a boy is 0.515) have also been known for a long time. A great
number of statistical laws in physics, chemistry, biology, and other sciences were
discovered at the end of the 19th and in the first half of the 20th century.

The possibility of applying the methods of probability theory to the investigation of


statistical laws, which pertain to a very wide range of scientific fields, is based on the fact
that the probabilities of events always satisfy certain simple relationships, which will be
discussed in the next section. The investigation of the properties of probabilities of events
on the basis of these simple relationships is also a topic of probability theory.

3.6.1 Fundamental concepts of Probability theory.


The fundamental concepts of probability theory as a mathematical discipline are most
simply defined in the framework of so-called elementary probability theory. Each trial T
considered in elementary probability theory is such that it is ended by one and only one of
the events E1, E2, … , Es (by one or another, depending on the case). These events are
called outcomes of the trial. Each outcome Ek is connected with a positive number pk, the
probability of this outcome. The numbers pk must add up to 1. Events A, which consist of
the fact that ―either Ei, or Ej … , or Ek occurs,‖ are then considered. The outcomes Ei, … ,
Ek are said to be favorable to A, and according to the definition, it is assumed that the
probability P(A) of event A is equal to the sum of the probabilities of the outcomes
favorable to it:

(1) P(A) = pi + pj + … + pk

The particular case p1 = p2 = ps= 1/s leads to the formula:


(2) P(A) = r/s

Formula (2) expresses the so-called classical definition of probability according to which
the probability of some event A is equal to the ratio of the number r of outcomes favorable
to A to the number s of all ―equally likely‖ outcomes. The classical definition of
probability only reduces the concept of probability to the concept of equal possibility,
which remains without a clear definition.

EXAMPLE. In the tossing of two dice, each of the 36 possible outcomes can be designated
by (i, j), where i is the number of pips that comes up on the first dice and j, the number on
the second. The outcomes are assumed to be equally likely. To the event A, ―the sum of the
pips is 4,‖ three outcomes are favorable: (1,3); (2,2); (3,1). Consequently, P(A) = 3/36 =
1/12.

Starting from certain given events, it is possible to define two new events: their union
(sum) and intersection (product). Event B is called the union of events A1, A2, …, Ar if it
has the form ―A1 or A2, …, or Ar occurs.‖

Event C is called the intersection of events A1, A2 …, Ar if it has the form ―A1, and A2, …
, and Ar occurs.‖
The union of events is designated by the symbol 𝖴, and the intersection, by ∩. Thus, we
write:

B = A1 𝖴 A2 𝖴 ... 𝖴 Ar C =
A1 ∩ A2 ∩ ... ∩ Ar
Events A and B are called disjoint if their simultaneous occurrence is impossible—that is,
if among the outcomes of a trial not one is favourable to A and B simultaneously.
Two of the basic theorems of probability theory are connected with the operations of union
and intersection of events; these are the theorems of addition and multiplication of
probabilities.

3.6.2 Theorem of Addition of Probabilities.


If events A1, A2, …, Ar are such that each two of them are disjoint, then the probability of
their union is equal to the sum of their probabilities.

Thus, in the example presented above of tossing two dice, event B, ―the sum of the pips
does not exceed 4,‖ is the union of three disjoint events A2, A3, A4, consisting of the fact the
sum of the pips is equal to 2, 3, and 4, respectively. The probabilities of these events are
1/36, 2/36, and 3/36, respectively. According to the theorem of addition of probabilities,
probability P(B) is:

1/36 + 2/36 + 3/36 = 6/36 = 1/6

The conditional probability of event B under condition A is determined by the formula:

which, as can be proved, corresponds completely with the properties of frequencies.


Events A1, A2, …, Ar are said to be independent if the conditional probability of each of
them, under the condition that some of the remaining events have occurred, is equal to its
―absolute‖ probability.

3.6.3 Theorem of Multiplication of Probabilities.


The probability of the intersection of events A1, A2, …, Ar is equal to the probability of
event A1 multiplied by the probability of event A2 under the condition that A1 has occurred,
…, multiplied by the probability of Ar under the condition that A1, A2, …, Ar-1 have
occurred. For independent events, the multiplication theorem reduces to the formula:

P(A1 ∩ A2 ∩ … ∩ Ar ) = P(A1 ) × P(A2 ) × … × P(Ar ) ............................................(3)

that is, the probability of the intersection of independent events is equal to the product of
the probabilities of these events. Formula (3) remains correct, if on both sides some of the
events are replaced by their inverses.

EXAMPLE:
Four shots are fired at a target, and the hit probability is 0.2 for each shot. The target hits
by different shots are assumed to be independent events. What is the probability of hitting
the target three times?

Each outcome of the trial can be designated by a sequence of four letters [for example, (s,
f, f, s) denotes that the first and fourth shots hit the target (success), and the second and
third miss (failure)]. There are 2 · 2 · 2 · 2 = 16 outcomes in all. In accordance with the
assumption of independence of the results of individual shots, one should use formula (3)
and the remarks about it to determine the probabilities of these outcomes. Thus, the
probability of the outcome (s, f, f, f) is set equal to 0.2 x 0.8 x 0.8 x 0.8 = 0.1024; here,
0.8 = 1 - 0.2 is the probability of a miss for a single shot. For the event ―three shots hit the
target,‖ the possible outcomes are: (s, s, s, f), (s, s, f, s), (s, f, s, s), and (f, s, s, s) are
favorable and the probability of each is the same:
0.2 · 0.2 · 0.2 · 0.8 = · · · = 0.8 · 0.2 · 0.2 ·.02 = 0.0064
Consequently, the desired probability is 4 x 0.0064 = 0.0256.
Generalizing the discussion of the given example, it is possible to derive one of the
fundamental formulas of probability theory: if events A1, A2, …, An are independent and
each has a probability p, then the probability of exactly m such events occurring is:

m
Pn(m) = Cn (1- p)n- m ....................................................................................................(4)

Here, Cm n denotes the number of combinations of n elements taken m at a time. For large n,
the calculation using formula (4) becomes difficult. In the preceding example, let the number
of shots equal 100; the problem then becomes one of finding the probability x that the
number of hits lies in the range from 8 to 32. The use of formula (4) and the addition theorem
gives an accurate, but not a practically useful, expression for the desired probability
The approximate value of the probability x can be found by the Laplace theorem

with the error not exceeding 0.0009. The obtained result demonstrates that the event 8 ≤ m
≤ 32 is practically certain. This is the simplest, but a typical, example of the use of the limit
theorems of probability theory.

Another fundamental formula of elementary probability theory is the so-called total


probability formula: if events A1, A2, …, Ar are disjoint in pairs and their union is a certain
event, then the probability of any event B is the sum

The theorem of multiplication of probabilities turns out to be particularly useful in the


consideration of compound trials. Let us say that trial T consists of trials T1, T2, …, Tn-1, Tn,
if each outcome of trial T is the intersection of certain outcomes Ai, Bi, … , xk, Yl of the
corresponding trials T1, T2, …, Tn-1, Tn. From one or another consideration, the following
probabilities are often known:

P(A1), P(Bj/Ai), … , P(Yi/Ai ∩ Bj ∩ … ∩ Xk) ..................................................................(5)

According to the probabilities of (5), probabilities P(E) for all the outcomes of E of the
compound trial and, in addition, the probabilities of all events connected with this trial can
be determined using the multiplication theorem (just as was done in the example above).

Two types of compound trials are the most significant from a practical point of view:
(a) the component trials are independent, that is, the probabilities (5) are equal to the
unconditional probabilities P(Ai), P(Bj), …, P(Yl); and
(b) the results of only the directly preceding trial have any effect on the probabilities of
the outcomes of any trial—that is, the probabilities (5) are equal, respectively, to
P(Ai), P(Bj/Ai), … , P(Yl/Xk).
In this case, it is said that the trials are connected in a Markov chain. The probabilities of
all the events connected with the compound trial are completely determined here by the
initial probabilities P(Ai) and the transition probabilities P(Bj/Ai), … , P(Yl/Xk).
Often, instead of the complete specification of a probability distribution of a random
variable, it is preferable to use a small number of numerical characteristics. The most
frequently used are the mathematical expectation and the dispersion.

In addition to mathematical expectations and dispersions of these variables, a joint


distribution of several random variables is characterized by correlation coefficients and so
forth. The meaning of the listed characteristics is to a large extent explained by the limit
theorems
3.7 The Limit theorems.
In the formal presentation of probability theory, limit theorems appear in the form of a
superstructure over its elementary sections, in which all problems have a finite, purely
arithmetic character. However, the cognitive value of probability theory is revealed only by
the limit theorems. Thus, the Bernoulli theorem proves that in independent trials, the
frequency of appearance of any event, as a rule, deviates little from its probability, and the
Laplace theorem indicates the probabilities of one or another deviation. Similarly, the
meaning of such characteristics of a random variable as its mathematical expectation and
dispersion is explained by the law of large numbers and the central limit theorem.

Let X1, X2, …, Xn, be independent random variables that have one and the same probability
distribution with EXK = a, DXK = ζ2 and Yn be the arithmetic mean of the first n variables
of sequence such that:
Yn = (X1 + X2 + X 2 + · · · +Xn)/n

In accordance with the law of large numbers, for any ε > 0, the probability of the inequality
| Yn - a | ≤ ε has the limit 1 as n → ∞, and thus Yn, as a rule, differs little from a.

The central limit theorem makes this result specific by demonstrating that the deviations
of Yn from a are approximately subordinate to a normal distribution with mean zero and
dispersion 82/n. Thus, to determine the probabilities of one or another deviation of Yn from
a for large n, there is no need to know all the details about the distribution of the variables
Xn; it is sufficient to know only their dispersion.

In the 1920‘s it was discovered that even in the scheme of a sequence of identically
distributed and independent random variables, limiting distributions that differ from the
normal can arise in a completely natural manner. Thus, for example, if X1 is the time until
the first reversion of some randomly varying system to the original state, and X2 is the time
between the first and second reversions, and so on, then under very general conditions the
distribution of the sum X1 + · · · + Xn (that is, of the time until the Aith reversion), after
multiplication by n-1/α(α is a constant less than 1), converges to some limiting distribution.
Thus, the time until the nth reversion increases, roughly speaking, as n1/α, that is, more
rapidly than n (in the case of applicability of the law of large numbers, it is of the order of
n).
The mechanism of the emergence of the majority of limiting regularities can be understood
ultimately only in connection with the theory of random processes.

Random processes.
In a number of physical and chemical investigations of recent decades, the need has arisen
to consider, in addition to one-dimensional and multidimensional random variables,
random processes—that is, processes for which the probability of one or another of their
courses is defined. In probability theory, a random process is usually considered as a one-
parameter family of random variables X(t). In an overwhelming number of applications,
the parameter t represents time, but this parameter can be, for example, a point in space,
and then we usually speak of a random function. In the case when the parameter t runs
through the integer-valued numbers, the random function is called a random sequence.
Just as a random variable is characterized by a distribution law, a random process can be
characterized by a set of joint distribution laws for X(t1), X(t2), …, X(tn) for all possible
moments of t1, t2, …, tn for any n > 0.

3.8 Probability Distribution Functions


In probability theory and statistics, a probability distribution identifies either the
probability of each value of a random variable (when the variable is discrete), or the
probability of the value falling within a particular interval (when the variable is
continuous). The probability distribution describes the range of possible values that a
random variable can attain and the probability that the value of the random variable is
within any (measurable) subset of that range.

Figure 2: The Normal distribution, often called the "bell curve".

When the random variable takes values in the set of real numbers, the probability
distribution is completely described by the cumulative distribution function, whose value at
each real x is the probability that the random variable is smaller than or equal to x.

The concept of the probability distribution and the random variables which they describe
underlies the mathematical discipline of probability theory, and the science of statistics.
There is spread or variability in almost any value that can be measured in a population (e.g.
height of people, durability of a metal, sales growth, traffic flow, etc.); almost all
measurements are made with some intrinsic error; also in physics many processes are
described probabilistically, from the kinetic properties of gases to the quantum mechanical
description of fundamental particles. For these and many other reasons, simple numbers
are often inadequate for describing a quantity, while probability distributions are often
more appropriate.

3.8.1 Probability distributions of real-valued random variables


Because a probability distribution Pr on the real line is determined by the probability of a
real-valued random variable X being in a half-open interval (-∞, x], the probability
distribution is completely characterized by its cumulative distribution function given as:
a. Discrete probability distribution

A probability distribution is called discrete if its cumulative distribution function only


increases in jumps. More precisely, a probability distribution is discrete if there is a finite
or countable set whose probability is 1.
For many familiar discrete distributions, the set of possible values is discrete in the sense
that all its points are isolated points. But, there are discrete distributions for which this
countable set is dense on the real line.
Discrete distributions are characterized by a probability mass function, p such that:

b. Continuous probability distribution

By one convention, a probability distribution μ is called continuous if its cumulative

distribution function is continuous and, therefore, the probability

measure of singletons .

Another convention reserves the term continuous probability distribution for absolutely
continuous distributions. These distributions can be characterized by a probability density
function: a non-negative Lebesgue integrable function ƒ defined on the real numbers such
that

Discrete distributions and some continuous distributions do not admit such a density.

Terminologies
The support of a distribution is the smallest closed interval/set whose complement has
probability zero. It may be understood as the points or elements that are actual members of
the distribution.

A discrete random variable is a random variable whose probability distribution is


discrete. Similarly, a continuous random variable is a random variable whose probability
distribution is continuous.

Some properties
 The probability density function of the sum of two independent random variables is
the convolution of each of their density functions.
 The probability density function of the difference of two independent random
variables is the cross-correlation of their density functions.
 Probability distributions are not a vector space – they are not closed under linear
combinations, as these do not preserve non-negativity or total integral 1 – but they
are closed under convex combination, thus forming a convex subset of the space of
functions (or measures).
In mathematics and, in particular, functional analysis, convolution is a mathematical
operation on two functions f and g, producing a third function that is typically viewed as a
modified version of one of the original functions. Convolution is similar to cross-
correlation. It has applications that include statistics, computer vision, image and signal
processing, electrical engineering, and differential equations

3.9 Summary of Common Probability Distributions


The following is a list of some of the most common probability distributions, grouped by
the type of process that they are related to.
Note that all of the univariate distributions below are singly-peaked; that is, it is assumed
that the values cluster around a single point. In practice, actually-observed quantities may
cluster around multiple values. Such quantities can be modeled using a mixture
distribution.

3.9.1 Related to real-valued quantities that grow linearly (e.g. errors, offsets)

 Normal distribution (aka Gaussian distribution), for a single such quantity; the most
common continuous distribution;
 Multivariate normal distribution (aka multivariate Gaussian distribution), for
vectors of correlated outcomes that are individually Gaussian-distributed;

3.9.2 Related to positive real-valued quantities that grow exponentially (e.g.


prices, incomes, populations)
 Log-normal distribution, for a single such quantity whose log is normally
distributed
 Pareto distribution, for a single such quantity whose log is exponentially
distributed; the prototypical power law distribution.

3.9.3 Related to real-valued quantities that are assumed to be uniformly


distributed over a (possibly unknown) region
 Discrete uniform distribution, for a finite set of values (e.g. the outcome of a fair
die)
 Continuous uniform distribution, for continuously-distributed values.

3.9.4 Related to Bernoulli trials (yes/no events, with a given probability)


 Bernoulli distribution, for the outcome of a single Bernoulli trial (e.g.
success/failure, yes/no);
 Binomial distribution, for the number of "positive occurrences" (e.g. successes, yes
votes, etc.) given a fixed total number of independent occurrences;
 Negative binomial distribution, for binomial-type observations but where the quantity
of interest is the number of failures before a given number of successes occurs‘
 Geometric distribution, for binomial-type observations but where the quantity of
interest is the number of failures before the first success; a special case of the
negative binomial distribution.

3.9.5 Related to sampling schemes over a finite population


 Binomial distribution, for the number of "positive occurrences" (e.g. successes, yes
votes, etc.) given a fixed number of total occurrences, using sampling with
replacement
 Hypergeometric distribution, for the number of "positive occurrences" (e.g.
successes, yes votes, etc.) given a fixed number of total occurrences, using sampling
without replacement
 Beta-binomial distribution, for the number of "positive occurrences" (e.g. successes,
yes votes, etc.) given a fixed number of total occurrences, sampling using a Polya urn
scheme (in some sense, the "opposite" of sampling without replacement)

3.9.6 Related to categorical outcomes (events with K possible outcomes, with a given
probability for each outcome)
 Categorical distribution, for a single categorical outcome (e.g. yes/no/maybe in a
survey); a generalization of the Bernoulli distribution;
 Multinomial distribution, for the number of each type of categorical outcome, given a
fixed number of total outcomes; a generalization of the binomial distribution;
 Multivariate hyper geometric distribution, similar to the multinomial distribution, but
using sampling without replacement; a generalization of the hyper geometric
distribution;

3.9.7 Related to events in a Poisson process (events that occur independently with a
given rate)
 Poisson distribution, for the number of occurrences of a Poisson-type event in a given
period of time
 Exponential distribution, for the time before the next Poisson-type event occurs

3.9.8 Useful for hypothesis testing related to normally-distributed outcomes


 Chi-square distribution, the distribution of a sum of squared standard normal
variables; useful e.g. for inference regarding the sample variance of normally-
distributed samples
 Student's t distribution, the distribution of the ratio of a standard normal variable and
the square root of a scaled chi squared variable; useful for inference regarding the
mean of normally-distributed samples with unknown variance
 F-distribution, the distribution of the ratio of two scaled chi squared variables; useful
e.g. for inferences that involve comparing variances or involving R-squared (the
squared correlation coefficient)
3.9.9 Useful as conjugate prior distributions in Bayesian inference
 Beta distribution, for a single probability (real number between 0 and 1); conjugate to
the Bernoulli distribution and binomial distribution
 Gamma distribution, for a non-negative scaling parameter; conjugate to the rate
parameter of a Poisson distribution or exponential distribution, the precision (inverse
variance) of a normal distribution, etc.
 Dirichlet distribution, for a vector of probabilities that must sum to 1; conjugate to
the categorical distribution and multinomial distribution; generalization of the beta
distribution
 Wishart distribution, for a symmetric non-negative definite matrix; conjugate to the
inverse of the covariance matrix of a multivariate normal distribution; generalzation
of the gamma distribution

4.0 4.0 Self-Assessment Exercise(s)


Answer the following questions:
1. Define probability distribution
2. What is the relationship between a random variable and probability distribution
3. List the distributions related to:
a. Bernoulli trials
b. Categorical outcomes
c. Hypothesis testing
4. The student is expected to familiarize him/herself with these probability distributions
and their applications.

5.0 Conclusion
The basis of simulation is randomness. Here we have discussed this fundamental basis
which offers us the possibility to quantitatively represent uncertainties in simulations.
With Probabilities in simulation we can explicitly represent uncertainties by specifying
inputs as probability distributions.

6.0 Summary
In this unit we discussed the following:
 Defined Probability as
 Discussed the fundamental concepts of probability theory
 The limit theorem
 Random variables and Random processes
 Probability distributions
 Provided a listing of common probability distributions grouped by their related
processes

7.0 Further Readings


 Devore, J. L. (2018). Probability and statistics for engineering and the sciences. Toronto,
Ontario: Nelson.
 Georgii, H. (2013). Stochastics: Introduction to probability and statistics. Berlin: De
Gruyter.
 Giri, N. C. (2019). Introduction to probability and statistics. London: Routledge.
 Johnson, R. A., Miller, I., & Freund, J. E. (2019). Miller & Freunds probability and
statistics for engineers. Boston: Pearson Education.
 Laha, R. G., & Rohatgi, V. K. (2020). Probability theory. Mineola, NY: Dover
Publications.
 Mathai, A. M., & Haubold, H. J. (2018). Probability and statistics: A course for
physicists and engineers. Boston: De Gruyter.
 Pishro-Nik, H. (2014). Introduction to probability, statistics, and random processes.
Blue Bell, PA: Kappa Research, LLC.
 Spiegel, M. R., Schiller, J. J., & Srinivasan, R. A. (2013). Schaums outline of probability
and statistics. New York: McGraw-Hill.
Unit 2: Modelling Methods

Contents
1.0 Introduction
2.0 Intended Learning Outcomes (ILOs)
3.0 Main Content
3.1 Basic Modelling Concepts
3.2 Visual and Conceptual models
3.3 Features of Visual and Conceptual Model
3.4 Cognitive Affordances of Visual Models
4.0 Self-Assessment Exercise(s)
5.0 Conclusion
6.0 Summary
7.0 Further Readings

1.0 Introduction
Modelling is an essential and inseparable part of all scientific activity, and many scientific
disciplines have their own ideas about specific types of modelling. There is little general
theory about scientific modelling, offered by the philosophy of science, systems theory,
and new fields like knowledge visualization.

We create models for representation of the objects within a system together with the rules
that govern the interactions of the objects. The representation may be concrete as in the
case of the spaceship or flight simulators or abstract as in the case of the computer program
that examines the number of checkout stations in service queue.

2.0 Intended Learning Outcomes (ILOs)


At the end of this unit, the student should be able to:
 Define Modelling
 Describe some basic modelling concepts
 Differentiate between Visual and Conceptual models
 Explain the Characteristics of Visual, models

3.0 Main Content


Definitions of Modelling
Modelling is the process of generating abstract, conceptual, graphical and/or mathematical
models. Science offers a growing collection of methods, techniques and theory about all
kinds of specialized scientific modelling. A scientific model can provide a way to read
elements easily which have been broken down to a simpler form.
Model
A scientific model seeks to represent empirical objects, phenomena, and physical processes
in a logical and objective way. All models are simplified reflections of reality, but despite
their inherent falsity, they are nevertheless extremely useful. Building and disputing
models is fundamental to the scientific enterprise. Complete and true representation may
be impossible but scientific debate often concerns which is the better model for a given
task, such as the most accurate climate model for seasonal forecasting.

For the scientist, a model is also a way in which the human thought processes can be
amplified. For instance, models that are rendered in software allow scientists to leverage
computational power to simulate, visualize, manipulate and gain intuition about the entity,
phenomenon or process being represented.

3.1 Basic Modelling Concepts


Modelling as a substitute for direct measurement and experimentation
Models are typically used when it is either impossible or impractical to create experimental
conditions in which scientists can directly measure outcomes. Direct measurement of
outcomes under controlled conditions will always be more accurate than modelled
estimates of outcomes. When predicting outcomes, models use assumptions, while
measurements do not. As the number of assumptions in a model increases, the accuracy
and relevance of the model diminishes.
Modelling language
A modelling language is any artificial language that can be used to express information or
knowledge or systems in a structure that is defined by a consistent set of rules. The rules
are used for interpretation of the meaning of components in the structure.
Simulation
A simulation is the implementation of a model. A steady state simulation provides
information about the system at an instant in time (usually at equilibrium, if it exists). A
dynamic simulation provides information over time. A simulation brings a model to life
and shows how a particular object or phenomenon will behave. It is useful for testing,
analysis or training where real-world systems or concepts can be represented by a model.
Structure
Structure is a fundamental and sometimes intangible notion covering the recognition,
observation, nature, and stability of patterns and relationships of entities. From a child's
verbal description of a snow, to the detailed scientific analysis of the properties of
magnetic fields, the concept of structure is an essential foundation of nearly every mode of
inquiry and discovery in science, philosophy, and art.
Systems
A system is a set of interacting or interdependent entities, real or abstract, forming an
integrated whole. In general, a system is a construct or collection of different elements that
together can produce results not obtainable by the elements alone. The concept of an
'integrated whole' can also be stated in terms of a system embodying a set of relationships
which are differentiated from relationships of the set to other elements, and from
relationships between an element of the set and elements not a part of the relational regime.
There are two types of systems:
1) Discrete, in which the variables change instantaneously at separate points in time and,
2) Continuous, where the state variables change continuously with respect to time.

3.1.1 The process of generating a model


Modelling refers to the process of generating a model as a conceptual representation of
some phenomenon. Typically a model will refer only to some aspects of the phenomenon
in question, and two models of the same phenomenon may be essentially different, that is
in which the difference is more than just a simple renaming. This may be due to differing
requirements of the model's end users or to conceptual or aesthetic differences by the
modellers and decisions made during the modelling process. Aesthetic considerations that
may influence the structure of a model might be the modeller's preferences regarding
probabilistic models vis-a-vis deterministic ones, discrete vs continuous time etc. For this
reason users of a model need to understand the model's original purpose and the
assumptions of its validity.

3.1.2 Factors in evaluating a model


A model is evaluated first and foremost by its consistency to empirical data; any model
inconsistent with reproducible observations must be modified or rejected. However, a fit to
empirical data alone is not sufficient for a model to be accepted as valid. Other factors
important in evaluating a model include:
 Ability to explain past observations
 Ability to predict future observations
 Cost of use, especially in combination with other models
 Refutability, enabling estimation of the degree of confidence in the model
 Simplicity, or even aesthetic appeal

3.2 Visual and Conceptual models


Visualization is any technique for creating images, diagrams, or animations to
communicate a message. Visualization through visual imagery has been an effective way
to communicate both abstract and concrete ideas since the dawn of man. Examples from
history include cave paintings, Egyptian hieroglyphs, Greek geometry, and Leonardo da
Vinci's revolutionary methods of technical drawing for engineering and scientific purposes.
We should not hold a narrow definition of exactly what a visual model should look like.
We should rather use whatever visual elements or styles such as diagrams, maps, graphs,
charts, pictures, cartoons, etc. – that will most effectively represent the problem at hand.

We can however define visual models by what they strive to do, and list some of the
important characteristics that distinguish 'visual models' from other kinds of graphic art.
Visual representation of data depends fundamentally on an appropriate visual scheme for
mapping numbers into graphic patterns (Berlin 1983). One reason for the widespread use
of graphical methods for quantitative data is the availability of a natural visual mapping:
magnitude can be represented by length, as in a bar chart, or by position along a scale, as in
dot charts and scatter plots. One reason for the relative paucity of graphical methods for
categorical data may be that a natural visual mapping for frequency data is not so apparent.

Conceptual model helps you interpret what is shown in a drawing or graph. A good
conceptual model for a graphical display will have deeper connections with underlying
statistical ideas as well.

For quantitative data, position along a scale can be related to mechanical models in which
fitting data by least squares or least absolute deviations correspond directly to balancing
forces or minimizing potential energy (Farebrother 1987).

The mechanical model for least squares regression, for example, likens each observation to
a unit mass connected vertically to a rod by springs of unit modulus. Sall (1991a) shows
how this mechanical model neatly describes the effects of sample size on power of a test,
the leverage of outlying observations in regression, principal components, and collinearity
among others.
Conceptual Modelling
• Is used for abstract (visual) representation of the problem domain
• It serves to enhance understanding of complex problem domains.
• It provides a basis for communication among project team members
3.3 Features of Visual and Conceptual Model
A visual model should:
 Render conceptual knowledge as opposed to quantitative data (information
visualization) or physical things (technical illustration). We usually express
conceptual knowledge with words alone, and yet the meaning behind those words
is often inherently visual. Visual models seek to render directly the image-
schematic (meaning that lies behind our words).
 Be good models - the images should accurately reflect the situation in the world
and embody the characteristics of a useful model.
 Integrate the most salient aspects of the problem into a clear and coherent picture.
 Fit the visual structure to the problem – and not force the problem into a
predefined visual structure.
 Use a consistent visual grammar.
 Should be visually and cognitively tractable. Visual models exist to support robust
qualitative thinking: they're software for 'human-simulation' (as opposed to
computer-simulation) of the issue at hand. To serve as effective 'simulation
software', visual models must be 'readable' and 'run able' by our visio-cognitive
'hardware' and should positively engage our prodigious visual intelligence.
 Tap into the power of elegant design. In other words, they shouldn't be ugly
Conceptual Modelling
 A good conceptual model should NOT reflect a solution bias.
 Should model the problem domain, not the solution domain.
 Initial conceptual model may be rough and general.
 May be refined during incremental development.
3.4 Cognitive Affordances of Visual Models
Due to the limited capacity of our working memory, 7 ± 2 ‗chunks‘ of information, we
cannot hold in our minds concepts, arguments, or problems that consist of more than 5 to 9
objects or relationships. While this cognitive limitation severely restricts our ability to
think about complex things, we can do what we often do: extend our intellectual abilities
with external representations or 'models' of the problem.

The particular affordances diagrams – their ability to simultaneously show many objects
and relationships – make them an ideal tool for thinking about conceptually-complex
problems. Diagrams provide an external mnemonic aid that enables us to see complicated
relationships and easily move between various mind-sized groupings of things.

4.0 4.0 Self-Assessment Exercise(s)

Answer the following questions:


1. Differentiate between modelling and a model
2. What factors are important in evaluating a model?
3. What are the desirable features of a visual model?

5.0 Conclusion
The essence of constructing a model is to identify a small subset of characteristics or
features that are sufficient to describe the behaviour of the system under investigation.
Since a model is an abstraction of a real system and not the system itself, there is therefore,
a fine line between having too few characteristics to accurately describe the behaviour of
the system and more than you need to accurately describe the system. The goal should be
to build the simplest model that effectively describes the relevant behaviour of the system.

6.0 Summary
 We defined modelling as the process of generating abstract, conceptual, graphical
and/or mathematical models. Science offers a growing collection of methods, techniques and
theory about all kinds of specialized scientific modelling.
 We Listed and briefly explained some basic modelling concepts
 Differentiating between Visual and Conceptual models
 we discussed the important factors in evaluating a model to include:
o Ability to explain past observations
o Ability to predict future observations
o Cost of use, especially in combination with other models
o Refutability, enabling estimation of the degree of confidence in the model
o Simplicity, or even aesthetic appeal
 We discussed the features of a good visual model which include:
o Ability to render conceptual knowledge as opposed to quantitative data
(information visualization) or physical things (technical illustration),
o the images should accurately reflect the situation in the world,
o the model should Integrate the most salient aspects of the problem into a clear
and coherent picture,
o Fit the visual structure to the problem,
o It should Use a consistent visual grammar,
o Should be visually and cognitively tractable.
 We also stated the Characteristics of Conceptual models

7.0 Further Readings


 Gordon, S. I., & Guilfoos, B. (2017). Introduction to Modeling and Simulation with
MATLAB® and Python. Milton: CRC Press.
 Zeigler, B. P., Muzy, A., & Kofman, E. (2019). Theory of modeling and simulation:
Discrete event and iterative system computational foundations. San Diego (Calif.):
Academic Press.
 Kluever, C. A. (2020). Dynamic systems modeling, simulation, and control. Hoboken,
N.J: John Wiley & Sons.
 Law, A. M. (2015). Simulation modeling and analysis. New York: McGraw-Hill.
 Verschuuren, G. M., & Travise, S. (2016). 100 Excel Simulations: Using Excel to Model
Risk, Investments, Genetics, Growth, Gambling and Monte Carlo Analysis. Holy
Macro! Books.
 Grigoryev, I. (2015). AnyLogic 6 in three days: A quick course in simulation modeling.
Hampton, NJ: AnyLogic North America.
 Dimotikalis, I., Skiadas, C., & Skiadas, C. H. (2011). Chaos theory: Modeling, simulation
and applications: Selected papers from the 3rd Cghaotic Modeling and Simulation
International Conference (CHAOS2010), Chania, Crete, Greece, 1-4 June, 2010.
Singapore: World Scientific.
 Velten, K. (2010). Mathematical modeling and simulation: Introduction for scientists and
engineers. Weinheim: Wiley-VCH.

You might also like