On this page
Book
21 Monte Carlo Simulation
The randomness of simulation methods is based on the generation of a sequence of independent random variables $ X_1,X_2,\ldots,X_n $ evenly distributed over the range $ [0,1] $. The first techniques used to generate random numbers used physical processes, which were accepted as random, for example, coin games, dice games, among others. The first experiments described date back to the 18th century, here we mention Buffon’s experiment. One of the most famous tables of supposedly random numbers, RAND (1955), contained 1 million digits generated by electronic noise. However, for the vast majority of tables of random numbers obtained by physical processes, biases and dependencies were detected.
Instead of developing more efficient machines to generate random numbers, the pioneers of computer theory proposed generating numbers that “resemble” random numbers, through deterministic sequences. For example, Von Neumann proposed the “middle square” method: starting with 8653, its square (74874409) is taken and its middle elements with four digits (8744) are consequently extracted (8744), and so on.
The technique known as Monte Carlo emerged through the work of several mathematicians. Stanislaw Ulam, a Polish mathematician, who participated in the Manhattan Project and proposed the design of thermonuclear weapons to Teller-Ulam, used this idea for this project. While at Los Alamos, he suggested the Monte Carlo method for evaluating complicated mathematical integrals that arise in the theory of nuclear chain reactions. This suggestion led to the development of the Monte Carlo simulation method by Von Neumann, Metropolis and others.
Von Neumann was struck by the idea of doing statistical sampling using computer simulation techniques. The approach appeared to be especially suitable for exploring the behavior of neutron chain reactions in fission devices. In particular, the neutron multiplication rate could be estimated and used to predict the explosive behavior of various nuclear fission weapons. Today the Monte Carlo simulation method is used not only to calculate integrals, but also as a tool to simulate stochastic behaviors, for example, in financial market studies.
21.1 Pseudo-Random Numbers
As previously stated, stochastic simulation methods are based on the ability to generate random numbers that represent a random variable uniformly distributed in $ [0,1] $. In practice, it is not possible to truly randomly generate values from a uniform distribution, however, it is possible to generate, deterministically, a sequence of values that appear to be random and uniformly distributed in the interval $ [0,1] $. In this sense, we generate what are known as pseudo-random numbers.
Definition
A sequence of pseudo-random numbers $ (U_i)_{i\geq 1} $ is a deterministic sequence of numbers from the range $ [0,1] $ which, although they were generated deterministically, appear to be random and uniformly distributed. Furthermore, this sequence has relevant statistical properties.
We understand by relevant statistical properties that any statistical test applied to detect deviations from randomness does not reject the randomness hypothesis. One of the main properties of a sequence of pseudorandom numbers is their lack of predictability. For example, in the method proposed by Von Neumann, if we start with $ 2.100 $ we get $ 4.100, 8.100, 6.100, 2.100, 4.100, \dots $, which leads us to reject this method, because depending on the initial condition, we can generate a sequence with a very small period, in this case 4.
The lack of predictability of pseudo-random numbers establishes a connection between the generation of such numbers and cryptography, the art or science of transforming seemingly random sequences into original data (information).
Next, we will present one of the types of pseudo-random number generators most used in practice, known as the congruential generator method. Such methods are derived from the science of cryptography. In the congruential generator method, we start with an initial value $ X_0 $, called seed and then, recursively, we calculate successive values $ X_n $ with $ n\geq 1 $ in the form
$$X_i=(aX_i+c) \ \text{mod} \ M,$$
in which $ a, c $ and $ M $ are positive integers. In this method, $ d \ \text{mod} \ M $ corresponds to the rest of the division of $ d $ by $ M $. It is important to note that, in this way, each value $ X_n $ belongs to the set $ (0,1,\ldots,M-1) $. For example, if we take $ M=16 $, $ a=1 $ and $ c=1 $, we get $ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,\dots $. The secret of such generators lies in the values of $ M $, $ a $ and $ c $ that provide us with the longest possible period. For details on such generators, see Ripley (1987). In order to determine a number between $ 0 $ and $ 1 $, just divide it by $ M $, that is, we consider the sequence
$$Y_i = \frac{X_i}{M}.$$
Example 1.1
Next, we apply the value-based method $ X_0 = 100 $, $ a = 25 $, $ c = 1313 $, $ M= 1.987.345 $ for the simulation of $ 100.000 $ values. The histogram of generated values provides evidence that the values are evenly distributed over the range $ [0,1] $.

21.1.1 Calculation of integrals
One of the main applications for the simulation of pseudo-random numbers and the basic idea for the development of the Monte Carlo simulation method was the calculation of integrals. In this sense, whether $g: \mathbb{R}\rightarrow\mathbb{R} $ a real function of a real variable and consider the problem of calculating
$$\theta =\int_0^1g(x)dx.$$
In order to calculate this integral, we note that if $ U $ is a random variable uniformly distributed over the interval $ [0,1] $, that is, $ U\sim U[0,1] $, then its probability density function $ f_U $ is given by

Furthermore, the expected value of $ U $ is calculated by
$$\mathbb{E}(U) = \int_0^1f_U(x)dx = \int_0^1dx.$$
In particular, we have that the random variable $ g(U) $ has expected value given by
$$\mathbb{E}(g(U)) = \int_0^1g(x)f_U(x)dx = \int_0^1g(x)dx = \theta.$$
Therefore, if $ U_1,\ldots,U_n $ are independent random variables and uniformly distributed in $ [0,1] $, then $ g(U_1),\ldots,g(U_n) $ are independent random variables with mean $ \theta $. Thus, by the Strong Law of Large Numbers (Kolmogorov’s Strong Law), we have
$$\sum_{i=1}^n\frac{g(U_i)}{n}\rightarrow\mathbb{E}\left[g(U)\right] = \theta$$
when $ n\rightarrow\infty $ with probability $ 1 $.
Conclusion: We can get closer $ \theta $ from the generation of a large amount of random numbers $ U_1,U_2,\ldots,U_n $ with uniform distribution in $ [0,1] $ and then calculate the approximation as the average
$$\hat{\theta_n} = \sum_{i=1}^n\frac{g(U_i)}{n}.$$
In this way, the following algorithm can be used to calculate $ \theta = \int_0^1g(x)dx $.
- Calculate $ n $ random numbers $ U_1,U_2,\ldots,U_n $ evenly distributed in $ [0,1] $ using the congruential generator method.
- Calculate $ g(U_1),g(U_2),\ldots,g(U_n) $.
- Calculate the average of these values.
Example 1.1.1
Calculate an approximation to the integral
$$\theta = \int_0^1\text{sen}(x)dx.$$
Initially, we will calculate this integral analytically. A primitive function for the function $ g(x) = \ \text{sen}(x) $ is the function $ G(x) = -\cos(x) $, therefore, we have the exact value for $ \theta $ is given by
$$\theta = \int_0^1\text{sen}(x)dx = -\cos(x)\Big|^{1}_0 = -\cos(1) + \cos(0) = -0,5403023 + 1 = 0,4596977.$$
Next, we apply the above algorithm to calculate an approximation for $ \theta $ based on the above algorithm and several different values of $ n $. Based on the Strong Law of Large Numbers, we expect that, as $ n $ grows, the result approaches the true value.
| 100 | 0,4727 |
|---|---|
| 1.000 | 0,4646 |
| 10.000 | 0,4637 |
| 100.000 | 0,4601 |
For the more general case, where we need to calculate the integral
$$\theta = \int_a^bg(x)dx$$
in which the limits of integration are not necessarily $ 0 $ and $ 1 $, it is necessary to perform the following variable substitution
$$y = \frac{x-a}{b-a} \Rightarrow dy = \frac{dx}{b-a}$$
and therefore
$$\theta = \int_a^bg(x)dx = \int_0^1g(a+y(b-a))(b-a)dy = \int_0^1h(y)dy$$
in which $h: \mathbb{R}\rightarrow\mathbb{R} $ is given by
$$h(y) = (b-a)g(a+y(b-a))$$
and, in this way, the problem is reduced to the previous case. The following algorithm can be used to calculate $ \theta = \int_a^bg(x)dx $.
- Calculate $ n $ random numbers $ U_1,U_2,\ldots,U_n $ evenly distributed in $ [0,1] $ using the congruential generator method.
- Calculate the values $ Y_i = (b-a)g(a + U_i(b-a)) $ with $ i = 1,\ldots, n $.
- Calculate the average of the values $ Y_i $ with $ i = 1,\ldots,n $.
Example 1.1.2
Calculate the integral
$$\theta = \int_3^7x^3dx.$$
Solving analytically, we have
$$\theta = \int_3^7x^3dx = \frac{x^4}{4}\Big|^7_3= 580.$$
Using the algorithm above to approximate the integral we have, for different values of $ n $, the results obtained are given in the table below.
| 100 | 590,2108 |
|---|---|
| 1.000 | 585,2604 |
| 10.000 | 582,5689 |
| 100.000 | 580,3870 |
In a similar way to the previous one, when we want to calculate the improper integral
$$\theta = \int_0^{\infty}g(x)dx,$$
just apply the following variable substitution
$$y = \frac{1}{x+1} \Rightarrow dy = -\frac{dx}{(x+1)^2} = -y^2dx$$
and so, we obtain that
$$\theta = \int_0^{\infty}g(x)dx = \int_1^0-\frac{g\left(\frac{1}{y}-1\right)}{y^2}dy = \int_0^1\frac{g\left(\frac{1}{y}-1\right)}{y^2}dy = \int_0^1h(y)dy$$
reducing the integral to the initial case.
Note 1.1.1
Se $ g $ is a square integrable function and we consider
$$ \sigma_g^2 := \int_0^1(g(x)-\theta)^2dx$$
then the error $ \hat{\theta}_n - \theta $ in Monte Carlo estimation it is a random variable with normal distribution with mean $ 0 $ and standard deviation $ \sigma_g/\sqrt{n} $ so that the approximation, in fact, becomes better as the value of $ n $. The parameter $ \sigma_g $ is unknown, but can be estimated using the sample standard deviation
$$s_g = \sqrt{\frac{1}{n-1}\sum_{i=1}^n\left(g(U_i)-\hat{\theta}_n\right)^2}.$$
In this way, the functions of the simulated values $ g(U_1),\ldots,g(U_n) $ do not only provide the value of the integral $ \theta $ but also provide an estimate for the error made in the estimate.
Note 1.1.2
The form of the standard error $ \sigma_g/\sqrt{n} $ is a central property of the Monte Carlo method, so to reduce this error by half, it is necessary to increase the number of simulations by a factor of four. Thus, the convergence is of the order of square root, due to the factor $ \sqrt{n} $ in the denominator of the standard error. As an alternative to this method, the error in the trapezoid rule, given by
$$\theta = \frac{g(0)+g(1)}{2n}+\frac{1}{n}\sum_{i=1}^{n-1}g\left(\frac{i}{n}\right)$$
it is in order $ O(n^{-2}) $, at least for class functions $ C^2 $. Therefore, the Monte Carlo method is not a competitive method for calculating integrals of dimension 1.
However, the Monte Carlo simulation method becomes a powerful computational tool for calculating integrals due to the fact that the order of convergence $ O(n^{-\frac{1}{2}}) $ is not restricted to the unit range. In fact, the steps above can be applied to estimate integrals over $ [0,1]^d $ for all dimensions $ d $. Of course, when we change the dimensions, changing the function $ g $ and when we change $ g $, we also changed $ \sigma_g $, but the standard error remains in the form $ \sigma_g/\sqrt{n} $ for Monte Carlo estimation. This means that the order convergence $ O(n^{-\frac{1}{2}}) $ remains the same throughout $ d $. On the other hand, the error evaluated using the trapezoid rule in dimension $ d $ it is in order $ O(n^{-\frac{2}{d}}) $ for class functions $ C^2 $. Thus, as the number of dimensions increases, in the trapezoidal rule, the convergence rate becomes increasingly worse, while in the Monte Carlo method, it remains unchanged. Therefore, the Monte Carlo method is very attractive for calculating multiple integrals when many dimensions are at play. In practice, when the number of dimensions is $ d = 4 $, the convergence rates are equal, however, from $ d \ > \ 4 $, the Monte Carlo method becomes superior.
Then consider $g: \mathbb{R}^d\rightarrow \mathbb{R} $ and suppose that the interest is to calculate
$$\theta = \int_0^1\int_0^1\ldots\int_0^1g(x_1,x_2,\ldots,x_d)dx_1dx_2\ldots dx_d.$$
Similarly, we have $ \theta = \mathbb{E}\left[g(U_1,U_2,\ldots,U_d)\right] $ in which $ U_1,\ldots,U_d $ are independent random variables and uniformly distributed in $ [0,1] $. In this way, to calculate an approximation for $ \theta $, just simulate $ n $ independent sets of $ d $ independent and uniformly distributed random variables in $ [0,1] $ given by $ (U^1_1,U^1_2,\ldots,U^1_d), (U^2_1,U^2_2,\ldots,U^2_d),\ldots,(U^n_1,U^n_2,\ldots,U^n_d) $ and then the estimate for $ \theta $ is given by
$$\hat{\theta} = \frac{1}{n}\sum_{i=1}^ng\left(U^i_1,U^i_2,\ldots,U^i_d\right).$$
Example 1.1.3
Estimate the value of $ \pi $ numerically.
To calculate the value of $ \pi $, consider the circle with unit radius inscribed in the square of vertices $ (-1,-1), (-1,1), (1,-1) $ and $ (1,1) $ as shown in the figure below.



In this way, be $ g: \mathbb{R}^2\rightarrow\mathbb{R} $ given by

So, if we take $ U_1 $ and $ U_2 $ two uniform random variables in $ [0,1] $ independent, we have to
$$\frac{\pi}{4} = \mathbb{E}\left[g(U_1,U_2)\right] = \mathbb{P}\left(X^2 + Y^2 \leq 1\right)$$
In this way, to bring $ \frac{\pi}{4} $, just simulate a quantity $ n $ independent sets of $ 2 $ random variables $ U_1 $ and $ U_2 $ evenly distributed over the range $ [0,1] $ and check the number of points $ (U_1,U_2) $ of the total that are within the hatched region, that is, for each pair generated $ (U^i_1,U^i_2) $ we check if $ g(U^i_1,U^i_2) = 1 $ or if $ g(U^i_1,U^i_2) = 0 $. In this way, we have to
$$\frac{pi}{4} \approx \frac{1}{n}\sum_{i=1}^ng(U^i_1,U^i_2) \Rightarrow \pi \approx 4\frac{1}{n}\sum_{i=1}^ng(U^i_1,U^i_2).$$
In the following figure, the blue points are those whose coordinates $ (U^i_1,U^i_2) $ are such that $ g(U^i_1,U^i_2) = 1 $ and the green ones are those in which $ g(U^i_1,U^i_2) = 0 $.

The algorithm for approximating $ \pi $ can be written considering the steps below.
- We generate the values $ U^i_1 $ and $ U^i_2 $ independent and evenly distributed in $ [0,1] $, for $ i = 1,\ldots,n $.
- We check if $ g(U^i_1,U^i_2) = 1 $ or if $ g(U^i_1,U^i_2) = 0 $, that is, if the ordered pair belongs to the region $ R $ or not.
- We approximate the value of $ \pi $ by
$$\pi = 4\frac{1}{n}\sum_{i=1}^ng(U^i_1,U^i_2).$$
We present below the approximations obtained for $ \pi $ following the algorithm described above and using the values $ n = 100 $, $ n = 1.000 $, $ n = 10.000 $ and $ n = 100.000 $.
| 100 | 3.2 |
|---|---|
| 1.000 | 3.096 |
| 10.000 | 3.1264 |
| 100.000 | 3.14628 |
21.2 Inverse Transform Method
Since we have an efficient way to simulate uniformly distributed random variables in $ [0,1] $, the focus now is to extend this result to the simulation of other probabilistic models. In this sense, we present a widely used method: the inverse transform method.
Suppose we want to simulate random samples of a random variable $ X $ with distribution function $ F $, that is, we want to generate a random variable $ X $ with the property $ F_X(x) = \mathbb{P}(X\leq x) $ for everyone $ x $. In this case, we generate a random variable $ U $ evenly distributed in $ [0,1] $, that is, $ U\sim U[0,1] $ and then, the inverse transform method establishes that the random variable $ X = F_X^{-1}(U) $. The method can be illustrated in the figure below for a hypothetical cumulative distribution $ F $.

To verify that the inverse transform method is, in fact, capable of generating values from a distribution with a cumulative distribution function $ F_X $, just check that
$$\mathbb{P}(X\leq x) = \mathbb{P}(F^{-1}(U)\leq x) = \mathbb{P}(U \leq F(x)) = F(x)$$
where the second equality follows from the fact that, for $ F^{-1} $ as we define it, the events $ (F^{-1}(u)\leq x) $ and $ (u\leq F(x)) $ coincide for all $ u $ and $ x $. The last equality follows from the fact that

We can interpret the value $ U $ of the inverse transform method as the random percentile. Se $ F_X $ is continuous and the random variable $ X $ has distribution $ F_X $, then $ X $ is just as likely to fall between, say, the 20th and 30th percentiles as it is the 85th and 95th percentiles. In other words, the percentile is evenly distributed. In this way, the inverse transform method selects a percentile uniformly and then applies this value to the corresponding value of the random variable.
In order to practically understand the method, we present two applications: the first, in which we want to simulate a discrete random variable and the second, in which we want to simulate a continuous random variable.
Simulation of discrete random variables
Suppose we want to generate a discrete random variable $ X $ which has a probability distribution function given by
$$F_X(x) = \mathbb{P}[X = x_j] = p_j, \quad j=0,1,…, \quad \sum_j p_j = 1$$
To do this, we generate a random number $ U $ such that $ U $ has a uniform distribution over the interval $ [0,1] $. So,

Therefore, if for $ 0 \ < \ a \ < \ b \ < 1, \mathbb{P}(a \le U \le b) = b-a $ we have to
$$\mathbb{P} (X = x_j ) = \mathbb{P} \Bigg ( \sum_{i=1}^{j-1} p_i \le U \le \sum_{i=0}^j p_i \Bigg ) = p_j$$
In this way, $ X $ has the desired distribution above.
In other words, after generating a random number $ U $ we determine the value of $ X $ identifying the range $ [F_X(x_{j-1}), F_X(x_j)] $ for which $ U $ belongs, which is equivalent to finding the inverse function of $ F_X(U) $.
A practical way to use the inverse transform method is to follow the algorithm:
- Generate a random number $ U $ of a uniform distribution $ [0,1] $;
- Se $ U \ < \ p_0 $ do $ X = x_0 $ and stop here;
- Otherwise, if $ U \ < \ p_0 + p_1 $ do $ X = x_1 $ and stop here;
- Otherwise, if $ U \ < \ p_0 + p_1 + p_2 $ do $ X = x_2 $ and stop here;
- $ \vdots $
Example 2.1
Let’s simulate a random variable $ X $ which has the following probability distribution.
$$p_1 = 0,20, \quad p_2 = 0,15, \quad p_3 = 0,25, \quad p_4 = 0,40, \quad \text{onde } p_j = \mathbb{P} (X = j )$$
So, following the algorithm we have
- Se $ U \ < \ 0,20 $ do $ X = 1 $ and stop here;
- Se $ U \ < \ 0,35 $ do $ X = 2 $ and stop here;
- Se $ U \ < \ 0,60 $ do $ X = 3 $ and stop here;
- Otherwise, $ X = 4 $.
Using the above algorithm, we obtained the following results when simulating $ n = 100 $, $ n = 1.000 $, $ n = 10.000 $ and $ n = 100.000 $ values of this random variable.

Simulation of continuous random variables
To simulate continuous random variables, the idea is analogous. To use the inverse transform method for continuous random variables, basically, simply use the inverse of the accumulated distribution function. However, in some cases, we can make the method more efficient through simple modifications.
Example 2.2
Suppose we want to simulate values of a continuous random variable $ X $ which has a cumulative distribution function $ F_X(x) = x^n $ for $ 0 \ > \ x \ > \ 1 $.
In this case, we have the inverse of the function $ F_X(x) = x^n $ is given by $ f(x) = x^{\frac{1}{n}} $ so that
$$x = F^{-1}_X(u) \ \Longrightarrow \ x = u^{\frac{1}{n}}$$
and then, to generate a random variable $ X $ from a random number $ U $, just calculate
$$X = U^{\frac{1}{n}}.$$
Next, we use the inverse transform method to simulate random variables from the main discrete and continuous probabilistic models.
21.2.1 Discrete Probabilistic Models
In this section, we use the discrete inverse transform method to simulate random variables from the main discrete probabilistic models. The models presented are: binomial model, Poisson model and geometric model.
21.2.1.1 Simulation of the Binomial Model
Be $ X $ the number of successes obtained in carrying out $ n $ independent Bernoulli trials. We will say that $ X $ has binomial distribution with parameters $ n $ and $ p $, in which $ p $ is the probability of success on each trial, if its probability function is given by
$$\mathbb{P}[X=k]=\frac{n!}{k!(n-k)!}p^k(1-p)^{n-k}, \quad i = 0,1,…,n$$
Then, we use the inverse transformation method through the recursive identity
$$\mathbb{P}[x = k+1] = \frac{n-k}{k+1} \frac{p}{1-p} \mathbb{P}[X=k]$$
where $ k $ is the current value, $ \mathbb{P}[X=k] $ is the probability of $ X $ if equal to $ k $. Denoting by $ F(k) $ the accumulated distribution function of $ k $ , we can generate random values from a binomial distribution with parameters $ n $ and $ p $ following the following algorithm:
- We generate a random number U from a uniform distribution in the interval $ [0,1] $.
- We start with the values: $ c = p/(1-p) $, $ k = 0 $, $ pr = (1-p)^n, F = pr $.
- Se $ U \ < \ F $, $ X = k $ and stop here.
- Otherwise, $ pr = [c(n-k)/(k+1)]pr $, $ F = F + pr $, $ k = k+1 $
- Return to step 3.
This algorithm will check if $ X= 0, X=1…, X= n $, therefore, the number of attempts to find the value of $ X $ will always be $ 1 + X $.
Example 2.2.1
Let’s generate a number following a Binomial distribution [5,0.3].
Generating $ U = 0,23 $, we have to:
$$c = \frac{0,3}{1 - 0,3} = 0,43$$
$$F = pr = (1 -0,3)^5 = 0,17$$
Following the algorithm in step 3 we have $ U \ > \ F $, therefore
$$pr = [0,43(5-1)/(0 + 1)]0,17 = 0,29$$
$$F = 0,17 + 0,29 = 0,46$$
$$k = 1$$
How $ U \ < \ F $, it follows that the generated number is $ X = 1. $
21.2.1.2 Poisson Model Simulation
We say that a discrete random variable $ X $ follows the Poisson distribution with parameter $ \lambda $, $ \lambda \ > 0 $, if its probability function is given by
$$p_k = \mathbb{P}(X=k)=\frac{e^{-\lambda}\lambda^k}{k!}.$$
Therefore, to determine a relationship to be used in the inverse transform method, we do
$$\frac{p_{k+1}}{p_k} = \frac{\frac{e^{-\lambda}\lambda^{k+1}}{(k+1)!}}{\frac{e^{-\lambda}\lambda^k}{k!}} \ \Longrightarrow \ p_{k+1} = \frac{\lambda}{k+1}p_k, \quad k \ge 0$$
Using the recursion above to generate the probability of the next event when necessary, the algorithm to generate Poisson random variables with mean $ \lambda $ is given by
1 - We generate a random number U from a uniform distribution in the interval $ [0,1] $.
2 - We start with the values: $ k = 0 $, $ p = e^{-\lambda} $, $ F = p $.
3 - If $ U \ < \ F $, $ X = k $ and stop here.
4 - Otherwise, $ p = \lambda p / (k+1) $, $ F = F + p $, $ k = k+1 $
5 - Return to step 3.
Example 2.1.2.1
Let’s generate a number following a Poisson distribution with parameter $ \lambda = 2 $. Following the algorithm, initially assume that we generate U = 0.37. So,
$$k = 0$$
$$p = e^{-2} \approx 0,13$$
$$F = 0,13$$
How $ U \ > \ F $
$$p = (2\ast 0,13)/(0+1) = 0,26$$
$$F = 0,13 + 0,26 = 0,39$$
$$k = 1$$
In this case we have $ U \ < \ F $ So, the generated number is $ X = 1 $.
21.2.1.3 Geometric Model Simulation
Be $ X $ the random variable that gives the number of failures to the first success. We say that $ X $ is a discrete random variable with geometric parameter distribution $ p $, $ 0 \ < \ p \ < \ 1 $, if its probability function is given by
$$\mathbb{P}\left(X=j\right)=(1-p)^{j-1}p, \quad j=1,2,\ldots$$
doing $ q = (1 - p) $ We can rewrite the above equation
$$\mathbb{P}\left(X=j\right) = q^{j-1}p, \ \text{para} \ \quad j=1,2,\ldots.$$
How $ X $ represents the number of failures until the first success, with each attempt having a probability $ p $ successful, we can write
$$\sum_{i=1}^{j-1}\mathbb{P} (X=i) = 1 - \mathbb{P}(X \ > \ j-1) = 1 - q^{j-1}, \quad j=1,2,\ldots.$$
In this way, be $ U $ a random number from a uniform distribution (0,1). We can generate a value of $ X $ doing $ X = j $ when
$$1 - q^{j-1} \le U \ < \ 1 - q^{j} \quad \Longrightarrow \quad q^{j} \ < \ U-1 \le q^{j-1}.$$
Note that $ (U-1) $ also has a uniform distribution (0,1), so, as $ U $ is a random number, we can write
$$q^{j} \ < \ U \le q^{j-1}.$$
So we can define

Using the expression above we encounter a problem when $ 0 \ < \ q \ <\ 1 $, $ \log(q) $ is negative and would change the sign of the inequality. To counter this problem, we use the notation $ \text{Int}() $
$$X = \ \text{Int}\left(\frac{\log(U)}{\log(q)}\right) + 1$$
in which $ \text{Int}(z) $ represents the entire part of $ z $.
Example 2.1.3.1
Let’s generate a number following a geometric distribution with $ p = 0,6 $.
It follows that $ q = 0,4 $, then, given that it was generated $ U = 0,82 $ randomly, we have
$$X = \ \text{Int} \left(\frac{\log(0,82)}{\log(0,4)} \right) + 1 = 1$$
21.2.2 Continuous Probabilistic Methods
In this section, we present random variable simulation methods for the main continuous probabilistic models.
21.2.2.1 Simulation of the Uniform Model [a,b]
To generate uniformly distributed values in the range $ [a,b] $, this $ U \sim U[a,b] $, we just need to calculate the accumulated distribution function $ F_X $, in the form
$$F_X(x)=\int_{a}^{x}\frac{1}{b-a}dx=\frac{x-a}{b-a}, \ \text{para todo} \ a\leq x\leq b.$$
Consider $ U $ a random variable uniformly distributed in $ [0,1] $. So $ F_X(X)=U $ and with this, we obtain that,
$$\frac{X-a}{b-a}=U, \quad t\text{ou seja,} \quad X = a+(b-a)U.$$
Thus, we can generate samples of random variables with uniform distribution $ [a,b] $, through the following algorithm:
1st) Generate Uniform $ [0,1] $;
- Apply the formula $ X=a+(b-a)U $.
Example 2.2.1.1
Let’s generate 2 numbers according to a uniform distribution with $ a=3 $ and $ b=5 $. Considering the randomly generated numbers being 0.27 and 0.51, in a distribution $ U[3,5] $ we have to
$$X_1 = 3+(5-3)\times 0,27 = 3,54.$$
and
$$X_2 = 3+(5-3)\times 0,51 = 4,02.$$
Exercise 2.2.1.1
From the table of random numbers, generate a sample of $ 5 $ numbers according to uniform distribution with $ a=12 $ and $ b=19 $.
21.2.2.2 Simulation of the Triangular Model [a,b]
Consider $ U $ a random variable uniformly distributed in $ [0,1] $, then $ F_X(X)=U $ and with that, for $ 0\leq U\leq \frac{1}{2} $, then, we have to
$$F_X(X)=U, \ \text{ou seja,} \ \frac{2(X-a)^2}{(b-a)^2}=U.$$
Isolating $ X $, we have to
$$X=a+\sqrt{\frac{U}{2}}(b-a),\quad {para } 0\leq U\leq\frac{1}{2}.$$
In the case where $ \frac{1}{2}\leq U\leq 1 $, we have
$$\frac{1}{2}+\frac{(b-a)^2-4(b-X)^2}{2(b-a)^2}=U,$$
and, in this way, isolating $ X $,
$$X=b-(b-a)\sqrt{\frac{1-U}{2}}.$$
Therefore, in general we can define

Thus, we can generate samples of random variables with triangular distribution in the range $ [a,b] $, through the following algorithm:
1st) Generate a sample of a random variable $ U $ with uniform distribution $ [0,1] $;
2nd) If $ 0\leq U\leq\frac{1}{2} $, apply the formula $ X=a+\sqrt{\frac{U}{2}}(b-a) $;
3rd) If $ \frac{1}{2}\leq U\leq1 $, apply the formula $ X=b-(b-a)\sqrt{\frac{1-U}{2}} $.
Another widely used algorithm for Triangular distributions is the following:
1st) Generate two uniforms $ [0,1] $ independent $ U_1 $ and $ U_2 $;
- Apply the formula $ X=a+(b-a)\left(\frac{U_1+U_2}{2}\right). $
Exercise 2.2.2.1
From the table of random numbers, generate a sample of $ 5 $ numbers according to the triangular distribution with $ a=12 $ and $ b=19 $.
21.2.2.3 Normal Model Simulation
Definition 2.2.3.1
The continuous random variable $ X $ has a normal distribution with a mean $ \mu $ and variance $ \sigma^2 $ if your probability density function is given by
$$f(x)=\frac{1}{\displaystyle\sqrt{2\pi\sigma^{2}}}\exp\left[-\frac{1}{2}\left(\frac{\displaystyle x-\mu}{\displaystyle\sigma}\right)^{2}\right],~ -\infty \ < \ x \ < \ +\infty,$$
in which $ -\infty \ < \ \mu \ < \ \infty $ and $ 0 \ < \ \sigma^2 \ < \ \infty $.
In Figure 1 we illustrate some curves of the normal distribution for different values of $ \mu $ and $ \sigma^2 $. Note that the normal distribution tends to be “bell” shaped.

Figure 1: Probability density function of the normal distribution for different values of $ \mu $ and $ \sigma $.
Below, we present the main properties of the normal distribution:
Properties
- $ \mathbb{E}(X)=\mu $;
- $ \text{Var}(X)=\sigma^2 $;
- $ f(x)\rightarrow0 $ when $ x\rightarrow\pm\infty $;
- $ \mu-\sigma $ and $ \mu+\sigma $ are inflection points of $ f(x) $;
- $ x=\mu $ is the maximum point of $ f(x) $, and the maximum value is $ \displaystyle\frac{1}{\sqrt{2\pi\sigma}} $;
- $ f(x) $ is symmetric around $ x=\mu $, that is, $ f(\mu+x)=f(\mu-x) $, for all $ -\infty< x<+\infty $.
Notation: If $ X $ has a normal distribution, with mean $ \mu $ and variance $ \sigma^2 $, we write:
$$X \sim N(\mu,\sigma^2).$$
When $ \mu=0 $ and $ \sigma^2=1 $, we have a standard or reduced normal, and we write $ N(0,1). $

Figure 2: Probability density function of the normal distribution.
Figure 2 illustrates the basic concept of quality system metrics where parts are manufactured and the percentage (or PPM) of parts out of specification are evaluated, see Table 1.
| Specifications | Percentage | Defect PPM |
|---|---|---|
| $ \pm 1\sigma $ | 68,27 | 317300 |
| $ \pm 2\sigma $ | 95,45 | 54500 |
| $ \pm 3\sigma $ | 99,73 | 2700 |
| $ \pm 4\sigma $ | 99,9937 | 63 |
| $ \pm 5\sigma $ | 99,999943 | 0,57 |
| $ \pm 6\sigma $ | 99,9999998 | 0,002 |
Table 1: Quality System Metrics.
The normal model is used in the following situations:
- We do not only have information about the limits of variation of the variable under study, or we do not want to set the limits for the variable under study;
- We assume that the variable is distributed symmetrically around the mean and with probability determined according to the graph and table above.
The most used method to simulate the normal distribution was proposed by Box and Muller (1958):
-
Generate a random variable $ U_1 $ with uniform distribution $ [0,1] $, and take $ Z = 2\pi U_1 $;
-
Generate a random variable $ U_2 $ with uniform distribution $ [0,1] $, and take $ E=-\ln(U_2) $ and $ R=\sqrt{2E} $;
3rd) Take $ X=R\cos(Z) $ and $ Y=R\sin(Z) $ as independent samples from the normal distribution with mean zero and standard deviation 1;
To obtain samples from a normal distribution with mean $ \mu $ and standard deviation $ \sigma $, we just need to apply the following transformation:
$$\theta=\mu+\sigma X.$$
Example 2.2.3.1

Solution: We have to $ \mu=10.000 $, $ \sigma=1.500 $ and be $ X= $deposit
a)
$$\mathbb{P}(X\leq10.000)=\mathbb{P}\left(\frac{X-10.000}{1.500}<\frac{10.000-10.000}{1.500}\right)=\mathbb{P}(Z\leq 0)=0,5=50(porcentagem);$$
b)
$$\mathbb{P}(X\geq10.000)=\mathbb{P}(Z\geq0)= 1 - \mathbb{P}(Z \leq 0) = 0,5=50(porcentagem);$$
c)
$$\mathbb{P}(12.000< X< 15.000)=\mathbb{P}\left[\frac{12.000-10.000}{1.500}\leq Z\leq\frac{15.000-10.000}{1.500}\right]$$
$$=\mathbb{P}\left[\frac{4}{3}\leq Z\leq\frac{10}{3}\right]=\mathbb{P}(1,33\leq Z\leq3,33)$$
$$=0,4997-0,40824=0,09133=9(porcentagem)$$
d)
$$\mathbb{P}(X\geq 20.000)=\mathbb{P}\left(\ Z \geq\frac{20.000-10.000}{1.500}\right)=\mathbb{P}(Z\geq6,67)\cong0.$$
21.2.2.4 Gamma Model Simulation
Definition 2.2.4.1
A continuous random variable $ X $ has Gamma distribution with parameters $ r,\lambda> 0 $, if its probability density function is given by
$$f(x)=\frac{x^{r-1}}{\Gamma(r)\lambda^r}e^{-\frac{x}{\lambda}},\quad {para~todo~} x \ > \ 0,$$
being:
- $ \lambda: $ first shape parameter;
- $ r: $ second shape parameter.
In Figure 1 we illustrate the Gamma distribution for different values of $ \lambda $ and $ r $.

Figure 1: Probability density function of the Gamma distribution for different values of $ \lambda $ and $ r $.
Properties
i) $ \mathbb{E}(X)=r\lambda $;
ii) $ \text{Var}(X)=r\lambda^2. $
The Gamma model is used in the following situation:
- The distribution of the variable behaves as in the graph above.
- We have no way of establishing limits for the random variable, except that it is never less than zero.
Consider $ U $ a random variable with uniform distribution $ [0,1] $, then $ X=\displaystyle\frac{U^{-(r+1)}}{\Gamma(r)\lambda^r}e^{-\frac{U}{\lambda}} $ has Gamma distribution with parameters and $ r $ and $ \lambda $. Thus, we have the following algorithm to simulate the Gamma distribution:
-
Generate a random variable $ U $ with uniform distribution $ [0,1] $;
-
Apply the formula: $ X=\frac{U^{-(r+1)}}{\Gamma(r)\lambda^r}e^{-\frac{U}{\lambda}}. $
Example 2.2.4.1
The cash flow (CF) for the next month follows Gamma distribution with parameters $ \lambda=30 $ and $ r=5200 $. This random variable has a mean equal to $ 156.000 $. Find the standard deviation and probability of the following events:
a) Cash Flow is less than 150,000.00 (reais);
b) Cash Flow is between 158,000.00 (reais) and 161,000.00 (reais);
c) Cash Flow is less than 157,000.00 (reais).
Before calculating these probabilities, let’s present the graph of the probability density function:

Figure 2: Probability density function of the Gamma distribution for $ \lambda=30 $ and $ r=5.200 $, example 1.
a) $ \mathbb{P}[\text{FC} \ < \ 150.000]=0,0025 $;
b)
$$\mathbb{P}[158.000\leq \ \text{FC} \ \leq 161.000]=\mathbb{P}[\text{FC} \ \leq161.000]-\mathbb{P}[\text{FC} \ \leq \ 158.000] = 0,98-0,8226=0,1574;$$
c) $ \mathbb{P}[\text{FC} \ < \ 157.000]=0,6794. $
21.2.2.5 Simulation of the Exponential Model
The exponential distribution is characterized by having a constant failure rate function. The exponential distribution is the only one with this property. It is considered one of the simplest in mathematical terms. This distribution has been used extensively as a model for the lifespan of certain products and materials. It adequately describes the lifespan of insulating and dielectric oils among others.
Definition 2.2.5.1
A continuous random variable $ X $, which takes all non-negative values, will have an exponential distribution with parameter $ \lambda> 0 $, if its probability density function is given by

In Figure 1 we present some graphs of the exponential distribution for different values of $ \lambda $.

Figure 1: Probability density function of the exponential distribution for different values of $ \lambda $.
Properties
i) $ \mathbb{E}(X)=\lambda $;
ii) $ \text{Var}(X)=\lambda^2 $;
iii) $ f(x)\rightarrow 0 $ when $ x\rightarrow +\infty $.
The exponential model is used in the following situation:
- We have information that the distribution of the random variable is asymmetric and behaves like the graph above;
- We have no way of establishing limits for the random variable, except that it is never less than zero.
To simulate the exponential distribution, consider $ U $ a random variable with uniform distribution $ [0,1] $, then $ X=-\lambda\ln(U) $ has exponential distribution with parameter $ \lambda $. Thus, we have the following algorithm to simulate the exponential distribution:
-
Generate a random variable $ U $ with uniform distribution $ [0,1] $;
-
Apply the formula: $ X=-\lambda\ln(U) $.
Example 2.2.5.1
Suppose that the cash flow at a given instant of time follows an exponential distribution with parameter $ \lambda=500 $ (average). Thus, the probability density function is given by:

It follows that the average flow is $ E(T)= 500 $ hours, and the probability that it is greater than the average is:

21.2.2.6 Weibull Model Simulation
The Weibull Distribution was originally proposed by W. Weibull (1954) in studies related to failure time due to metal fatigue. It is often used to describe the lifespan of industrial products. Its popularity in practical applications is due to the fact that it comes in a wide variety of forms, all with one basic property: its failure rate function is monotonous. That is, it is either increasing or decreasing or constant. It adequately describes the life of bearings, electronic components, ceramics, capacitors and dielectrics.
Definition 2.2.6.1
A continuous random variable $ X $ a Weibull distribution with parameters $ \alpha,\delta,\gamma> 0 $, if its probability density function is given by
$$f(t,\alpha,\delta,\gamma)=\frac{\delta}{\alpha}\left(\frac{t-\gamma}{\alpha}\right)^\delta\exp\left[-\left(\frac{t-\gamma}{\alpha}\right)^\delta\right],~t\leq\gamma { e } \alpha,\delta>0,$$
where:
- $ \alpha $ scale parameter, proportional to the mean of the random variable;
- $ \delta $ shape parameter, determines the more or less flat shape of the pdf;
- $ \gamma $ location parameter, lower bound for the random variable.
The probability density function of the Weibull distribution with location parameter ($ \gamma $) equal to zero is given by:
$$f(t,\alpha,\delta)=\frac{\delta}{\alpha}\left(\frac{t}{\alpha}\right)^{\delta-}\exp\left[-\left(\frac{t}{\alpha}\right)^\delta\right],~t\leq0 {~e~} \alpha,\delta \ > \ 0.$$
In Figure 1 we present the Weibull distribution curve for different values of $ \alpha $, $ \delta $ and $ \gamma $.

Figure 1: Probability density function of the Weibull distribution for different values of $ \gamma $, $ \alpha $ and $ \delta $.
Properties
i) $ \mathbb{E}(X)=\alpha\Gamma\left(1+\frac{1}{\delta}\right) $;
ii) $ \text{Var}(X)=\alpha^2 ( \Gamma\left(1+\frac{2}{\delta}\right)-\left[\Gamma\left(1+\frac{1}{\delta}\right)\right]^2) $.
Given that we have the information that the distribution of the random variable is asymmetric and behaves like the graph above, we only establish a lower limit for the random variable.
Consider $ U $ a random variable with uniform distribution $ [0,1] $, then $ X=-\alpha[\ln(U)]^{\frac{1}{\delta}} $ has a Weibull distribution with parameters and $ \alpha $ and $ \delta $. Thus, we have the following algorithm to simulate the Weibull distribution:
-
Generate a random variable $ U $ with uniform distribution $ [0,1] $;
-
Apply the formula: $ X=-\alpha[\ln(U)]^{\frac{1}{\delta}}. $
Example 2.2.6.1
For a certain type of pipe, the scale values $ \alpha $ and in shape $ \delta $ are equal to $ 19,7 $ and $ 41,7 $ kwh. What is the probability of this type of tube complying with at least $ 985 $ h?
$$P[X> 985]=1-\int_{0}^{0,985}\frac{\delta}{\alpha}\left(\frac{t}{\alpha}\right)^{\delta-1}\exp\left[-\frac{t}{\alpha}^\delta\right]dt=\exp\left[-\left(\frac{0,985}{\alpha}\right)^\delta\right]$$
$$=\exp\left[-\left(\frac{0,985}{19,7}\right)^{1,7}\right]=0,994.$$
Therefore, we have that the probability of this type supporting at least $ 985 $ h is from $ 99,4 (porcentagem) $.
21.3 Acceptance-Rejection Method
The acceptance-rejection method is among the most used mechanisms for generating random numbers. Basically, this method generates samples from a distribution of interest by generating candidates from a convenient (known) distribution and then rejecting a subset of the generated candidates. The rejection mechanism is constructed in such a way that the sample that will be accepted, in fact, follows the distribution of interest.
Thus, suppose we want to generate random values of a probability density $ f $ defined in some set $ \mathcal{X} $. In this case, this subset can be a subset of the real line $ \mathbb{R} $, from $ \mathbb{R}^d $ or a more general set. Be $ g $ a density in $ \mathcal{X} $ from which we know how to generate random values and with the property that
$$f(x)\leq cg(x) \ \text{para todo} \ x\in\mathcal{X}$$
for some constant $ c $. In the acceptance-rejection method, we generate an element $ X $ from the density $ g $ and we accept the element with probability $ f(X)/cg(X) $. This method can be implemented when generating an element $ U $ evenly distributed in $ (0,1) $ and then we accept $ X $ if $ U\leq f(X)/cg(X) $. Se $ X $ is rejected, a new candidate is sampled from $ g $ and we repeat the acceptance test. The process repeats until the acceptance test is positive; the accepted value is an element selected from $ f $.
Algorithm
The algorithm of the acceptance-rejection method can be presented in the steps below.
- The value is simulated $ X $ with density $ g $
- A random number is generated $ U\sim U(0,1) $
- Se $ U\leq f(X)/cg(X) $, the value is accepted $ X $ and stop. Otherwise, return to step 1.
Example 3.1
Suppose we want to simulate a random variable $ X $ that assumes the values $ 1,2,\ldots,10 $ with probability $ 0,11; 0,12; 0,09; 0,08; 0,12; 0,10; 0,09; 0,09; 0,10; 0,10 $, respectively. In this way, we have that the density we want to simulate is given by $ f(x) = \mathbb{P}(X = x) $. We will use the acceptance-rejection method to solve the problem from the discrete uniform density in $ 1,2,\ldots,10 $, that is, $ g(x) = \mathbb{P}(Y = x) = 1/10 $ for $ x = 1,\ldots,10 $. For this, we choose $ c $ in the form
$$c = \max_{x}\frac{g(x)}{f(x)} = \frac{0,12}{0,1} = 1,2$$
The algorithm will be as follows:
-
In the first step, we generate a random value $ U_1\sim U(0,1) $ and we take $ Y = \text{int}(10U_1) + 1 $. In this way, we will be generating a random number from the discrete uniform random variable in $ 1,2,\ldots,10 $.
-
In the second step, we generate a random number $ U\sim U(0,1) $.
-
Se
$$U \leq \frac{f(Y)}{cg(Y)}=\frac{f(Y)}{1,2\times 0,1} = \frac{f(Y)}{0,12}$$
then $ X = Y $ and the algorithm stops. Otherwise, return to Step 1.
To check the validity of the acceptance-rejection method, either $ Y $ a sample obtained by the algorithm. In this case, $ Y $ has the distribution of $ X $ conditional on the fact that $ U\leq f(X)/cg(X) $. Thus, for any $ A\subseteq\mathcal{X} $, we have to
$$\mathbb{P}(Y\in A) = \mathbb{P}\left(X\in A|U\leq \frac{f(X)}{cg(X)}\right) = \frac{\mathbb{P}\left(X\in A, U\leq \frac{f(X)}{cg(X)}\right)}{\mathbb{P}\left(U\leq \frac{f(X)}{cg(X)}\right)}.$$
Therefore, given $ X $, the probability of $ U\leq f(X)/cg(X) $ is simply $ f(X)/cg(X) $, since $ U $ is uniform, so the denominator in the above equation is given by
$$\mathbb{P}\left(U\leq \frac{f(X)}{cg(X)}\right) - \int_{\mathcal{X}}\frac{f(x)}{cg(x)}g(x)dx = \frac{1}{c}$$
and then we conclude that
$$\mathbb{P}\left(Y\in A\right) = c\mathbb{P}\left(X\in A, U\leq\frac{f(X)}{cg(X)}\right) = c\int_A\frac{f(x)}{cg(x)}g(x)dx = \int_Af(x)dx.$$
How $ A $ is arbitrary, it follows that $ Y $ has the density $ f $. Furthermore, we have that the probability of acceptance in each attempt is equal to $ 1/c $. As the number of attempts are independent, the number of candidates generated until one is accepted has a geometric distribution with a mean $ c $.
21.4 Risk of Investments in Finance
21.4.1 Introduction
The idea of uncertainty is always related to the occurrence of future events. While the idea of risk is related to the degree of uncertainty that we attribute to possible future situations. Some authors make a distinction between uncertainty and risk, considering uncertainty to be a situation in which no probability has been assigned objectively, but rather subjectively.
The idea of objective probability refers to one that is calculated through past information and knowledge or based on a sequence of real data. Subjective probability refers to the probability established in a qualitative way, that is, without a database as support, which may be based on an assessment by experts, with intuition or the experience of professionals in the field, reflecting personal belief about the occurrence of a certain event.
For these authors, risk is treated as a situation in which we can associate a certain probability distribution. In this sense, we can say that every risk situation admits a certain degree of uncertainty, but not the opposite, that is, uncertainty presents itself as a necessary condition for risk, but not sufficient, due to the need to assign a probability to the concept of risk.
The most common measures to assess risk are the measures dispersion variance, standard deviation and coefficient of variation or the probability associated with a successful event, which are related to the return on investment.
- $ \mu = E(X)= \sum x_i \quad p(x_i) $ (Hope);
- $ \sigma^2 = Var(X) = E(X^2)-E^2(X) $ (Variance);
- $ \sigma = \sqrt{[Var(X)]} $ (Standard Deviation); and
- $ CV = \frac{\sigma}{\mu} \times 100 $ (Coefficient of Variation).
Below, we present the main methods used to evaluate investments.
21.4.2 Investment Assessment
In traditional investment evaluation, the most used instruments are: Internal Rate of Return (IRR), Profitability Index (IL), Uniform Equivalent Annual Value (VAEU), Payback and Net Present Value (VAL) or Capital Recovery. These investment evaluation methods will provide us with conditions to accept or reject an investment.
In the traditional analysis of these methods, future cash flows and discount rates are determined without uncertainty, which simplifies the analysis, but makes it less realistic. For a more realistic analysis, it must be considered that there is uncertainty regarding future events. Initially we will present the above methods in a conventional way and later we will focus our attention on the net present value method, which is more widely accepted, and we will incorporate the concept of degree of uncertainty, to which we will associate a probability distribution.
21.4.2.1 Internal Rate of Return (IRR) Method
This method is based on discounted cash flow to calculate the internal rate of return, which can be defined as the discount rate that makes the net present value of the investment equal to zero, expressed as follows:
$${TIR} = \sum \limits_{t=1}^{n} \frac{FC_t}{(1+i)^t}$$
being that
$ FC_t $ = Project Cash Flow;
$ i $ = Project Interest Rate; and
$ n $ = Project Lifetime.
When deciding on the investment project, when considering the internal rate of return method, this rate must be considered as the discount rate. When the internal rate of return is greater than the discount rate, the investment is considered attractive, otherwise it must be rejected from an economic point of view. As the internal rate of return is calculated on the company’s cash flows and on the company’s total investment, the company’s cost of capital must be considered, that is, the investment must be recommended if the IRR is greater than the cost of capital, otherwise it must be rejected.
21.4.2.2 Profitability Index (IL) Method
The profitability index method is a method that considers the ratio between the net present value of the investment and the Initial Investment Value (I$ _0 $), for a given discount rate. The IL method can be expressed as follows:
$${IL_t} = \frac{\sum \limits_{t=1}^{n} \frac{FC_t}{(1+i)^t}}{I_0}.$$
As shown in the expression above, the project will be recommended whenever the IL is greater than 1, given that the numerator expression, cash flow plus the residual value of the investment, would have to be greater than the value of the initial investment. Therefore, the higher the index, the more attractive the investment will be. On the other hand, if the IL is less than 1, the investment must be rejected.
21.4.2.3 Capital Recovery Time Method (Payback)
It is a method that considers the length of time that would be sufficient for the cash flows generated by the project to cover the initial investment. This method is related to an apparently simple idea, namely, the capital recovery time, therefore, the faster the future cash flow provides capital recovery, the greater the attractiveness of making the investment.
Although companies rarely use the Payback method as a single criterion to make a decision about making an investment, it is an instrument that should be used in an auxiliary and complementary way in decision making, especially when comparing two projects. Using only this investment evaluation criterion can be compromising, as its analysis is restricted only to the capital recovery period, not considering subsequent periods, which are fundamental for investment analysis.
21.4.2.4 Equivalent Uniform Annual Value Method (VAUE)
This method seeks to find a uniform annual series equivalent to an investment’s cash flow, considering a given minimum attractiveness rate. This method can also be used to convert the disbursement of a cash flow and its benefits into the equivalent uniform annual cost and the equivalent uniform annual benefit, respectively. Thus, once the costs and benefits of a cash flow have been transformed into their respective equivalent uniform annual values, we can compare them.
$${VAUE} = \sum \limits_{t=1}^n \frac{FC_t}{(1+i)^t} \times \left[\frac{i \times (1+i)^t}{(1+i)^t -1}\right]$$
in which
$ FC_t $ = Project Cash Flow;
$ i $ = Project Interest Rate;
$ n $ = Project Lifetime.
where the first term on the right side of the expression is the current value of a cash flow and the second term is the capital recovery factor of a uniform series.
21.4.2.5 Net Present Value (NPV) Method
When using the VAL as an instrument for evaluating a given investment, we are interested in knowing whether the project has a value greater than its cost, that is, it is the sum of the values of future cash flows discounted at a certain interest rate obtained during the life of the project minus the initial investment, which can be a negative or positive value.
For the current NPV to be positive, the expected return on the investment must be greater than its opportunity cost. Therefore, an increase in the opportunity cost of the investment, that is, in the interest rate, will imply a reduction in the NPV of the project, and may even make it negative in a given planning horizon.
$${VAL} = - I_0 + \sum \limits_{t=1}^{n} \frac{FC_t}{(1+i)^t}$$
in which
$ FC_t $ = Project Cash Flow;
$ i $ = Project Interest Rate;
$ n $ = Project Lifetime; and
$ I_0 $ = Initial Investment.
Example 4.2.5.1
Obtain the Net Present Value (NPV) of an investment that has the following characteristics:
A future cash flow forecast for $ (reais) $ 45,000.00 in the year $ t_1 $; $ (reais) $ 50,000.00 in $ t_2 $; $ (reais) $ 40,000.00 in $ t_3 $; $ (reais) $ 45,000.00 in $ t_4 $; and (reais) 55,000.00 in $ t_5 $.
Let’s consider:
T = 5 years;
$ I_0 = (reais) 150.000,00 $; and
$ i = 10(porcentagem). $
The Net Present Value of this Investment will be:
$${VAL} = - I_0 + \sum \limits_{t=1}^5 \frac{FC_t}{(1+i)^t}$$
$${VAL} = - 150.000 + \left[\frac{45.000}{(1+0,10)} + \frac{50.000}{(1+0,10)^2} + \frac{40.000}{(1+0,10)^3} + \frac{45.000}{(1+0,10)^4} + \frac{55.000}{(1+0,10)^5}\right]$$
$${VAL} = - 150.000 + 177.170,30$$
$${VAL} = 27.170,30.$$
21.4.2.6 Randomization of Parameters
In the capitalization models presented, the variables used, the interest rate, the cash flow, the period are considered random variables. In practice, we consider only one of these variables as random in each analysis; in general, we take cash flow as a random variable.
When we admit that FC is a random variable, as we cannot know its value at a specific moment in time, we calculate the expected value of the net present value $ \mathbb{E} \text{[VAL]} $ by:
$$\mathbb{E}\text{[VAL]} = \sum \limits_{t=1}^n \mathbb{E}\left[ \frac{FC_t}{(1+i)^t} \right]$$
The variance of net present value $ \text{Var[VAL]} $ will be:
$$\text{Var[VAL]}= \sum \limits_{i=1}^n \text{Var} \left[ \frac{FC_t}{(1+i)^t} \right]$$
The standard deviation of the net present value is called $ \sigma[VAL] $ which is given by the square root of the variance, that is:
$$\sigma \text{[VAL]} = \sqrt{ \text{Var[VAL]}}$$
Example 4.2.5.1 presents a positive Net Present Value, which means that the sum of discounted cash flows is greater than the value of the investment, that is, the investment is worth making. However, it should be noted that we consider a situation in conditions where there is no uncertainty, that is, future cash flows are certain.
When analyzing investment projects we must be careful with the type of risk we consider, since when we make any investment in any real or financial asset we are assuming some type of risk. The total risk to which any investment is subject is presented as follows: systematic risk and unsystematic risk.
Systematic or cyclical risk is defined as that risk due to the idiosyncratic economic, political and social system of any market, that is, the risk determined by the cyclical situation of a nation. In such conditions, diversification in asset portfolio management is recommended as a risk reduction measure, although it is not possible to eliminate it completely.
Non-systematic risk is that risk that is inherent to the asset itself, that is, it is a specific risk of a given real or financial asset, not impacting the other assets in a portfolio.
When we make a decision to make any investment, we must analyze the possible return conditions considering different situations or states of nature. To do this, we can apply some methodologies such as: analysis of an optimistic and pessimistic situation, scenario analysis and sensitivity analysis.
When evaluating two situations, one optimistic and the other pessimistic, we seek to evaluate the return of the project by making pessimistic and optimistic estimates about the parameters of interest.
In scenario analysis, we seek to list the main variables that influence the decision to be made. Once the impact variables have been identified, the parameters are set and the various scenarios are formed. This analysis is usually carried out by a group of people in the field or specialists.
21.4.3 Scenario Analysis
Scenario analysis can be better understood through the following example:
Example 4.3.1
Consider the possibility of an investor purchasing debt securities (C-bond) from the Brazilian government for a term of 6 months. According to data from Gazeta Mercantil, we know that such securities are being traded at a price of around $ 50(porcentagem) $ of face value in the market and with a Brazil risk on the same date reaching 2,449 points.
We are interested here in making an assessment of the value of the C-bond six months from now. A group of market analysts admitted the following scenarios:
Scenario 1: The government proposes a renegotiation of the debt under current conditions, which causes a reduction in its market value to 20 cents of the face value;
Scenario 3: The government pays the debt in reais, but with the condition that if it is converted it requires a premium of $ 25(porcentagem) $;
Scenario 3: The government fulfills its commitments in dollars.
The same group of analysts admits the following probabilities to the above events:
$ \mathbb{P}(C_1)=0,20 $, $ \mathbb{P}(C_2)=0,70 $, $ \mathbb{P}(C_3)=0,10 $ and therefore $ \sum \limits_{k=1}^3 \mathbb{P}(C)=1. $
As the payment method for securities in the international market is linear, we can apply the following simple capitalization expression:
$${Para~o~Valor~Futuro:~} F=A(1 + i \times n)$$
$${Para~o~Valor~Atual:~} A = \frac{F}{(1 + i \times n)}$$
$${Para~o~Valor~dos~Juros:~} i = \frac{F}{A \times n}$$
As holders of Brazilian external debt securities are interested in knowing the value of the bond six months from now, we have:
$${Valor~Esperado~dos~títulos:~} \mathbb{E} [C-bond] = 0,20 \times 0,20 + 0,75 \times 0,70 + 1,00 \times 0,10 = 0,665$$
$$\Longrightarrow \mathbb{E} [C-bond^2] = 0,20^2 \times 0,20 + 0,75^2 \times 0,70 + 1,00^2 \times 0,10 = 0,50175$$
$${Desvio~Padrão:~} \sigma [C-bond] = \sqrt{0,5018-0,665^2} = 0,244$$
The values above show us that the average value of the government debt security six months from now is: 0.665 and with a Standard Deviation of 0.244.
As the objective is to obtain the value of the security and its deviation at the current moment, we apply the current value form for linear interest, also admitting a rate of $ 20(porcentagem) $ per year, that is, close to the Brazil risk, we have the following values:
$$E[VAC-bond] = \frac{E[C-bond]}{1 + i \times n}= \frac{0,665}{1 + 0,20 \times \frac{180}{365}}=0,6053$$
$$\sigma[VAC-bond] = \frac{\sigma[C-bond]}{1 + i \times n}= \frac{0,244}{1 + 0,20 \times \frac{180}{365}}= 0,2221.$$
In the above analysis, we assume that the interest rate (i) and the period are fixed, only the C-bond is a random variable.
The above results tell us that the government debt bond is worth on average $ 57,80(porcentagem) $ from its face value with a deviation of 28.58 cents, which means that the value of the security is between 28.22 and 86.38 cents.
We can also use the coefficient of variation as a measure of relative dispersion:
$$CV = \frac{0,2221}{0,6053} \times 100 = 36,69$$
where it tells us that a deviation in relation to the average of $ 36,69(porcentagem) $, that is, there is a very high risk for government bonds.
As an exercise and curiosity, the reader could calculate the average value and deviation of the future and current values of the C-bond considering the assessment made by Megainvestor George Soros, in which he attributes a probability of $ 50(porcentagem) $ Brazilian government debt restructuring
21.4.4 Sensitivity Analysis
In sensitivity analysis, optimistic and pessimistic estimates are made about a group of variables that have an impact on the return on investment. The variables that influence the Net Present Value or Return on investment, such as market share, sales, variable and fixed costs, among others, are estimated by assigning different values and states of nature. The analysis can be done in a more simplified way assuming independence between the variables, that is, assigning different values to just one variable and keeping the others constant or in a more complex and real way assuming that they are interdependent.
Example 4.4.1
Let’s consider that a certain company makes an initial investment of 150,000,000 dollars and presents the following information regarding expected future earnings over the next ten years:
- Consider that the price of the product is sold for $ U$ 30.00 per unit;
- Imagine that the market size is 75 million products and that the company has a market share of $ 20(porcentagem) $ of the market;
- Let the cost per unit be $ 80(porcentagem) $ of the price sold, that is, $ U$ 24.00;
- The opportunity cost of capital is $ 18(porcentagem) $ per year (Selic rate).
Let’s also assume that the investment was made through the purchase of equipment with a useful life of 10 years, being depreciated linearly and that the income tax rate is $ 30(porcentagem) $ on profit before income tax.
| Value (Dollars) | |
|---|---|
| Total Revenue (1) | 450.000,00 |
| Variable Costs (2) | 360.000,00 |
| Fixed Costs (3) | 40.000,00 |
| Depreciation (4) | 15.000,00 |
| LAIR (5) | 35.000,00 |
| GO (6) | 10.500,00 |
| Net Profit (7) | 24.500,00 |
| Cash Flow (4+7) | 39.500,00 |
Depreciation is added to cash flow because it does not represent an actual outflow of cash.
Using the net present value method we have:
$$\text{VAL} = -150.000 + \sum \limits_{i=1}^{10} \frac{39500}{1,18^10}=27.517,41.$$
The positive Net Present Value above indicates that the investment should be made a priori. However, before making such a decision based solely on forecasting the values in the table above, you must identify the variables that may have the greatest influence on the net present value and attribute some variation in their estimates and thus analyze the impact on the VAL.
As making a decision solely on the predictions in the table above can be very optimistic, we must consider the possibility that these predictions are not the real ones. To do this, we carry out a sensitivity analysis on some variables that impact the company’s cash flow and, consequently, the VAL.
Let’s now consider the following changes in the variables that influence the company’s cash flow:
- The company decides to raise the price per unit by $ 20(porcentagem) $, that is, changing to $ U$36.00;
- With the increase in price, the firm’s market share, which was $ 20(porcentagem) $ of the total goes to $ 14(porcentagem) $, which means a reduction in $ 30(porcentagem) $ in its market share;
- The reduction in market share also caused a reduction in the company’s variable costs. $ 15(porcentagem) $, given that there was a reduction in production factors considered variables.
Considering that the variables changed above are related, we can obtain the following conclusions:
- The effect of the increase in the price of the product in $ 20(porcentagem) $ causing a reduction in the quantity sold $ 30(porcentagem) $ implies that the product has positive price elasticity of demand, that is, an increase in price caused a reduction in quantity proportionally greater than the reduction in price.
Price elasticity of demand:
(there are missing elements in the equation above)
$ \Delta $Q: represents the variation in quantity sold;
$ \Delta $P: represents the variation in prices;
Q: price; and
Q: quantity sold.
- With the reduction in market share there was consequently a reduction in the company’s variable costs. However, as the reduction in variable costs was $ 15(porcentagem) $, while the reduction in market share was $ 30(porcentagem) $, that is, a reduction proportionally smaller than the reduction in the use of variable production factors, we say that there is a positive expenditure elasticity.
Expense elasticity:
(there are missing elements in the equation above)
$ \Delta $Q: represents the variation in quantity sold;
$ \Delta $CT: represents the variation in costs;
CT: production cost; and
Q: quantity sold.
With the information above, we will prepare a new forecast for the company’s cash flow and net present value. In the sensitivity analysis carried out here we consider that there is an interdependence between the variables that influence the NPV, making the analysis more real than if it were carried out considering independence between the variables. Therefore, the forecast of future cash flows would be presented as follows:
| Value (Dollars) | |
|---|---|
| Total Revenue (1) | 478.000,00 |
| Variable Costs (2) | 306.000,00 |
| Fixed Costs (3) | 40.000,00 |
| Depreciation (4) | 15.000,00 |
| LAIR (5) | 17.000,00 |
| GO (6) | 5.100,00 |
| Net Profit (7) | 11.900,00 |
| Cash Flow (4+7) | 26.900,00 |
Using the net present value method we have:
$$\text{VAL} = -150.000 + \sum \limits_{i=1}^{10} \frac{26900}{1,18^{10}}=-29.109,08.$$
The result above shows us a negative net present value, indicating that the investment is no longer attractive. This occurred due to the change in the price of the product and a possible reduction in market share, also impacting other variables, as there is an interdependence between the variables that influence the company’s cash flow and that must be considered in the investment analysis.
Considering elasticities when preparing investment analysis is of great importance, as it gives us an idea of how variation in one variable can affect other variables. The example above gives us an idea of how we should carry out a sensitivity analysis considering the interdependence between the variables, that is, in the sensitivity analysis we should consider optimistic, pessimistic values and those most likely for each variable. In a more complex analysis, it would be very useful to investigate the project behavior considering different scenarios and various combinations.
In the above analysis we consider that the product was traded in a market close to competitive, in which the price elasticity of demand is positive. However, the reader could, as an exercise, consider a market close to oligopoly in which the price elasticity of demand is negative.
In many situations it would be convenient to present the question of how the variables impact the NPV as follows: What is the quantity of sales or price increases, for example, that could make the project inconvenient, that is, with a negative net present value. Or even, from what sales volume would the company have a positive VAL? This approach is known as break-even analysis.
To answer the question above, we would have to find the point at which the net present value was equal to zero and then obtain the sales volume compatible with VAL = 0. Thus, in the example we would have to find the sales volume at which the following would result:
$$\text{VAL}= -150.000 + \sum \limits_{i=1}^{10} \frac{FC_t}{(1+i)^t}= 0.$$
In this case, we would find the following cash flow for which the net present value is equal to zero:
$$FC = \frac{150.000}{\frac{(1+i)^n - 1}{(1+i)^n \times i}} = \frac{150.000}{\frac{(1+0,18)^{10} - 1}{(1+0.18)^{10} \times 0,18}} = \frac{150.000}{4,494} = 33.377,20.$$
where the denominator is the current value factor for a uniform series with a rate of $ 18(porcentagem) $ per year and a period of 10 years. The value of $ U$ 33,377.20 represents the cash flow that the company would have if its net present value was equal to zero.
| Value (Dollars) | |
|---|---|
| Total Revenue (1) | 406.265,20 |
| Variable Costs (2) | 325.012,56 |
| Fixed Costs (3) | 40.000,00 |
| Depreciation (4) | 15.000,00 |
| LAIR (5) | 26.253,14 |
| GO (6) | 7.875,94 |
| Net Profit (7) | 18.377,20 |
| Cash Flow (4+7) | 33.377,20 |
Thus, once the cash flow above was found, we would have the following net present value of the investment:
$$\text{VAL} = -150.000 + \sum \limits_{i=1}^{10} \frac{33.377,20}{(1+i)^{10}}= 0.$$
With total revenue of $ U$ 406,265.70, for the same sales price we would have to have the sales volume reduced from $ U$15,000,000.00 to $ U$13,542,000.00 approximately, that is, a sales volume that would provide us with a net present value equal to zero. Therefore, this would answer our initial question, which is, from what sales volume would we start to obtain a positive net present value. In this example, for simplicity, we are assuming that the other variables are remaining constant.
(image missing)
In this break-even point analysis, other questions of a similar nature could be asked regarding, for example, the opportunity cost of the invested capital, that is, what would be the minimum attractiveness rate that could provide a positive net present value. The same could be done for other variables of interest.
In a more complex and real analysis, we could consider the effect of changing several economic variables, simultaneously, which would affect the net present value of the investment project. This analysis combining all possible changes in variables can be done via Monte Carlo simulation, which we will discuss later.
The VAL assessment is made on the future cash flow discounted at a certain interest rate, however, the problem here is knowing with certainty what the future cash flow of the investment will be. To introduce the idea of risk, considering the probability distribution that the net present value may assume, we will present the following example:
Example 4.4.2
Consider purchasing a machine with a given cash flow at an attractiveness rate of 10 (percentage) per year and with the following probabilities of changes in cash flow values. Let’s assume the following sequence of cash flows $ (F_k )_{k=3} = (F_1, F_2, F_3 ) $ with the following probabilities $ \mathbb{P}(F_1), $ $ \mathbb{P}(F_2), $ $ \mathbb{P}(F_3), $ given below. Furthermore, we admit that the cash flow (CF) variables are independent between specific times.
| $ \bold{F_1} $ | $ \bold{\mathbb{P}(F_1)} $ | $ \bold{F_2} $ | $ \bold{\mathbb{P}(F_2)} $ | $ \bold{F_3} $ | $ \bold{\mathbb{P}(F_3)} $ |
|---|---|---|---|---|---|
| 500 | 0,7 | 600 | 0,6 | 550 | 0,7 |
| 650 | 0,2 | 550 | 0,4 | 600 | 0,3 |
| 600 | 0,1 |
For each flow above we have more than one alternative, that is, for the flow we have three possibilities of occurrences: 500 with probability 0.70, 650 with probability 0.20 and 600 with probability 0.10. Our problem here is to determine the expected value $ \mathbb{E} \text{[VAL]} $ and the standard deviation $ \sigma \text{[VAL]} $ net present value.
The distribution of $ F_1 $ will have $ k_1=3 $ elements, $ F_2 $ will have $ k_1=2 $ and $ F_3 $ with $ k_1=2, $ that is, we will have the total of $ k_1 \times k_2 \times k_3 = 12 $ elements. For each combination of cash flows between periods, we will have a corresponding net present value. In total we have 12 $ (3 \ast 2 \ast 2) $ possible combinations. Next, we calculate the NPV of each combination:
(image missing)
$$\text{VAL}_1 = \frac{500}{1,10} + \frac{600}{1,10^2} + \frac{550}{1,10^3} = 1.363,64$$
$$\text{VAL}_2 = \frac{500}{1,10} + \frac{600}{1,10^2} + \frac{500}{1,10^3} = 1.326,07$$
(image missing)
$$\text{VAL}_3 = \frac{600}{1,10} + \frac{600}{1,10^2} + \frac{550}{1,10^3} = 1.454,55$$
$$\text{VAL}_4 = \frac{500}{1,10} + \frac{550}{1,10^2} + \frac{550}{1,10^3} = 1.322,31$$
(image missing)
$$\text{VAL}_5 = \frac{550}{1,10} + \frac{550}{1,10^2} + \frac{550}{1,10^3} = 1.367,69$$
$$\text{VAL}_6 = \frac{600}{1,10} + \frac{550}{1,10^2} + \frac{550}{1,10^3} = 1.413,22$$
(image missing)
$$\text{VAL}_7 = \frac{500}{1,10} + \frac{600}{1,10^2} + \frac{600}{1,10^3} = 1.401,20$$
$$\text{VAL}_8 = \frac{550}{1,10} + \frac{600}{1,10^2} + \frac{600}{1,10^3} = 1.446,66$$
(image missing)
$$\text{VAL}_9= \frac{600}{1,10} + \frac{600}{1,10^2} + \frac{600}{1,10^3} = 1.492,11$$
$$\text{VAL}_{10} = \frac{500}{1,10} + \frac{550}{1,10^2} + \frac{600}{1,10^3} = 1.359,88$$
(image missing)
$$\text{VAL}_{11}= \frac{550}{1,10} + \frac{550}{1,10^2} + \frac{600}{1,10^3} = 1.405,33$$
$$\text{VAL}_{12} = \frac{600}{1,10} + \frac{550}{1,10^2} + \frac{600}{1,10^3} = 1.450,79$$
| Flow | $ \text{Val} $ | $ \mathbb{P}\text{[Val]} $ | $ \mathbb{E}\text{[Val]} $ | $ \mathbb{E}\text{[Val]} \times \mathbb{P}\text{[Val]} $ |
|---|---|---|---|---|
| 1 | 1.363,08 | 0,294 | 400,75 | 546.248,20 |
| 2 | 1.409,08 | 0,084 | 118,36 | 166.782,54 |
| 3 | 1.454,53 | 0,042 | 61,09 | 88.857,62 |
| 4 | 1.322,31 | 0,196 | 259,17 | 364.454,06 |
| 5 | 1.367.69 | 0,056 | 76,59 | 111.841,10 |
| 6 | 1.413,22 | 0,028 | 39,29 | 55.638,38 |
| 7 | 1.401,20 | 0,126 | 176,55 | 247.383,54 |
| 8 | 1.446,66 | 0,036 | 52,08 | 75.341,70 |
| 9 | 1.492,11 | 0,018 | 26,86 | 40.075,06 |
| 10 | 1.359,88 | 0,084 | 114,23 | 155.338,98 |
| 11 | 1.405,33 | 0,024 | 33,73 | 47.398,86 |
| 12 | 1.450,79 | 0,012 | 17,41 | 25.257,40 |
| Total | - | 1 | 1376,11 | 1.924.617,44 |
The probability of each combination was calculated assuming independence between periods. The expected value and standard deviation for discounted cash flows are obtained as follows:
$$\mathbb{E}\text{[VAL]} = \sum \text{VAL} \times \mathbb{P}\text{[VAL]} = 1.376,11$$
$$\mathbb{E}\text{[VAL}^2\text{]} = \sum \text{VAL}^2 \times \mathbb{P}\text{[VAL]} = 1.924.617,44$$
$$\sigma\text{[VAL]} = \sqrt{1.924.617,44 - 1.376,11^2} = 175,89.$$
The results above indicate an average discounted cash flow value of 1,376.11, with a standard deviation of 175.89. Logically, the assessment of whether the investment should be made or not depends on the value of the initial investment, and consequently, whether the net present value is positive or negative.
We could also calculate the coefficient of variation, which represents a relative measure of the dispersion associated with the investment, that is, a measure of risk, defined as the ratio of the deviation from the mean:
$$CV = \frac{175,89}{1.376,11} = 0,1278.$$
The above coefficient of variation tells us that there is a risk associated with the project of around $ 12,78(porcentagem) $, meaning a small degree of relative dispersion. If there is another project, it would be interesting to compare the two coefficients, and the choice regarding the index would be for the one that was lower.
The example above presents an idea of how the distribution of a discounted cash flow, at a given interest rate, is constructed when the investment is analyzed considering the risk. However, there are situations in which we are interested in transforming a given amount of money into an equivalent series of uniform payments. For example, given the net present value of a certain value, what is the equivalent annual series of this net present value, since it would be difficult for us to predict equal future cash flows.
In this sense, when the purpose is to transform discounted cash flows, for a given opportunity cost, into an equivalent uniform annual series, we use the Equivalent Uniform Annual Value - VAUE method. Below we will present an example with the VAUE considering a situation in which there is uncertainty.
Example 4.4.3
Consider that the purchase of a machine provides a uniform annual value initially given by the following cash flow and with the following probabilities:
| $ \bold{F_1} $ | $ \bold{\mathbb{P}(F_1)} $ | $ \bold{F_2} $ | $ \bold{\mathbb{P}(F_2)} $ |
|---|---|---|---|
| 150 | 0,8 | 170 | 0,7 |
| 120 | 0,1 | 120 | 0,3 |
| 80 | 0,1 |
The expected value of flows $ F_1 $ and the $ F_2 $ are:
$$F_{\mu_1} = 150 \times 0,80 + 120 \times 0,10 + 80 \times 0,10 = 140$$
$$F_{\mu_2} = 170 \times 0,70 + 120 \times 0,30 = 155$$
And standard deviation of cash flows by:
$$\mathbb{E}[F_1^2] = \sum \limits_{t=1}^3 F_1 \times \mathbb{P}(F_1) = 150^2 \times 0,80 + 120^2 \times 0,10 + 80 \times 0,10 = 20.080$$
$$\mathbb{E}[F_2^2] = \sum \limits_{t=1}^2 F_1 \times \mathbb{P}(F_2) = 170^2 \times 0,70 + 120^2 \times 0,30 = 24.550$$
$$S(F_1)= \sqrt{\mathbb{E}[F_1^2] - \mathbb{E}[F_1]^2} = 20.080 - 140^2 = 21,91 $$
$$S(F_2)= \sqrt{\mathbb{E}[F_2^2] - \mathbb{E}[F_2]^2} = 24.550 - 155^2 = 22,91, $$
therefore the deviation will be given by:
$$\sqrt{\sum \limits_{t=1}^2[S(F_t)]^2 + 2 \times \sum S_1(F_1) \times S_2(F_2)} = 44,81.$$
We are interested here in calculating the net present value of the uniform annual series. To do this, we will consider a period of five years at an opportunity cost of $ 10(porcentagem) $ per year. In this case, therefore, we have the following expected VAL:
$$\mathbb{E}\text{[VAL]} = \mathbb{E}[F_t] \times \frac{(1+i)^n - 1}{(1+i)^n \times i} = 559,14,$$
being that $ \mathbb{E}[F_t] $ is the uniform series of cash flows, which for simplicity is considered as the general average:
$ \sum\limits_{t=1}^T \frac{F_t}{n}=147,50, $ and the second term on the right side of the equation is the current value factor of an equivalent uniform annual series, given by the sum of the terms of a geometric progression. The standard deviation of the uniform annual value and its coefficients are represented respectively by:
$$S\text{[VAL]} = S(F_t) \times \sqrt{\frac{(1+i)^{2n}-1}{[(1+i)^2-1]\times (1+i)^{2n}}+ \frac{2}{i} \sum \limits_{t=1}^{n-1} \frac{(1+i)^{n-1}-1}{(1+i)^{n+t}}}$$
$$S\text{[VAL]} = 44,81 \times \sqrt{2,9260 + \frac{2}{0,10} \times 0,3102} = 135,40$$
$$CV = \frac{S\text{[VAL]}}{\mathbb{E}\text{[VAL]}} \times 100 = \frac{135,40}{559,14} \times 100 = 0,2422$$
The value of 559.14 represents the current value of a uniform series, given by cash flows of 147.50 in five years at an interest rate of 10 (percentage) per year. The value of 135.40 represents the standard deviation of the net present value of the uniform annual series. While, the CV of 24.22 (percentage) means a relative dispersion of average degree of the uniform annual value.
21.4.5 Probability Distribution
When we analyze an investment project involving risk, we must consider the probability distribution that can best represent the set of values we are interested in. Among investment evaluation methods, the most extensively used is the discounted cash flow method or net present value of the project. In this method, as already described, we are interested in the future cash flows that the investment will provide, which will be updated at a given opportunity cost. In this sense, we would have to identify a probability distribution for each variable that has an influence on cash flow.
We will show some examples of how some probability distributions can be used in different situations in investment analysis.
Below we will present an example of a binomial distribution. A binomial distribution has a sequence of $ n $ identical and independent experiments and has the following representation: Observations $ X_1, X_2,\ldots,X_k $ have binomial distribution with parameters $ (n , p) $ and sample size $ n, $ where each experiment admits two results: success with probability $ p $ or failure with probability $ (1 - p). $
The binomial distribution can be written as:
$$\mathbb{P}(X = k) = \binom{n}{k} p^k (1-p)^{n-k}, \quad k=0,1,2,\ldots,n.$$
Example 4.5.1
Suppose a machine was purchased from a certain supplier without knowing the net present value of each machine. However, it is known that the following possibilities exist regarding the net present value of each machine:
$$E_1 = {\text{VAL} \ > \ 0} \quad \text{e} \quad E_2 = {\text{VAL} \ > \ 0}.$$
A group of experts analyzing the machines available for purchase assigned the following probabilities to possible events:
$$\mathbb{P}(E_1) = p = 0,70 \quad {e} \quad \mathbb{P}(E_2) = 1 - p = 0,30.$$
Out of a total of 10 machines, we want to know the probability that 7 machines have a $ \text{VAL} \ > \ 0 $ and 3 machines have a $ \text{VAL}\ > \ 0. $
To know this probability we apply the binomial formula.
$$\binom{10}{3} 0,7^7 (1-0,7)^3= 0,2668.$$
The result above tells us there is $ 26,68(porcentagem) $ probability of 7 machines having a $ \text{VAL} \ > \ 0 $ and 3 machines have a $ \text{VAL} \ > \ 0 $.
An extension of the binomial distribution is the multinomial distribution. A multinomial distribution has a sequence of $ n $ identical and independent experiments. The observations $ X_1, X_2,\ldots,X_k $ have multinomial distribution with parameters $ \theta_1, \theta_2,\ldots, \theta_k $ and sample size $ n, $ represented by:
$$\mathbb{P}(X_1, X_2,\ldots,X_k|\theta_1, \theta_2,\ldots, \theta_k) = \frac{n!}{X_1! X_2!\ldots X_k!} \theta_1^{x_1} \theta_2^{x_2} \ldots \theta_k^{x_k}.$$
Example 4.5.2
Suppose a machine was purchased from a certain supplier without knowing the net present value of each machine. However, it is known that the following possibilities exist regarding the net present value of each machine:
$$E_1 = {150 \leq \text{VAL} \leq 190}; \quad E_2 = {130 \leq \text{VAL} \leq 150} \quad \text{e} \quad E_3 = {80 \leq \text{VAL} \leq 100}.$$
A group of experts, together with information from suppliers analyzing the machines available for purchase, assigned the following probabilities for the events:
$$\mathbb{P}(E_1) = \theta_1 = 0,50; \quad \mathbb{P}(E_2) = \theta_2 = 0,30 \quad \text{e} \quad \mathbb{P}(E_3) = \theta_3 = 0,20.$$
Out of a total of 10 machines, we want to know the probability of 5 machines having a VAL between 150 and 190, 3 machines having a VAL between 130 and 150 and 2 machines having a VAL between 80 and 100.
To know this probability we use the multinomial distribution.
$$\frac{10!}{5!3!2!} \times 0,50^5 \times 0,30^3 \times 0,20^2 = 0,085 = 8,5(porcentagem).$$
The previous result tells us there is $ 8,5(porcentagem) $ probability of 5 machines having a VAL between 150 and 190, 3 machines having a VAL between 150 and 130 and 2 machines having a VAL between 80 and 100.
21.4.6 Stochastic Simulation
Example 4.6.1
Let’s consider that a certain company makes an investment and presents the following information regarding expected future earnings over the next ten years:
- Consider that the price of the product is sold for 30.00 (reais) per unit;
- Imagine that the market size is 75 million products and that the company has a market share of $ 20(porcentagem) $ of the market;
- Let the cost per unit be $ 80(porcentagem) $ of the price sold, that is, 24.00 (reais)
- The opportunity cost of capital $ 18(porcentagem) $ per year (selic rate).
Let’s also assume that the investment was made through the purchase of equipment with a useful life of 10 years, being depreciated linearly and that the income tax rate is $ 30(porcentagem) $ on profit before income tax.
| Investment: 150,000.00 | Value |
|---|---|
| Total Revenue (1) | 450.000,00 |
| Variable Costs (2) | 360.000,00 |
| Fixed Costs (3) | 40.000,00 |
| Depreciation (4) | 15.000,00 |
| LAIR (5) | 35.000,00 |
| GO (6) | 10.500,00 |
| Net Profit (7) | 24.500,00 |
| Cash Flow (4+7) | 39.500,00 |
The depreciation account is added to the cash flow due to the fact that it does not represent an effective outflow of money.
Using the net present value method we have:
$$\text{VAL} = -150.000 + \sum \limits_{t=1}^{10} \frac{39500}{1,18^{t}}=27.517,41.$$
To carry out the stochastic simulation, we will establish the relationships between the variables established in the table above. In general, we cannot assume that the variables are independent.
Below, we present a suggestion for simulating cash flow. We repeat the 9 steps described below 3 thousand times and analyze the risk contained in the investment.
- Total Revenue (RT) = Product Unit Value (VUP) $\times$ Quantity Sold (QV)
To simulate total revenue (RT), we will simulate the quantity sold (QV) and take the unit value of the product (VUP) as fixed. To do this, we follow the steps:
- Study the random variable of interest (QV). Analyze historical data and/or the experience of the personnel involved;
- Determine the distribution that best describes the behavior of the variable. In this case, based on a time series model for sales forecasting, we concluded that the distribution that best describes sales behavior is a normal distribution with a mean of 14,000 and standard deviation of 1,000.
- Generate a sample of quantity sold (QV) using Monte Carlo simulation, called QV-S.
Thus, we simulate total revenue (RT) per year by doing:
$$\text{RT-S} = \text{VUP} \ast \text{QV-S}$$

$ \text{2) Custo Variável (CV) = p} \ast \text{RT} $
The variable cost corresponds to a percentage of the total revenue value (RT). In the example, we consider that $ p=0,8 $. Here, we will simulate the percentage of RT that corresponds to variable cost (CV). Through historical data, we determined that $ p $ varies between $ 0,75 $ and $ 0,85 $. This is the only information we have about p. Thus, we will model the variability (behavior) of the random variable p via the uniform distribution between $ [0,75; 0,85] $, to obtain p-S. With this, we simulate the variable cost (CV-S) each year by:
$$\text{CV-S = p-S} \ast \text{RT-S}$$

$ \text{3) Custo fixo (CF)} $
This cost, as the name suggests, is fixed. Therefore, we do not stipulate any probability distribution.
$ \text{4) Depreciação (D)} $
Depreciation presents a fixed behavior during the investment project.
$ \text{5) LAIR} $
This random variable is a function of the other variables. Thus, we obtain a sample of the LAIR random variable in each year by:
$$\text{LAIR-S} = \text{RT-S} - \text{CV-S} - \text{CF} - \text{D}$$

$ \text{6) IR} $
Income tax (IR) corresponds to a rate i of the value of LAIR. In the example, we consider that $ i = 30(porcentagem) $. Thus, we can obtain a sample of the IR via
$$\text{IR-S} = 0,30 \ast \text{LAIRS-S}$$
$ \text{7) Lucro Líquido (LL)} $
This random variable is a function of the other variables. Thus, we obtain a sample of the random variable LL in each year by:
$$\text{LL-S} = \text{LAIR-S} - \text{IR-S}$$

$ \text{8) Fluxo de Caixa }(FC_t) $
This random variable is a function of the other variables. Thus, for each year $ t $ we obtain a sample of the random variable FC by:
$$FC_t-S = \text{D} + \text{LL-S}$$

We repeat the 8 steps above for all years of the simulation, in the case of this example 10 years, so that we can calculate the net present value of the investment.
$ \text{9) Valor Atual Liquido (VAL) em 10 anos} $
To obtain a sample of the Net Present Value (NPV) considering 10 years, we will simulate the Cash Flow (CF) for each year, via the model discussed from (1) to (8), we can even modify some parameters as we change the year. Next, we obtain a sample of the VAL by
$$\text{VAL-S} = -150.000+\sum\limits_{t=1}^{t=10} {\frac{FC_t }{(1,18)^t}}$$

It follows that, in this simulation repeated 3 thousand times, we found a 30.3% risk of obtaining a loss on the investment.
Exercise 4.6.1
Assume that the initial investment is a random variable and assume different parameters for the variables over time. For example, we can admit that the Unit Value of the Product (VUP) is a function of time.
One of the most important elements for a good analysis of an experimental design is the veracity of the proposed model. Below, we present a way to model the correlation between variables.
The effect of the increase in the price of the product in $ 20(porcentagem) $ causing a reduction in the quantity sold $ 30(porcentagem) $ implies that the product has positive price elasticity of demand, that is, an increase in price caused a reduction in the quantity sold proportionally greater than the reduction in price.
Price elasticity of demand: $ \varepsilon_p = \frac{\Delta QV}{\Delta P} \times \frac{P}{QV} = \frac{(15.000 - 10.500)}{(30-36)} \times \frac{30}{15.000} = -1,5 $
$ \Delta QV $: represents the variation in quantity sold;
$ \Delta P $: represents the variation in prices;
$ P $: selling price;
$ QV $: quantity sold.
Through a linear relationship, we take
$$\text{QV} =a + b \ast \text{VUP}$$
Therefore, for any two VUP values$ _{1} $ and VUP$ _{2} $, we obtain that
$$\frac{\Delta QV}{\Delta VUP}=\frac{QV_2 -QV_1 }{VUP_2 -VUP_1 }=b$$
Note that b presents quantity as a unit, to make b a relative value (unitless), we will divide by the ratio QV / VUP.
(there are missing elements in the equation above)
Thus, we obtain that elasticity is given by:
$$\varepsilon _P =\frac{\Delta QV}{\Delta VUP}\frac{VUP_1 }{QV_1 }$$
So, we can interpret elasticity as the proportion of variation of one variable in relation to another. In our example, the percentage reduction in QOL is 1.5 of the proportion of increase in VUP.
To simulate Total Revenue (RT), we will simulate VUP and obtain a simulation of the quantity sold through elasticity. Here, we will also consider elasticity as a random variable. Please note that,
$$\frac{\Delta QV}{\Delta VUP}=\varepsilon _P \ast \frac{QV_1 }{VUP_1 }$$
Thus, we obtain that
$$\Delta QV = \Delta VUP \ast \varepsilon_P \ast \frac{QV}{VUP_1}$$
Therefore, we conclude that
$$QV_2 = QV_1 + \Delta VUP \ast \varepsilon_p \ast \frac{QV_1}{VUP_1}$$
Here we will simulate three different flows: $ FC_1; FC_2 = \cdots = FC_6; FC_7 = \cdots = FC_{10} $. Next, we establish the steps to generate Cash Flow in the instant of time $ t_1 $:
a) Generate the Unit Value of the Product instantly $ t_1 $ $ (\text{VUP}_1) $. Let’s assume that the $ \text{VUP} $ It has a triangular distribution with a lower limit of 29 and an upper limit of 31.
b) Generate quantity sold instantly $ t_1 $ $ (\text{QV}_1) $ via a triangular distribution with a limit lower than $ 14.500 $ and upper limit of $ 15.500 $;
Obtain the simulated total revenue via equation: $ \text{RT-S} = \text{VUP-S} \ast \text{QV-S} $. Next, we repeat the same steps as in items $ (2) $ to $ (8) $ to obtain cash flow instantly $ t_1 $. To obtain the FC at the instant $ t_2 $, we will use the following price increase policy. Let’s increase the expected value of the Unit Value of the Product by one monetary unit $ ( \mathbb{E} (\text{VUP})) $.
c) Let’s simulate $ \text{VUP}_2 $ (at the moment $ t_2 $) via a triangular distribution with a lower limit of 30 and an upper limit of 32;
d) The price elasticity of demand is simulated through a triangular distribution with a lower limit of –1.6 and an upper limit of –1.4;
e) Through $ \text{VUP}_1 $ and elasticity, we obtain
$$QV_2 = QV_1 + \Delta VUP \ast \varepsilon_p \ast \frac{QV_1}{VUP_1}$$
f) Generate from Total Revenue $ (RT) $ and repeat the steps of the items $ (2) $ to $ (8) $ to obtain a cash flow sample $ (FC_2) $ in the instant $ t2 $.
For simplicity, we will consider that the cash flow is constant until the moment $ t_2 $. In reality, we are considering that $ FC_2 = FC_3 = FC_4 = FC_5 = FC_6 $. In the moments $ t_7 $ until $ t_{10} $, we will consider that the expected value of the Unit Value of the product rises to 32 monetary units. Therefore, we must repeat steps (c), (d), (e) and (f) above, to establish the cash flow at the moments $ t_7 $ until $ t_{10} $.
After obtaining the cash flows at each instant of time, we can calculate the NPV using the formula:
$$\text{VAL-S} = -150.000 + \sum_{t=1}^{t=10} \frac{FC_t}{(1,18)^t}$$
Next, we will introduce expense elasticity into the stochastic simulation.
With the reduction in market share there was consequently a reduction in the company’s variable costs. However, as the reduction in variable costs was $ 15(porcentagem) $, while the reduction in market share was 30%, that is, a reduction proportionally smaller than the reduction in the use of variable production factors, we say that there is a positive expenditure elasticity. Expense elasticity is given by:
$$ \varepsilon_d = \frac{(\Delta CV)}{(\Delta QV)} \times \frac{QV}{CV} = \frac{(360.000 - 306.000)}{(15.000 - 10.500)} \times \frac{15.000}{360.000} = 0,5$$
$ \Delta QV $: represents the variation in quantity sold;
$ \Delta CV $: represents the variation in the total costs of the variable;
$ CV $: total variable cost;
$ QV $: quantity sold.
With the information above, we will prepare a new forecast for the company’s cash flow and net present value. In the sensitivity analysis carried out here we consider that there is an interdependence between the variables that influence the $ \text{VAL} $, making the analysis more real than if it were carried out considering independence between the variables.
Through a linear relationship we take
$$CV = a + b\ast QV$$
Therefore, for any values $ QV_1 $ and $ QV_2 $, we obtain that
$$\frac{\Delta CV}{\Delta QV} = \frac{CV_2 - CV_1}{QV_2 - QV_1} = b$$
Note that b presents quantity as a unit, to make b a relative value (unitless), we will divide by the QV / CV ratio. Thus, we obtain that elasticity is given by:
(there are missing elements in the equation above)
$$\varepsilon_P = \frac{\Delta CV}{\Delta QV} \ast \frac{QV_1}{CV_1}$$
Thus, we can interpret elasticity as the proportion of variation of one variable in relation to another. In our example, the percentage reduction in CV is 0.5 of the proportion of reduction in QoL.
To simulate Variable Cost (CV), we simulate Quantity Sold (QV) and elasticity. Thus, we obtain that
$$CV_2 = CV_1 + \Delta QV \ast \varepsilon_P \ast \frac{CV_1}{QV_1}$$