ANALYSIS TOOL BOX

Simulations

SimulateTDistributedOutcome

Simulate continuous variables following a Student's T distribution.

monte-carlosimulationstochasticuncertainty

Introduction

Modeling asset returns or small-sample outcomes as Normal often understates how often extreme values actually occur — real financial and clinical data tend to have fatter tails than a bell curve accounts for. SimulateTDistributedOutcome runs a Monte Carlo simulation from a Student's T distribution instead, which behaves like a Normal distribution but with heavier tails controlled by a degrees-of-freedom parameter (approaching Normal as that parameter grows), making it a better fit for processes prone to outliers or built on sparse historical data.

Teaching Note

Student's T distribution simulations are essential for:

  • Finance: Modeling stock or asset returns that exhibit high kurtosis and "fat tails."
  • Healthcare: Simulating patient outcomes in clinical trials with small sample sizes.
  • Engineering: Modeling material failure stress where sparse data leads to higher uncertainty.
  • Intelligence Analysis: Estimating the range of adversary capabilities with limited signal intelligence.
  • Quality Control: Simulating product weight or dimension variability during initial production ramps.
  • Environmental Science: Modeling extreme wind loads or rainfall events with high outlier potential.
  • Social Science: Simulating standardized scores or survey metrics from niche demographics.
  • Project Management: Estimating activity durations when historical records are sparse and risks are high.

Parameters

ParameterTypeDefaultDescription
degrees_of_freedomrequiredfloatThe degrees of freedom (nu) parameter, which controls the 'fatness' of the tails.
expected_outcomefloat0The location (mean) of the distribution. Defaults to 0.
standard_deviation_of_outcomefloatNoneThe scale (spread) of the distribution. If None, it must be estimated from min_max_of_outcome. Defaults to None.
min_max_of_outcomelistNoneA list of length 2 [min, max] used to estimate the scale parameter based on the T distribution range rule. Defaults to None.
number_of_trialsint10000The number of stochastic simulations (Monte Carlo trials) to run. Defaults to 10000.
return_formatstr'dataframe'The format of the returned data: 'dataframe' (pd.DataFrame) or 'array' (np.ndarray). Defaults to 'dataframe'.
simulated_variable_namestr'Simulated Outcome'The label for the simulated variable in the output and plot. Defaults to 'Simulated Outcome'.
random_seedint412The seed for the random number generator to ensure replicability. Defaults to 412.
plot_simulation_resultsboolTrueWhether to display a histogram of the simulation outcomes. Defaults to True.
fill_colorstr'#999999'The hex color code for the histogram bars. Defaults to '#999999'.
fill_transparencyfloat0.6The transparency level (0-1) for the histogram plot. Defaults to 0.6.
figure_sizetuple(8, 6)The size of the plot figure in inches (width, height). Defaults to (8, 6).
show_meanboolTrueWhether to display the mean value as a vertical dashed line. Defaults to True.
show_medianboolTrueWhether to display the median value as a vertical dotted line. Defaults to True.
title_for_plotstr'Simulation Results'The main title for the distribution plot. Defaults to 'Simulation Results'.
subtitle_for_plotstr'Showing the distribution of the outcome'The descriptive subtitle for the plot.
caption_for_plotstrNoneOptional caption text displayed at the bottom of the plot. Defaults to None.
data_source_for_plotstrNoneOptional data source identification text. Defaults to None.
show_y_axisboolFalseWhether to display the frequency/density scale on the y-axis. Defaults to False.
title_y_indentfloat1.1Vertical position for the title text. Defaults to 1.1.
subtitle_y_indentfloat1.05Vertical position for the subtitle text. Defaults to 1.05.
caption_y_indentfloat-0.15Vertical position for the caption text. Defaults to -0.15.

Returns

The simulated outcomes across all Monte Carlo runs — a pandas DataFrame or a NumPy array, depending on return_format.

Example

python
from analysistoolbox.simulations import SimulateTDistributedOutcome

# Finance: simulating daily returns with fat tails (df=5, mean=0.001, SD=0.02)
return_sim = SimulateTDistributedOutcome(
    degrees_of_freedom=5,
    expected_outcome=0.001,
    standard_deviation_of_outcome=0.02,
    simulated_variable_name='Daily Return',
    title_for_plot='Asset Return Simulation with Outliers'
)