A Python-based Monte Carlo simulation to predict sales commission expenses for a team of 500 sales representatives. This project demonstrates how to use probabilistic modeling to make better business decisions than simple averages would allow.
- Overview
- What is Monte Carlo Simulation?
- Business Problem
- Installation
- Usage
- How It Works
- Understanding the Results
- Customization
- Example Output
- Advantages Over Spreadsheets
- References
Instead of using simple averages to budget for sales commissions, this simulation runs 1,000 different scenarios with randomized inputs to predict realistic expense ranges and probability distributions. This gives decision-makers concrete insights into potential outcomes rather than relying on single-point estimates.
Monte Carlo simulation is a computational technique that uses random sampling to obtain numerical results. Named after the famous Monte Carlo casino, it's particularly useful when:
- You have input variables with uncertainty
- The mathematical formula is known but involves complex probability distributions
- You want to understand the range and likelihood of possible outcomes
In this project, we model two sources of uncertainty:
- Sales targets - varies by sales rep based on experience and territory
- Performance - actual sales as a percentage of target
You need to budget for sales commissions, but there's significant variability:
- 500 sales representatives with different targets
- Performance varies from month to month
- Commission rates are tiered based on performance levels
- A single average estimate might leave you under or over-budgeted
Solution: Run 1,000 simulations with different combinations of targets and performance to see the full distribution of possible commission expenses.
git clone https://github.com/TheDevsGarden/monte-carlo.git
cd monte-carlo# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activatepip install -r requirements.txtRequired packages:
- pandas: Data manipulation and analysis
- numpy: Numerical computing and random number generation
- seaborn: Statistical data visualization
- matplotlib: Plotting and charting
# Make sure virtual environment is activated
source venv/bin/activate # macOS/Linux
# or
venv\Scripts\activate # Windows
# Run the simulation
python commission_calc.py- Runs 1,000 simulations - Each simulation represents a possible scenario
- Displays summary statistics - Mean, standard deviation, min, max, quartiles
- Generates a histogram - Visual distribution of commission amounts
- Saves the chart - Creates
commission_histogram.pngin the project directory
def calc_commission_rate(x_to_target):
if(x_to_target < 0.9):
return 0.02 # 2% for under 90% of target
elif(x_to_target >= 0.9 and x_to_target < 0.99):
return 0.03 # 3% for 90-99% of target
elif(x_to_target >= 0.99):
return 0.04 # 4% for meeting/exceeding targetSales targets are distributed across 6 brackets reflecting organizational structure:
| Target Amount | Probability | Typical Role |
|---|---|---|
| $75,000 | 30% | Entry-level reps |
| $100,000 | 30% | Standard reps |
| $200,000 | 20% | Senior reps |
| $300,000 | 10% | Territory managers |
| $400,000 | 5% | Regional managers |
| $500,000 | 5% | Top performers |
Performance (percent to target) follows a normal distribution:
- Mean: 100% (average rep hits their target)
- Standard Deviation: 10% (68% of reps fall between 90-110% of target)
This models real-world sales variability where most reps cluster around their targets but some significantly over or underperform.
For each of 1,000 simulations:
- Randomly assign targets to 500 reps based on the probability distribution
- Randomly generate performance percentages from the normal distribution
- Calculate actual sales:
Sales = Target × Performance - Determine commission rate based on performance tier
- Calculate commission:
Commission = Sales × Rate - Sum total commissions for all 500 reps
Aggregate all 1,000 simulations to find:
- Most likely commission expense (mean)
- Range of possible outcomes (min to max)
- Confidence intervals (quartiles)
- Distribution shape (histogram)
Summary Statistics:
Sales Commission_Amount Sales_Target
count 1000.0 1000.0 1000.0
mean 83636840.0 2905779.0 83653200.0
std 2690765.0 102713.0 2643569.0
min 73743750.0 2568798.0 73800000.0
25% 81803125.0 2834196.0 81900000.0
50% 83667500.0 2902965.0 83675000.0
75% 85539000.0 2975332.0 85500000.0
max 92571000.0 3225805.0 92625000.0
- Expected Commission: ~$2.9M (mean)
- Standard Deviation: ~$103K (variability around the mean)
- Realistic Range: $2.57M - $3.23M (min to max)
- Planning Range: $2.83M - $2.98M (25th to 75th percentile)
- Conservative Budget: Plan for $3.0M (covers 75% of scenarios)
- Aggressive Budget: Plan for $2.8M (50/50 chance of exceeding)
- Worst Case: Have contingency plans if expenses reach $3.2M+
num_simulations = 5000 # More simulations = smoother distributionnum_reps = 1000 # Model a larger sales forcedef calc_commission_rate(x_to_target):
if(x_to_target < 0.8):
return 0.01 # 1% for under 80%
elif(x_to_target >= 0.8 and x_to_target < 1.0):
return 0.025 # 2.5% for 80-100%
elif(x_to_target >= 1.0):
return 0.05 # 5% for exceeding targetavg = 0.95 # Model more conservative performance (95% average)
std_dev = .15 # Model higher variability (15% std dev)sales_target_values = [50_000, 100_000, 150_000, 200_000]
sales_target_prob = [.4, .3, .2, .1] # Must sum to 1.0The simulation generates a histogram showing the distribution of total commission amounts:
The histogram typically shows:
- Bell-shaped curve - Most outcomes cluster around the mean
- Symmetric distribution - Roughly equal chances of over/under the mean
- Range visibility - Clear view of best and worst cases
- Complex Logic: Easy to implement tiered commission structures
- Readability: Clear code vs. nested Excel formulas
- Scalability: Runs thousands of simulations quickly
- Reproducibility: Version control with git
- Flexibility: Easy to modify distributions and parameters
- Visualization: Integrated charting with matplotlib/seaborn
- Analysis: Powerful statistical tools with pandas
Use Excel when:
- Quick one-off analysis
- Stakeholders need to interact with the model
- Simple linear calculations
Use Python when:
- Complex conditional logic
- Many simulations needed
- Integration with other systems
- Version control is important
- Team of technical users
- Monte Carlo Method: Wikipedia
- Pandas Documentation: pandas.pydata.org
- NumPy Random: numpy.org/doc/stable/reference/random
License: MIT Last Updated: October 2025
