Charting Functions

Overview

MCHammer offers the most important charts for building and analyzing Monte-Carlo Results. MCH_Charts contains standard simulation charts for sensitivity, density, trends (time series with confidence bands) for simulation arrays, vectors, and DataFrames.

Functions

Density Chart

MCHammer.density_chrtFunction
density_chrt(Data, x_label="Sim. Values")

Data is your array (simulated or historical). x_label (optional) customizes the X-axis label.

source
dist = rand(Normal(), 1000)
density_chrt(dist, "The Standard Normal")

Histogram Chart

MCHammer.histogram_chrtFunction
histogram_chrt(Data, x_label="Sim. Values")

Data is your array (simulated or historical). x_label (optional) customizes the X-axis label.

source
histogram_chrt(dist, "The Standard Normal")

S-Curve

MCHammer.s_curveFunction
s_curve(results, x_label="Sim. Values"; rev=false)

s_curve allows the visualization of a data set in cumulative form.

  • You can create a reverse emprical CDF py setting rev=true
  • x_label= set the units label for the x axis.
source

Regular Cumulative Density Function

s_curve(dist)

Reverse Cumulative Density Function

s_curve(dist; rev=true)

Sensitivity Chart (Tornado Chart)

Analyzing variables most influential using a tornado sensitivity chart. Here is an example using the simple 3-2-1 profit model.

MCHammer.sensitivity_chrtFunction
sensitivity_chrt(ArrayName::DataFrame, TargetCol, Chrt_Type=1)

Generate a horizontal bar chart summarizing sensitivity metrics for variables in a DataFrame, with special utility for analyzing Monte Carlo trials and exploratory data analysis.

Description

This function computes pairwise correlations between one or more target columns and every column in the input DataFrame using both Spearman (rank) and Pearson correlation measures. In addition, it calculates a measure of contribution to variance based on the squared Spearman correlations. The function then builds a horizontal bar chart where:

  • When Chrt_Type == 1, the x-axis shows Spearman (rank) correlations.
  • When Chrt_Type == 2, the x-axis displays Pearson correlations.
  • For any other value of Chrt_Type, the x-axis presents the percentage contribution to variance.

Each variable is color-coded (red for negative correlations, blue for positive), providing an immediate visual cue about the direction of impact. The resulting chart is particularly helpful for assessing which inputs have the most significant effect on simulation outcomes, enabling users to prioritize variables for further analysis or model refinement.

Arguments

  • ArrayName::DataFrame: A DataFrame containing your simulation or experimental data, where each column represents a different variable.
  • TargetCol: One or more column identifiers (symbols or strings) in ArrayName for which the sensitivity is to be measured. The function computes correlations between these target columns and all other columns.
  • Chrt_Type: An optional integer flag (default is 1) to choose the metric for the x-axis:
    • 1 — Spearman correlation (Rank Correlation)
    • 2 — Pearson correlation
    • Any other value — Percentage contribution to variance (with sign)
source
# Set trials
n_trials = 1000

# Set inputs
Revenue = rand(TriangularDist(2_500_000, 4_000_000, 3_000_000), n_trials)
Expenses = rand(TriangularDist(1_400_000, 3_000_000, 2_000_000), n_trials)

# Model
Profit = Revenue - Expenses

# Capture results
Trials_df = DataFrame(Profit = Revenue - Expenses, Revenue = Revenue, Expenses = Expenses)

# Chart sensitivity of profit (column 1 in DataFrame)
sensitivity_chrt(Trials_df, 1)

Trend Charts

Probabilistic Line Chart and Time Series Charts

MCHammer.trend_chrtFunction
trend_chrt(SimTimeArray, PeriodRange::Vector{Date}; x_label="periods", quantiles=[0.05,0.5,0.95])

Visualizes a simulated time series with confidence bands. PeriodRange must be a vector of Dates (e.g., using Dates: collect(Date(2019,1,1):Year(1):Date(2023,1,1))).

source
trend_chrt(SimTimeArray; x_label="periods", quantiles=[0.05,0.5,0.95])

Visualizes a simulated time series with confidence bands. The x-axis is a simple period index.

source
ts_trials = []

# Setup a TimeSeries simulation with MCHammer over 12 periods
for i in 1:1000
    Monthly_Sales = GBMM(100_000, 0.05, 0.05, 12)
    Monthly_Expenses = GBMM(50_000, 0.03, 0.02, 12)
    MonthlyCOGS = Monthly_Sales .* 0.3
    MonthlyProfit = Monthly_Sales - Monthly_Expenses - MonthlyCOGS
    push!(ts_trials, MonthlyProfit)
end

trend_chrt(ts_trials, x_label="last 12 months")

Using Dates for X-axis

To replace periods with a series of dates:

dr = collect(Date(2019,1,1):Dates.Month(1):Date(2019,12,1))
trend_chrt(ts_trials, dr, x_label="last 12 months")

Sources & References

Eric Torkia, Decision Superhero Vol. 2, chapter 3 : Superpower: Modeling the Behaviors of Inputs, Technics Publishing, 2025 Available on Amazon : https://a.co/d/4YlJFzY . Volumes 2 and 3 to be released in Spring and Fall 2025.