IS602-S5 AG

📚 IS602-S5_AG.pdf

Brief overview

This document introduces Monte Carlo simulation as a method for analyzing uncertainty and exploring probabilistic outcomes. It covers the foundational principles, mathematical techniques for generating random data from various distributions, and practical applications in financial planning. Understanding these concepts is essential for robust decision-making under uncertainty.

Key points

  • Overview of Monte Carlo simulation and its purpose in analyzing random inputs and output distributions.
  • How to invert continuous and discrete probability distributions to generate random variates.
  • Practical application of Monte Carlo simulation using the Monty Hall problem.
  • Utilization of the COUNTIF function for retirement fund planning and scenario analysis.

1. Introduction to Monte Carlo simulation

1.1 Core concepts of Monte Carlo simulation

  • Monte Carlo simulation: A technique that involves repeatedly simulating scenarios using random generation of input variables to a model.
  • Purpose: To analyze the distribution of potential outcomes rather than a single definitive answer 3.
  • Process:
  • Specify probability distributions for input variables.
  • Generate random draws and map them to cumulative probabilities.
  • Repeat for numerous trials to build an output distribution.

🔑 Important: Monte Carlo simulation transforms a single-point estimate into a distribution of possible outcomes, essential for decision-making under uncertainty.

1.2 Random number generators

  • RAND():

  • Generates a random number in the interval [0,1.0)[0, 1.0), excluding 11.

  • Represents a continuous uniform distribution, where all numbers are equally likely.

  • Typically used as a cumulative probability value.

  • RANDBETWEEN(bottom, top):

  • Returns a random integer between bottom and top, inclusive.

  • Represents a discrete uniform distribution, where all integers are equally likely.

  • Often used as a position number 7.

Comparison of RANDBETWEEN(1,6) and RAND() distributions.

🔑 Important: RAND() maps to continuous distributions, while RANDBETWEEN() maps to discrete distributions. Both are fundamental for generating random inputs.

1.3 Monte Carlo analysis steps

The Monte Carlo analysis involves a systematic approach to simulation:

  1. Specify probability distributions for inputs: Identify and define the statistical distributions that best represent the uncertainty in each input variable.
  2. Trial by random draws and equate to cumulative probability: Use random number generators to draw values and then map these values to the cumulative distribution functions (CRFs) of the input variables. This step is crucial because cumulative probabilities range from 0 to 1, aligning with the output of RAND().
  3. Repeat for many trials: Execute steps 1 and 2 numerous times to generate a distribution of the output results, rather than a single answer. This allows for a comprehensive understanding of the potential range and likelihood of outcomes 6.

1.4 Resampling and data generation methods

Resampling, often referred to as "bootstrapping," allows for the generation of additional representative data from a small set of actual data. This is vital when the underlying distribution of the input variables is unknown or complex 9.

1.4.1 Method 1: Frequency bins and CRF tables

This method constructs a Cumulative Relative Frequency (CRF) table from existing data.

  • Binning data: Group data points into bins and calculate the frequency within each bin.
  • CRF table construction: Use the bin frequencies to compute cumulative probabilities. These probabilities, ranging from 0 to 1, are essential for mapping random numbers generated by RAND().
  • Generating new data points:
  • Generate a random number using RAND().
  • Compare this random number to the CRF table to obtain a new, resampled data point.

This bar chart displays a discrete uniform distribution for the outcome of rolling a single 6-sided die, where each face has a probability of 1/6.

🔑 Important: The RAND() function's output is mapped to the cumulative probability in the CRF table. A wider range of cumulative probability for a given data point implies a higher likelihood of that data point being generated 11.

Reading CRF tables with lookup functions

To correctly extract a resampled value from a CRF table:

  • LOOKUP() function:
  • Requires careful handling of the lookup_vector and result_vector.
  • To match the RAND() output correctly, the CRF column (lookup_vector) often needs to be "down-shifted" by one row or adjusted in its range selection to avoid incorrectly assigning values 12 13.

Two tables, labeled Type A and Type B, are presented side-by-side, illustrating data for calculating Cumulative Relative Frequencies (CumRF).

  • VLOOKUP() function:
  • Requires the lookup column (CRF) to be the leftmost column in the lookup_array.
  • The lookup_array must also be prepared with the "down-shifted" CRF values 14.

This diagram illustrates the transformation of a table for VLOOKUP by swapping columns.

🔑 Important: Both LOOKUP and VLOOKUP require precise table setup (column order and row alignment) to accurately resample data based on a CRF table.

1.4.2 Method 2a: Discrete data resampling using SMALL

This method resamples discrete data directly without explicitly building a CRF table, leveraging the SMALL function and RANDBETWEEN.

  • Functionality: X’ = SMALL(raw_data, RANDBETWEEN(1, N)) where NN is the total number of raw data points.
  • Process:
  • Generate a random integer kk between 1 and NN using RANDBETWEEN(1, N).
  • Use kk as the second argument in the SMALL function, applied to the raw data. This returns the kk-th smallest value from the raw data.
  • Representation: The generated data X′X' will reflect the actual frequency distribution of the raw data, meaning values with higher initial frequencies are more likely to be selected 17.

🔑 Important: While RANDBETWEEN generates integers uniformly, the SMALL function applied to raw data ensures that the resampled discrete values retain their original frequency proportions 16.

1.4.3 Method 2b: Continuous data resampling using PERCENTILE

This method resamples continuous data using the PERCENTILE function and RAND().

  • Functionality: X’ = PERCENTILE(raw_data, RAND()).
  • Process:
  • Generate a random percentile value kk between 0 and 1.0 using RAND().
  • Use this kk as the second argument in the PERCENTILE function, applied to the raw data.
  • Interpolation: The PERCENTILE function sorts the raw data and interpolates between data points if the RAND() value does not coincide with an actual data point's percentile19.
  • Outcome: The resampled data X′X' may differ from the original raw data due to interpolation but will still reflect the underlying probability distribution.

This table shows sorted data and their corresponding actual percentiles, illustrating the relationship between data values and their rank.

🔑 Important: PERCENTILE with RAND() for continuous data resampling inherently involves interpolation, generating potentially new values that lie between existing data points while preserving distribution shape 18.

🔑 Important: The core principle of Monte Carlo simulation is to leverage random sampling and statistical distributions to explore a wide range of potential outcomes for complex systems.

2. Inverting continuous and discrete distributions

The inversion method is a fundamental technique for generating random variates from a specified probability distribution. It relies on the inverse of the cumulative distribution function (CDF), also known as the quantile function.

By feeding a uniform random number (drawn from U(0,1)U(0,1)) into the inverse CDF, one can obtain a random variate from the target distribution. This principle underpins many simulation-based analyses.

2.1 Inverting continuous distributions

This section details the inversion methods for several common continuous probability distributions. The core principle is to equate the CDF, F(x)F(x), to a uniform random variable, U∼U(0,1)U \sim U(0,1), and solve for xx.

This yields x=F−1(U)x = F^{-1}(U), where F−1F^{-1} is the inverse CDF.

2.1.1 Uniform distribution

For a uniform distribution defined over the interval [min,max][min, max], the CDF is F(x)=x−minmax−minF(x) = \frac{x - min}{max - min}. Inverting this to find xx in terms of a uniform random variable UU gives x=min+U⋅(max−min)x = min + U \cdot (max - min).

Diagram illustrating a uniform distribution with a shaded area representing a random value within the min and max range.

2.1.2 Normal distribution

The normal distribution, characterized by its mean (μ\mu) and standard deviation (σ\sigma), is inverted using its inverse CDF, often denoted as the probit function. A simulated value X′X' is obtained via X′=NORMINV(U,μ,σ)X' = \text{NORMINV}(U, \mu, \sigma), where U∼U(0,1)U \sim U(0,1).

2.1.3 Exponential distribution

For an exponential distribution with a given mean, the inverse CDF can be derived. A variate X′X' is simulated using X′=−Mean⋅LN(U)X' = -\text{Mean} \cdot \text{LN}(U) or equivalently X′=−Mean⋅LN(1−U)X' = -\text{Mean} \cdot \text{LN}(1 - U), where U∼U(0,1)U \sim U(0,1) 20.

2.1.4 Triangular distribution

The triangular distribution is defined by its minimum, maximum, and apex (most likely value) parameters. Let PP be the proportion of the distribution to the left of the apex.

The simulation formula branches based on whether a uniform random variate UU is less than or equal to PP 22.

  • If U≤PU \leq P: X′=min+(max−min)⋅P⋅UX' = min + (max - min) \cdot \sqrt{P \cdot U}
  • If U>PU > P: X′=min+(max−min)⋅(1−P)⋅(1−U)X' = min + (max - min) \cdot \sqrt{(1-P) \cdot (1-U)}

Diagram illustrating a triangular distribution with parameters min, max, and apex.

2.1.5 Lognormal distribution

A variable XX follows a lognormal distribution if its natural logarithm, Y=LN(X)Y = \text{LN}(X), is normally distributed. To simulate a lognormal variate X′X', one first simulates a normally distributed variate Y′Y' using Y′=NORMINV(U,LN(μ),LN(σ))Y' = \text{NORMINV}(U, \text{LN}(\mu), \text{LN}(\sigma)) and then computes X′=EXP(Y′)X' = \text{EXP}(Y').

Alternatively, specialized functions like LOGINV can be used 23.

2.1.6 Gamma distribution

The Gamma distribution, parameterized by shape (α\alpha) and scale (β\beta), is often used to model waiting times between events in a Poisson process. A variate X′X' from this distribution can be generated using the inverse Gamma CDF: X′=GAMMAINV(U,α,β)X' = \text{GAMMAINV}(U, \alpha, \beta) 24.

2.1.7 Erlang distribution

The Erlang distribution is a special case of the Gamma distribution where the shape parameter α\alpha (referred to as hh for the hh-th arrival) is an integer. It models the waiting time until the hh-th event in a Poisson process.

Simulation is identical to the Gamma distribution: X′=GAMMAINV(U,α,β)X' = \text{GAMMAINV}(U, \alpha, \beta) 25.

2.1.8 Weibull distribution

The Weibull distribution is widely applied in reliability engineering, particularly for modeling failure times. Its simulation formula, given shape parameter α\alpha and scale parameter β\beta, is X′=β⋅[−LN(U)]1αX' = \beta \cdot [-\text{LN}(U)]^{\frac{1}{\alpha}} 26.

Formula for simulating data from a Weibull distribution.

2.1.9 Beta distribution

The Beta distribution is suitable for modeling proportions or percentages within a fixed range, typically [A,B][A, B]. With shape parameters α\alpha and β\beta, a variate X′X' is simulated as X′=BETAINV(U,α,β,A,B)X' = \text{BETAINV}(U, \alpha, \beta, A, B) 27.

2.2 Inverting discrete distributions

Generating variates from discrete distributions typically involves mapping intervals of uniform random numbers to specific outcomes.

2.2.1 Uniform discrete distribution

For a discrete uniform distribution over integers [min,max][min, max], a variate X′X' can be generated using X′=RANDBETWEEN(min,max)X' = \text{RANDBETWEEN}(min, max), which selects an integer uniformly from the specified range.

2.2.2 Binomial distribution

To simulate a binomial random variate X′X' with nn trials and success probability pp, one can use the inverse binomial cumulative distribution function: X′=CRITBINOM(n,p,U)X' = \text{CRITBINOM}(n, p, U) or X′=BINOM.INV(n,p,U)X' = \text{BINOM.INV}(n, p, U), where U∼U(0,1)U \sim U(0,1).

2.2.3 Poisson distribution

For a Poisson distribution with mean λ\lambda, simulating a variate X′X' can be approximated using the binomial inverse CDF with a large number of trials nn and a success probability p=λ/np = \lambda/n. This is expressed as X′=CRITBINOM(n,λ/n,U)X' = \text{CRITBINOM}(n, \lambda/n, U) or X′=BINOM.INV(n,λ/n,U)X' = \text{BINOM.INV}(n, \lambda/n, U), where n≫λn \gg \lambda 21.

2.3 Monte Carlo simulation: The Monty Hall problem

The Monty Hall problem provides a compelling case study for applying simulation techniques to solve probability puzzles. The scenario involves three doors, one concealing a prize, and the contestant's choice 28.

  • Game Mechanics:
  • A prize is placed behind one of three doors.
  • The contestant selects one door.
  • The host, who knows where the prize is, opens one of the unselected doors that does not contain the prize.
  • The contestant is then offered the chance to switch to the remaining closed door or stick with their original choice.

Illustration of the Monty Hall problem showing two scenarios with three doors, one prize, and the contestant's choice.

2.3.1 Simulation approach

A Monte Carlo simulation involves repeatedly playing the game and recording outcomes to estimate probabilities. The process typically involves:

  1. Initialization: Randomly assigning the prize door and the contestant's initial door selection.
  2. Host's Action: Determining which of the remaining doors the host opens, considering the prize location and the contestant's selection. Auxiliary matrices (reveal door options and change door options) can guide this decision, especially when multiple doors can be opened by the host.
  3. Contestant's Decision: Simulating the contestant's decision to either stay with their original choice or switch to the other closed door.
  4. Outcome Evaluation: Determining if the contestant wins based on their final door choice relative to the prize door. This can be done by assigning 1 for a win and 0 for a loss, allowing for probability calculation via averaging 35.
  5. Probability Estimation: Repeating these steps many times (e.g., thousands or millions) to estimate the probability of winning for each strategy (sticking vs. switching).

2.3.2 Key matrices for simulation logic

The simulation requires logic to manage door reveals and subsequent choices.

  • Reveal Door Options Matrix: This matrix helps determine which door the host opens. It takes the selected door and the prize door as inputs to specify the door to be revealed 32.
Selected DoorPrize DoorRevealed Door Action
11Randomly choose between 2 or 3
12Reveal door 3
13Reveal door 2
21Reveal door 3
22Randomly choose between 1 or 3
23Reveal door 1
31Reveal door 2
32Reveal door 1
33Randomly choose between 1 or 2
  • Change Door Options Matrix: This matrix determines the door the contestant switches to. Given the selected door and the revealed door, it specifies the alternative door. A simplified formula for three doors is 6−(revealed door+selected door)6 - (\text{revealed door} + \text{selected door}) 34.
Selected DoorRevealed DoorChange Door Action
12Switch to 3
13Switch to 2
21Switch to 3
23Switch to 1
31Switch to 2
32Switch to 1

A matrix table showing the options for changing doors in a game based on the revealed door and the selected door.

2.3.3 Probability of winning

Through simulation, it can be demonstrated that switching doors significantly increases the probability of winning the prize. Specifically, the probability of winning by switching is 23\frac{2}{3}, compared to 13\frac{1}{3} for sticking with the initial choice 36.

🔑 Important: Understanding the inverse CDF is crucial for generating random variates from various distributions, forming the basis for statistical simulations and Monte Carlo methods, as exemplified by the counter-intuitive solution to the Monty Hall problem.

3. Retirement fund planning with COUNTIF function

3.1 Introduction to retirement fund analysis

  • The objective is to determine annual withdrawal amounts for a retirement fund of 500,000 dollars over 20 years, considering various investment return scenarios.
  • These scenarios include a zero percent return, a fixed 10% annual return, and fluctuating return rates.
  • The COUNTIF function is a key tool for analyzing these scenarios by counting cells that meet specific criteria.

3.2 The COUNTIF function

  • The COUNTIF function quantifies the number of cells within a specified range that satisfy a given criterion.
  • Its syntax is COUNTIF(range, criteria), where range is the dataset and criteria is the condition for counting.
  • The criteria can be text, such as a specific value like "apple", or a comparison, such as "<=55".

3.3 Scenario analysis with COUNTIF

  • The document outlines four distinct retirement fund scenarios, each requiring analysis of potential annual withdrawals.
  • These scenarios involve different assumptions about investment performance and the remaining fund balance at the end of the retirement period.
  • While the core mechanics of calculating annual withdrawals are detailed, the specific application of COUNTIF for these calculations is implied through its general utility in conditional counting 37 38.

🔑 Important: The COUNTIF function is versatile for categorizing and counting outcomes within financial models, enabling scenario-based analysis for retirement planning by segmenting results based on defined criteria.

🔑 Important: The analysis focuses on the potential annual withdrawal amounts given a target retirement fund size and various return assumptions, underscoring the practical application of financial functions.

© 2026 Maeve. All rights reserved. This content is protected by copyright.

See also