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), excluding 1.
-
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
bottomandtop, inclusive. -
Represents a discrete uniform distribution, where all integers are equally likely.
-
Often used as a position number 7.

🔑 Important:
RAND()maps to continuous distributions, whileRANDBETWEEN()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:
- Specify probability distributions for inputs: Identify and define the statistical distributions that best represent the uncertainty in each input variable.
- 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(). - 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.

🔑 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_vectorandresult_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.

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

🔑 Important: Both
LOOKUPandVLOOKUPrequire 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 N is the total number of raw data points. - Process:
- Generate a random integer k between 1 and N using
RANDBETWEEN(1, N). - Use k as the second argument in the
SMALLfunction, applied to the raw data. This returns the k-th smallest value from the raw data. - Representation: The generated data 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
RANDBETWEENgenerates integers uniformly, theSMALLfunction 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 k between 0 and 1.0 using
RAND(). - Use this k as the second argument in the
PERCENTILEfunction, applied to the raw data. - Interpolation: The
PERCENTILEfunction sorts the raw data and interpolates between data points if theRAND()value does not coincide with an actual data point's percentile19. - Outcome: The resampled data X′ may differ from the original raw data due to interpolation but will still reflect the underlying probability distribution.

🔑 Important:
PERCENTILEwithRAND()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)) 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), to a uniform random variable, U∼U(0,1), and solve for x.
This yields x=F−1(U), where F−1 is the inverse CDF.
2.1.1 Uniform distribution
For a uniform distribution defined over the interval [min,max], the CDF is F(x)=max−minx−min. Inverting this to find x in terms of a uniform random variable U gives x=min+U⋅(max−min).

2.1.2 Normal distribution
The normal distribution, characterized by its mean (μ) and standard deviation (σ), is inverted using its inverse CDF, often denoted as the probit function. A simulated value X′ is obtained via X′=NORMINV(U,μ,σ), where U∼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′ is simulated using X′=−Mean⋅LN(U) or equivalently X′=−Mean⋅LN(1−U), where U∼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 P be the proportion of the distribution to the left of the apex.
The simulation formula branches based on whether a uniform random variate U is less than or equal to P 22.
- If U≤P: X′=min+(max−min)⋅P⋅U
- If U>P: X′=min+(max−min)⋅(1−P)⋅(1−U)

2.1.5 Lognormal distribution
A variable X follows a lognormal distribution if its natural logarithm, Y=LN(X), is normally distributed. To simulate a lognormal variate X′, one first simulates a normally distributed variate Y′ using Y′=NORMINV(U,LN(μ),LN(σ)) and then computes X′=EXP(Y′).
Alternatively, specialized functions like LOGINV can be used 23.
2.1.6 Gamma distribution
The Gamma distribution, parameterized by shape (α) and scale (β), is often used to model waiting times between events in a Poisson process. A variate X′ from this distribution can be generated using the inverse Gamma CDF: X′=GAMMAINV(U,α,β) 24.
2.1.7 Erlang distribution
The Erlang distribution is a special case of the Gamma distribution where the shape parameter α (referred to as h for the h-th arrival) is an integer. It models the waiting time until the h-th event in a Poisson process.
Simulation is identical to the Gamma distribution: X′=GAMMAINV(U,α,β) 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 α and scale parameter β, is X′=β⋅[−LN(U)]α1 26.

2.1.9 Beta distribution
The Beta distribution is suitable for modeling proportions or percentages within a fixed range, typically [A,B]. With shape parameters α and β, a variate X′ is simulated as X′=BETAINV(U,α,β,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], a variate X′ can be generated using X′=RANDBETWEEN(min,max), which selects an integer uniformly from the specified range.
2.2.2 Binomial distribution
To simulate a binomial random variate X′ with n trials and success probability p, one can use the inverse binomial cumulative distribution function: X′=CRITBINOM(n,p,U) or X′=BINOM.INV(n,p,U), where U∼U(0,1).
2.2.3 Poisson distribution
For a Poisson distribution with mean λ, simulating a variate X′ can be approximated using the binomial inverse CDF with a large number of trials n and a success probability p=λ/n. This is expressed as X′=CRITBINOM(n,λ/n,U) or X′=BINOM.INV(n,λ/n,U), where n≫λ 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.

2.3.1 Simulation approach
A Monte Carlo simulation involves repeatedly playing the game and recording outcomes to estimate probabilities. The process typically involves:
- Initialization: Randomly assigning the prize door and the contestant's initial door selection.
- 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.
- Contestant's Decision: Simulating the contestant's decision to either stay with their original choice or switch to the other closed door.
- 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.
- 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 Door | Prize Door | Revealed Door Action |
|---|---|---|
| 1 | 1 | Randomly choose between 2 or 3 |
| 1 | 2 | Reveal door 3 |
| 1 | 3 | Reveal door 2 |
| 2 | 1 | Reveal door 3 |
| 2 | 2 | Randomly choose between 1 or 3 |
| 2 | 3 | Reveal door 1 |
| 3 | 1 | Reveal door 2 |
| 3 | 2 | Reveal door 1 |
| 3 | 3 | Randomly 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) 34.
| Selected Door | Revealed Door | Change Door Action |
|---|---|---|
| 1 | 2 | Switch to 3 |
| 1 | 3 | Switch to 2 |
| 2 | 1 | Switch to 3 |
| 2 | 3 | Switch to 1 |
| 3 | 1 | Switch to 2 |
| 3 | 2 | Switch to 1 |

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 32, compared to 31 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
COUNTIFfunction is a key tool for analyzing these scenarios by counting cells that meet specific criteria.
3.2 The COUNTIF function
- The
COUNTIFfunction quantifies the number of cells within a specified range that satisfy a given criterion. - Its syntax is
COUNTIF(range, criteria), whererangeis the dataset andcriteriais the condition for counting. - The
criteriacan 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
COUNTIFfor these calculations is implied through its general utility in conditional counting 37 38.
🔑 Important: The
COUNTIFfunction 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.