Anda di halaman 1dari 54

Financial Modelling Using

Excel and VBA

Sylvain Bourjade Toulouse Business School

www.tbs-education.fr
Plan of the Chapter

o Introduction to Financial Modelling


o VBA Reminder
o Simulation in Finance:
Sensitivity Analysis and Monte Carlo Simulations
o Applications

References:
Berk and DeMarzo, Corporate Finance, Prentice Hall.
Benninga, Principles of Finance with Excel, Oxford University Press.
Brealey, Myers and Allen, Principles of Corporate Finance, McGraw Hill.
Holden, Spreadsheet Modeling in Corporate Finance, Prentice Hall.

2 Sylvain Bourjade Toulouse Business School


Organization

o You must have:


o Your computer,
o A memory stick.
You will work within a group of 2.
o Pre-requisites :
o Finance 1 and Finance 2 courses (you should master all concepts).
o Regis Hucs Financial Analysis and Corporate Valuation courses.
o Excels basics tools and functions (This is not an IT course!).

o References :
o Berk & DeMarzo
o S. Benninga, Principles of Finance with Excel, Oxford University Press
o C. W. Holden, Spreadsheet Modeling in Corporate Finance, Prentice Hall
o M. Jackson & M. Staunton, Advanced Modelling in Finance usind Excel and VBA, John Wiley
& Sons

3 Sylvain Bourjade Toulouse Business School


What is Financial Modelling?

Excel, a decision-making tool:

As future managers, you will have to make important (investment) decisions.


These decisions have to be based on facts, numbers, figures, values, anticipations
You will need to implement or to use decision-making tools (for instance, a table or a chart that
represents treasury management, demand forecasts, the sales or the market shares, etc...).
Excel allows you to format teh presentaion of these key elements on which you will have
to base your decision (for instance an histogram).
Excel also allows you to analyze the data you have in order to generate the outputs you
need (for instance: compute to total sales per product).

You have been initiated to Excel during the IT courses to the basics of Excel. You have also seen how to
use Excel and VBA more deeply. We will apply here these concepts to Finance.

4 Sylvain Bourjade Toulouse Business School


Excel in Finance

Excel is an efficient business computational tool:

Financial Functions (ex: NPV, IRR),


o Statistical Functions (ex: mean, standard deviation, variance),
o Advanced Statistical Functions (ex: regressions, tests),
o Solving equations / optimization problems (ex: goal-seek, solver)

That allow to manage uncertainty:


o Make Forecats,
o Evaluate Financial Products,
o Run Sensitivity Analysis.

What is Financial Modelling?


o Generate and Present Results,
o Automate repeated computations,
o Give the flexibility to change the inputs of an example and o immediately get the new output.

5 Sylvain Bourjade Toulouse Business School


The Objectives

Automate:
o Save time: The needs are often repetitive.
o Avoid typos and miscalculation.
o Some tasks could be decentralized.

Clarity:
o Report the results,
o Arguments for decision-making,
o Have an easy mind when you are on leave

How? With a general model that allows


o To include new or updated data,
o Not in the computing cells,
o Well explained,
o User-friendly ,
o And that allows to generate the desired outputs in a particular place/sheet.

6 Sylvain Bourjade Toulouse Business School


Basics Principles (1)

You have to think as a new user:


o If your boss is willing to have a look to the last overview of the forecasted sales (of
course she has deleted your last email),
o If you want your asistant tu update the market data,
o How should they proceed?

Always separate the fields:


In your file, you should separate:
o A sheet dedicated to the explanations.
o One or several sheets dedicated to include new or updated data (for your intern).
o One or several sheets dedicated to generate results (computations, for you or
your intern).
o One or several sheets dedicated to present the results (for your boss).

7 Sylvain Bourjade Toulouse Business School


Basics Principles (2)

Try to build an as general as possible model:


Take into account (at maximum) the potential changes. For instance:
o In the dates: some months have 30 or 31 days,
o Changes in the interest rates from one month to the other,
o Creation of a new subsidiary...

Adopt some conventions:


o Dates/periods in columns and variables in lines.
o Color code (ex: yellow for the inputs, grey for the outputs).

Make the model as clear as possible:


o Replace the references to cells by names,
o Include Comments to explain complex computations,
o A sheet Explanations should include most of the keys elements to understand how to use
the file.

8 Sylvain Bourjade Toulouse Business School


VBA Reminder

Sylvain Bourjade - Toulouse Business School

www.tbs-education.fr
VBA Reminder

o VBA programs allow the user to automatize tasks that may be very long to undertake when they
are made manually

o Open VBA and make a Macro

o Press Alt+F11 or use the menu (Developper -> Macro -> Visual Basic Editor)
Insertion->Module
Sub bonjour()
MsgBox "Je mappelle Jean-Claude Dusse avec un D comme Dusse"
End Sub
o Click run or ALT+F8: A pop-up appears with the message.

10 Sylvain Bourjade Toulouse Business School


VBA Reminder

o Excel can translate your actions into VBA programs


o Example : Record a macro that colors a cell in yellow
o Menu (New macro)
o Attribute a name to the Macro (cellule_en_jaune) then OK
o Color a cell in yellow then stop recording the Macro
o In the module (Alt+F11) you can find the VBA program:

Sub cellule_en_jaune()
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End Sub

11 Sylvain Bourjade Toulouse Business School


VBA Reminder

o A module contains processes or functions

o A process is delimited by Sub and End Sub


Example : Show date and hour in the cell C1
Sub montre_la_date()
Range("C1") = Now()
End Sub

o How to Call a process:


Sub z(a) Sub x()
MsgBox a Call z("ABC")
End Sub End Sub

o z takes an argument a and shows the value "ABC" in a box


o x calls z

12 Sylvain Bourjade Toulouse Business School


VBA Reminder

o A function allows to make an operation and therefore provides a value. You can define a
function in using the keywords Function and End Function

o Example : Make the sum of 2 numbers


Function sommeNo(x, y) Sub Affiche_la_somme()
sommeNo = x + y Msgbox sommeNo(3,5)
End Function End Sub

o Array or table variables allow the user to stock several values


o You have to declare such variables:
dim toto(5) as integer
o This table toto can receive 5 integers. However the index starts at 0: the elements will be
indexed from 0 to 4. To index the elements from 1 to 5:
dim toto(1 to 5) as integer
o Declare a 2 dimensional tables:
dim tab(1 to 10,1 to 10) as integer

13 Sylvain Bourjade Toulouse Business School


VBA Reminder

o Make references to cells


o Row and Column give the number of the line or the column
o Offset allows to shift with respect to a specified cell
range("A1").select selects A1
range("A1:B10").select selects cells from A1 to B10
range("A1, B10").select selects cells A1 and B10.
cells(1,1).select selects A1

o Other references
activecell.offset(0,1).select selects a cell on the same line and on the right
activecell.offset(0,-1).select selects a cell on the same line and on the left
activecell.offset(0,-1).Range("A1:A4").select selects 4 cells on the same line and on the left

14 Sylvain Bourjade Toulouse Business School


VBA Reminder

o Select all non-empty adjacent cells from line 1:


Range("A1", Range("A1").End(xlToRight)).Select

o Select all non-empty cells around A1:


Range("A1").CurrentRegion.Select

o Select all non-empty cells around the active cell:


Range(ActiveCell, ActiveCell.CurrentRegion).Select

o Select all non-empty cells from a column below the active cell:
Range(ActiveCell, ActiveCell.End(xlDown)).Select

o Select all non-empty cells from a line and on the right of the active cell:
Range(ActiveCell, ActiveCell.End(xlToRight)).Select

o Select the last non-empty cell from a column:


ActiveCell.End(xlDown).Select

15 Sylvain Bourjade Toulouse Business School


VBA Reminder

o Conditional Instructions

o Principle: If Then Else


They are currently used in most of Macros
A process If should be followed on the same line by then and is delimited by If and End If
If the condition is true, the instructions following then are realized
Otherwise, the process searches for Else.
If Else is found, the subsequent instructions are realized

How to write them:


If condition then
instructions ..
End If
If condition then
instructions ..
else
instructions...
End If

16 Sylvain Bourjade Toulouse Business School


VBA Reminder

o How to write them:


If condition then
instructions ..
else
instructions...
elseif autre condition
instructions..
End If

o Examples:
If isempty(activecell) then
If activecell.value = "" then
Those processes return True if the Active Cell is empty, otherwise they return False
The keywords And or Or con also be used within a condition:
If activecell.value >10 And activecell.value <20 then
In this case, the condition only returns True if both conditions are satisfied
If activecell.value <10 or activecell.value >20 then
In this case, the condition returns True if at least one of those conditions are satisfied

17 Sylvain Bourjade Toulouse Business School


VBA Reminder

o Loops:
o Loops allow to repeat several times a sequence of instructions

o The loop For Next repeats a sequence of instructions.


o The number of repetitions is determined by the user
o How to write it:
o For meter = beginning to end step next
o Meter is a variable to be defined. Beginning corresponds to the initial value of Meter while End is
the last one. The value of step is 1 by default

o Example:
o Your Excel sheet contains within a column some students first names and in another one their
grades. You are willing to stock those values within a table variable with 2 dimensions.
o Here is the table:

18 Sylvain Bourjade Toulouse Business School


VBA Reminder

Sub stock_tableau2()
Dim tableau()
nb_lignes = Range("A1").End(xlDown).Row
nb_colonnes = Range("A1").End(xlToRight).Column
ReDim tableau(1 To nb_lignes, 1 To nb_colonnes)

For lignes = 1 To nb_lignes


For colonnes = 1 To nb_colonnes
tableau(lignes, colonnes) = Cells(lignes, colonnes)
MsgBox tableau(lignes, colonnes)
Next colonnes
Next lignes

End Sub

Notice that even if this seems very complicated this is much easier than using
references for reading a large table

19 Sylvain Bourjade Toulouse Business School


VBA Reminder

o Do While ... Loop


o This structure is used in order to test if a condition is satisfied. The loop will continue to work as
long as the condition is satisfied. It stops when the condition becomes false
o Example (the variable i is used as a meter and varies between 1 and 10):
i=1
Do While i =< 10
Cells(i, 1) = i
i=i+1
Loop
o If the condition is badly defined, the loop can be infinite. In this case, you can stop it with [ESC]
or [CTRL] + [C].
o Do Until ... Loop
o This loop works until the condition stays True
o Exemple :
i=1
Do Until i = 11
Cells(i, 1) = i
i=i+1
Loop
20
VBA Reminder

o How to link a Macro to a Button


o When other persons use your Macros, it is very convenient to run Macro in clicking on a Button
as they dont know or dont understand your Macros
o In the Developer, select Insert a Button.
o You can choose where to include this button and its size
o Then you have to choose the Macro you will link to this Button.
o You now have to choose the text you are willing to write on the Button.
o When the user will click on this Button, the selected Macro will be executed

21 Sylvain Bourjade Toulouse Business School


VBA Reminder

Illustrations:

o Djia.xls
o You want to make a selective sorting for a very large table (more than 28,000 lines)
o You want to highlight all lines with daily returns exceeding 1%
o You can not modified the order in the table, so that you cannot used the Excel function
o In this case, writing a simple Macro can help you
o Write a Macro that highlights in Yellow all dates for which daily returns exceed 1%

o RAE.xls
o You have to create a button that is able to the Yield to Maturity (RAE or YTM) of a bond

22 Sylvain Bourjade Toulouse Business School


Simulations in Finance

Sylvain Bourjade - Toulouse Business School

www.tbs-education.fr
I. Statistics: The Normal Distribution
We can apply this distribution empirically when there is a large number of
observations (>30 : which is generally the case in finance, otherwise, one
should use the Student distribution).
Why : The central limit theorem (the mean of a sufficiently large number of
independent random variables, each with finite mean and variance, will be
approximately normally distributed.)
Characteristics :
One of the values is frequently observed: the mean
The probability of observing a value far from the mean is low

The Normal Distribution is defined by its mean and its variance (or standard
deviation) => Very simple to use it

Notation for a Normal Distribution with mean m and standard deviation :N(m,).
As this can only be applied to continuous random variables, we compute
p(X<x) or P(X>x), P(X=x)=0.

24 Sylvain Bourjade Toulouse Business School


I. Statistics: The Normal Distribution

Statistics
Turnover
CA total
10 Symmetry / Mean Turnover
8
N 48
Mean 6274.49
6

Standard Dev. 2826.55


Frequency
Frquence

2 Sigma = 2826,55

0
Moyenne = 6274,5
N = 48,00
Minimum 787.7
10 0

11 0
12 0 ,0
13 0 ,0
10
20 , 0

30 0
40 , 0
50 , 0

60 0
70 , 0

80 0
90 , 0

00

00
00
00
00
00

00
00
00

00
00

00
00

Maximum 13426.8
0,

0,
,

CA total

Parameters Mean & Standard Deviation


P(Turnover < x)
P(Turnover >y)

25 Sylvain Bourjade Toulouse Business School


I. Statistics: The Normal Distribution

Density function for a random variable X:


With a mean m
With a variance (or standard deviation )

26 Sylvain Bourjade Toulouse Business School


I. Statistics: The Normal Distribution

Properties
Mean: E(X)=m
Variance: V(X)=

Cumulative Distribution Function of X :


We are willing to compute F(x) = P(X < x) or F(-x)=P(X > x)
P(X<x) represents the area below the curve of the Normal Distribution
density function
When you need other values, you can use the following:
P(X > x) = 1 - P(X < x)
P(X < -x) = P(X > x) = 1 - P(X < x) (with x > 0)
We usually use the standard Normal Distribution: N(0;1), as:
if X follows a N(m;), T=(X-m)/ follows a N(0;1)

27 Sylvain Bourjade Toulouse Business School


I. Statistics: The Normal Distribution

28 Sylvain Bourjade Toulouse Business School


I. Statistics: The Normal Distribution

Properties :
67% of all observations belong to the interval: mean minus 1 standard deviation and
mean plus 1 standard deviation
95% of all observations belong to the interval: mean plus/minus 2 standard deviations
99% of all observations belong to the interval: mean plus/minus 3 standard deviations
If X1 and X2 are 2 independent random variables following respectively N(m1 ;1) and
N(m2;2), then:
X1+X2 follows a N(m1 + m2 ; 12 22 ),
X1-X2 follows a N(m1 - m2 ; 12 22 ),
aX1 follows a N(am1 ; a 1 ).

29 Sylvain Bourjade Toulouse Business School


I. Statistics: Confidence Intervals

Objective :
We have a representative sample with observations of a random variable X that
follows a distribution function depending on a parameter q.
We are willing to find a confidence interval for the parameter q for a given level
of confidence (or a given risk of error)

As we only have a sample of the values that can be taken by X, we have a risk
of error. This risk will be higher when the standard deviation is high and when
our sample is small.

30 Sylvain Bourjade Toulouse Business School


I. Statistics: Confidence Intervals
Example : Confidence intervals for a mean
Let m be an estimator of the mean and be the standard deviation, we can
compute a confidence interval for the mean with an error margin (risk) of r% with
the following formula :

ma
n

where a is such that P ( -a < N(0;1) < a ) = 1 - r% = t%

r% t% a
10% 90% 1,64
5% 95% 2
1% 99% 2,6

We can therefore state that there is a probability t that m belongs to the



interval: m a ;m a
n n

31 Sylvain Bourjade Toulouse Business School


I. Statistics: Usual Excel Functions

MAX(number1 ; number2 ;...),


MIN(number1 ; number2 ;...)
AVERAGE(number1 ; number2 ;...), MOYENNE in French
STDEV(number1 ; number2 ;...), ECARTYPE in French
VAR(number1 ; number2 ;...)

NORM.DIST(value ; mean ; standard deviation ; cumulative), LOI.NORMALE in French


Gives P( N(mean ; standard deviation) < value ) if the cumulative is TRUE and
P( N(mean ; standard deviation) = value ) otherwise.

NORM.INV(probability ; mean ; standard deviation), LOI.NORMALE.INVERSE in


French
Gives the value a such that P( N(mean ; standard deviation) < a ) = probability

NORMSDIST (LOI.NORMALE.STANDARD in French) returns the standard normal


cumulative distribution

NORMSINV (LOI.NORMALE.STANDARD.INVERSE in French) returns the inverse of the


standard normal cumulative distribution

32 Sylvain Bourjade Toulouse Business School


II Simulations in Finance

Simulations allows to use computers in order to imitate the real world or to make
forecasts in order to implement decisions.

When you generate a model with Excel, for instance, this model should include:
Some inputs
Some equations
Solving the model allows Excel to generate the outputs of the model

Most of financial models and this is particularly true in corporate finance) are purely
deterministic For given inputs, they always generate the same result and outputs.

Model

33 Sylvain Bourjade Toulouse Business School


II Simulations in Finance

Examples :
Black et Scholes (r and )
NPV(CFt , r)

Problem: As all financial models (but this is also the case in Economics, Strategy,
Marketing,) are forward-looking , i.e. they are supposed to provide an objective
information today based on future (forecasted) events , they are not, by nature,
deterministic. The mathematical models make them deterministic while they should be
stochastic as they are based on forecasts. As a forecast corresponds to a random
variable, this will generate errors !!!
2 useful tools allow to take into account the stochastic nature of those models:
A sensitivity analysis
Monte-Carlo simulations

34 Sylvain Bourjade Toulouse Business School


III Sensitivity Analysis

A sensitivity analysis consists in analyzing the sensitivity of a financial model to potential


future variations of the inputs values.

The Excel function Data Table allows to it in a quite simple way (from the Excel menu bar,
click on Data, locate the Data Tools panel and click on the "What if Analysis" item, then click
on Data Table).

Method :
You first have to define the data of your base scenario on a particular sheet
The model that will use those data should appear on another sheet
Then, you have to copy the output of the model within a cell
Enter new values for the inputs of your model whether in line or column or
both.
Highlight both the new values & the output of the model you're using. This will
also highlight the cells in which Excel will put the results of the sensitivity
analysis
Apply the function Data Table in stating whether your inputs are in line or
column and enter the cell in which your original input is.
35 Sylvain Bourjade Toulouse Business School
III Sensitivity Analysis

The file sensi.xls computes the NPV of a capital budgeting decision project. We are
willing to analyze the sensitivity of the NPV to variations of both the cost of goods sold
and the cost of capital

There are 5 sheets in the Excel file:


Information defines the problem
Color Code
Definition of the variables
In Base there are the data of the base scenario and the application of Data
Table
Cash Flows states the formulas of the NPV model
Sensi to cost of goods sold provides the analysis of the sensitivity of the
NPV to the cost of goods sold.
Sensi to cost of capital provides the analysis of the sensitivity of the NPV to
the cost of capital

36 Sylvain Bourjade Toulouse Business School


III Sensitivity Analysis

There are some weaknesses with a sensitivity analysis:


The function Data Table only allows variations of the values of two inputs of
the model => What should we do with models using more than 2 forecasted
inputs (which is the case of lots of models).
The user has to choose the interval in which the inputs vary There is
consequently a bias which may be very strong if the user is not an expert
It does not allow to take into account the potential correlation between the
inputs
It does not provide confidence intervals which may be very useful in order to
make an efficient decision

We have the opportunity to solve those problems in making an analysis based on


Monte-Carlo simulations!!!!

The main interest of doing such a sensitivity analysis is therefore the inherent simplicity
of implementing it.

37 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations

Simulation methods are based on the following principle: generating random numbers in
order to simulate a probability distribution. Monte-Carlo Simulations are a reference to the
Monte-Carlo casino. The main idea is that a running simulations is equivalent to spinning a
large number of times an unbiased roulette.

A stochastic model is a model with variables that follows probability distributions. Those
models are frequently used in Finance because most of variables are not known with
certainty (B&S). For instance, one can observe that most of financial assets returns
distribution are close to classic probability distributions (Stock returns can be
approximated by Normal or Log-Normal distributions). Even though this was not the case,
you can think about the Central Limit Theorem.

Simulations consist in mimicking the behavior of a stochastic model in using probability


distributions in order to randomly generate the values of the models parameters.

38 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations
Principle :
The Monte Carlo simulation is a method which consists in evaluating iteratively a
deterministic model using a set of random values as inputs.
This method is particularly interesting when:
o The model is complex
o The model includes uncertainty about more than 2 parameters
o The model is highly nonlinear
Simulations can potentially lead to more than 10 000 evaluations of the model It was
not possible to implement it some years ago as one needs to use powerful computers.
Why and When using Monte-Carlo Simulations?
o When the model is too complex to be solved analytically (eg pricing of American
options, NPV...).
o Where data do not exist (eg new financial product, new good...) to validate an
evaluation model or to compute the profitability of an investment ...

39 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Introduction

Example : sensitivity of an IRR


Sensitivity Analysis vs Simulation

Market Share
4% 5% 6% 7% 8% 4% 5% 6% 7% 8%
1% -5.9 -3.5 -1.2 1.2 3.5 1%

2% -5.3 -2.8 -0.2 2.3 4.8 2%


Operating Margin

3% -4.7 -2.0 0.8 3.5 6.2 3% High Probability

4% -4.1 -1.2 1.8 4.7 7.6 4%


Low Probability
5% -3.5 0.3 2.8 5.9 9.1 5%

6% -2.8 0.5 3.8 7.2 10.5 6%

40 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Introduction
Optimization vs Simulation :

Optimization = You have to find the optimal values for the control variables
(Weights of the assets in a Mean-Variance analysis, ) that maximize or
minimize an objective function (the variance in the previous example)
Even though you have to solve the algorithm numerically, the base principle
is analytical there is only one optimal value!
Simulation = You have to determine the value of an objective function in
simulating the values of the parameters (or the control variables) of the
model
This is a purely empirical method: You only get a distribution for the values of
the objective function.
This allows to analyze the values of the objective function that will occur
with the highest probabilities
This also allows to analyze the volatility of the values of the objective
function around the mean of its distribution

41 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Introduction

How it works?

Model

Confidence

42 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology

(a) (b) (c)


Generate values of the Compute the outputs of the
control variables from model with the values Keep the result
probability distributions generated in (a)

Repeat this operation N times

Then, analyze the probability distribution of the


outputs of the model

43 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology
Repeating the steps a), b) and c) many times allows to compute:
A mean (expectation)
A standard-deviation (dispersion around the mean)
A Probability Distribution for the objective function
Confidence Intervals

How may times should you repeat those steps?


The more observations you have, the better your estimation.
However, this will depend on the complexity of the model you want to simulate as
the time needed to make the simulations may quickly increase
Convergence criterion: You should stop when:
Observing an additional value only enhances marginally the precision of the
estimator
The Confidence Interval is consistent with your anticipations.

Monte-Carlo Simulations allow to analyze a problem both graphically and


statistically as the objective function is the output (The NPV for instance)

44 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology
The output of the model can be:
Either discrete (you can either accept or reject to invest in a project, ) In
this case the probability distribution of the output will be discrete (Bernoulli or
Binomial Probability Distributions)
Or Continuous (Price of a financial asset, Result of a NPV, an IRR, ) In this
case the probability distribution of the output will be continuous (Normal, Log-
normal, Poisson, Student Probability Distributions,)

Reminder on Discrete Probability Distributions:


A density function associated to a random variable X with discrete values gives
the probability that X takes a particular value: f(x) = Proba(X = x)

Assume that we are willing to estimate the market shares of some brands of the car
industry:
- This is difficult because we do not have access to regional data !
- However, one can observe the traffic on the highway and analyze the number
of cars for each brand that drive on the highway X being the Car company
45 Sylvain Bourjade Toulouse Business School
IV Monte-Carlo Simulations: Methodology

Density Function
% d'observation
% of observations selon
for each
lesbrand
diffrentes
Renault 30% marques

PSA 25% 30%


25%
VW 15% 20%
15%
Toyota 10% 10%
5%
Others 20% 0%
Autres
Others Ford
Toyota PSA
PSA Renault
Renault VW
VW

The density function is piecewise linear

46 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology
The cumulative distribution function of a discrete random variable X gives the probability that X
takes a value lower than x: F(x) = Proba(X x).
F(x) is therefore computed in adding all the probabilities from the density function.
If x is the upper bound of the interval, F(x)=1 (all categories are included) => the
cumulative distribution function is also piecewise linear. In the previous example,
this would give:

Density Cumulative Distribution Fonction de rpartition de la for


Function Function Cumulative distribution function
distribution des marques observes
the observed brand
Others 20% 20%
100%
Toyota 10% 30% 80%
60%
PSA 25% 55%
40%
Renault 30% 85% 20%
0%
VW 15% 100% Autres
Others Ford
Toyota PSA
PSA Renault
Renault VW
VW

F(PSA) = P(Others) + P(Toyota) + P(PSA) = 55%

47 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology
Generating random observations from a discrete distribution:
You can use the Excel function random() or alea() in French : This function gives a
number from the interval [0,1] randomly chosen from the Uniform Distribution.

Cumulative Distribution
Fonction Function
de rpartition
(b)
120%
(a) Inversion of the cumulative
100%
Generating a distribution function in order to
number
80% get a value
60% X
between 0 and
1 from the 40%
Uniform 20%
Distribution 0%
1 3 5 7 9 11 13 15 17 19 21 23 25
(c)
The value comes from the
corresponding distribution

48 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology
You can of course generate any value for a discrete random variable using the function
random() and the function int() or ent() in French which rounds a number down to the nearest
integer:
Int((random()*5 +1) simulate random numbers between 1 and 6 from a uniform
distribution (this simulates a dice game), etc.

The density function of a continuous random variable gives the probability that X is in a
neighborhood of x as P(X = x) = 0. We therefore have f(x) = Proba(a X b)

The total area below


0.1 the curve is 100%

0.05

0
Values of the
random variable

49 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology

The cumulative distribution function of a continuous random variable gives the probability that
X takes values lower than x: F(x) = Proba(X x)
You can compute it in integrating the density function
If x is the upper bound of the interval, F(x)=1
The cumulative distribution function of a continuous random variable is continuous

F(x)

f(x)

P(X a) F(a) = P(X a)

a x a

50 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology

Generating random observations from a continuous distribution:

F(x) c.d.f.

(a)
Generating a number between
0 and 1 from the Uniform p
Distribution with random()

Random
observation

(b)
Read the value associated to the random variable from the c.d.f.:
The value comes from the corresponding distribution

51 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology

One can generate values from a continuous random variable that follows a particular
distribution function in combining the Excel function random() with other functions:

Uniform Distribution:
= 10*random() generates a number from the Uniform Distribution between 0 &
10.
= 5 + (2*random()) generates a number from the Uniform Distribution between 5
& 7.
= x + ((y-x)*random() ) generates a number between x & x+y.

Normal Distribution:
= NORMINV(random(),x,y) or LOI.NORMALE.INVERSE in French, generates a
random number from the Normal Distribution with mean x and standard deviation y.

52 Sylvain Bourjade Toulouse Business School


IV Monte-Carlo Simulations: Methodology

The choice of the probability distribution depends on your anticipations concerning the
symmetry and the likelihood of observing values close from the mean and from the lower
and upper bounds of the interval for the inputs of your model.

53 Sylvain Bourjade Toulouse Business School


V Applications

Example 1: You have to evaluate a NPV with Monte-Carlo Simulations: Sim_NPV.xls


You have to simulate the inputs of the NPV Model
You are willing to estimate the probability distribution of the NPV

Example 2: You have to introduce a negative correlation between price and quantity in a
Monte-Carlo Simulation: CF_Simulation.xls
The base random number (between 0 and 1) that should generate the quantity has to depend on the
random nuber that generate the price. For instance, to generate the random nuber for Q, hou may
use the function If and associate a multiplicative coeffeicient > 1 (resp. < 1) depending on the
random number for P (i.e. if it is > or < 0.5). The anti-correlation degree is at your discretion.
Choose Uniform Distributions for price and quantity.
Simulate 500 Prices and quantities
Generate Descriptive statistics and an Histogram for the output.

54 Sylvain Bourjade Toulouse Business School

Anda mungkin juga menyukai