Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SeloSlav/f68d46c65bac2b392d8e0662678454a6 to your computer and use it in GitHub Desktop.
Save SeloSlav/f68d46c65bac2b392d8e0662678454a6 to your computer and use it in GitHub Desktop.
"""
Wealth Dynamics: Married vs Single with Random Shocks
This simulation explores the dynamics of wealth accumulation for married couples and single individuals over a 100-year time period. It incorporates random financial shocks that can negatively impact wealth. The model parameters include:
Mean return for investment (0.08)
Fixed volatility factor (0.15)
Probability of a shock occurring in a given time step (0.05)
Magnitude of wealth reduction due to shock (0.2)
Additive contributions from individual A and individual B (both set to 5000)
Initial wealth for A and B (both set to 50000)
The scenario of married couples assumes a pooling of resources, which could help buffer the impact of shocks. In the simulation, we compare how wealth evolves for married couples and single individuals, and how each group recovers from shocks.
A key assumption in this model is that both spouses have the same income contribution (c_A = c_B = 5000). However, even if one spouse does not have any monetary income, their additive contribution can be viewed as their psychological or emotional contribution to the marriage. This intangible contribution, though hard to quantify, is valuable in reducing wealth volatility and providing stability.
By investigating the impact of random shocks and recovery trajectories, this simulation offers insights into the role of marriage and partnership in managing life's financial uncertainties.
The simulation aligns with concepts from ergodicity economics, a framework that provides a novel perspective on economic behavior, decision-making, and the nature of risk. For more information, see the work of Ole Peters and related discussions on ergodicity economics:
- Mark Buchanan, "How ergodicity reimagines economics for the benefit of us all," Aeon, August 14, 2019. (https://aeon.co/ideas/how-ergodicity-reimagines-economics-for-the-benefit-of-us-all)
- Ole Peters, "The ergodicity problem in economics," Nature Physics, 2019. (https://www.nature.com/articles/s41567-019-0732-0)
- Ole Peters and Murray Gell-Mann, "Evaluating gambles using dynamics," Chaos, 2016. (https://aip.scitation.org/doi/abs/10.1063/1.4940236)
@author: Martin Erlic (martin.erlic@gmail.com)
"""
import numpy as np
import matplotlib.pyplot as plt
# Parameters
T = 100 # Time period in years
dt = 0.1 # Time step
time = np.arange(0, T, dt)
mean_return = 0.08 # Mean return for investment
volatility = 0.15 # Fixed volatility factor
shock_probability = 0.05 # Probability of a shock occurring in a given time step
shock_magnitude = 0.2 # Proportion of wealth reduction due to shock
c_A = 5000 # Additive contribution of individual A
c_B = 5000 # Additive contribution of individual B
# Initial wealth
W_A0 = 50000
W_B0 = 50000
# Scenario 1: Married
W_married = np.zeros(len(time))
W_married[0] = W_A0 + W_B0
# Scenario 2: Single
W_single = np.zeros(len(time))
W_single[0] = W_A0
for t in range(1, len(time)):
# Simulate investment return with fixed volatility
investment_return_married = mean_return * dt + np.random.normal(0, volatility) * np.sqrt(dt)
investment_return_single = mean_return * dt + np.random.normal(0, volatility) * np.sqrt(dt)
# Determine if a shock occurs
shock_occurs = np.random.rand() < shock_probability
# Update wealth for "Married" scenario (pooling function for married couples)
W_married[t] = (W_married[t-1] + c_A + c_B) * (1 + investment_return_married)
if shock_occurs:
W_married[t] *= (1 - shock_magnitude) # Apply shock to married wealth
# Update wealth for "Single" scenario
W_single[t] = (W_single[t-1] + c_A) * (1 + investment_return_single)
if shock_occurs:
W_single[t] *= (1 - shock_magnitude) # Apply shock to single wealth
# Plot results
plt.figure(figsize=(10, 12))
# Linear plot (top subplot)
plt.subplot(2, 1, 1)
plt.plot(time, W_married, label='Total Wealth (Married)')
plt.plot(time, W_single, label='Total Wealth (Single)')
plt.xlabel('Time (years)')
plt.ylabel('Wealth')
plt.title('Wealth Dynamics (Linear): Married vs Single')
plt.legend()
# Logarithmic plot (bottom subplot)
plt.subplot(2, 1, 2)
plt.plot(time, np.log(W_married), label='Log Total Wealth (Married)')
plt.plot(time, np.log(W_single), label='Log Total Wealth (Single)')
plt.xlabel('Time (years)')
plt.ylabel('Log Wealth')
plt.title('Wealth Dynamics (Logarithmic): Married vs Single')
plt.legend()
plt.tight_layout() # Adjust subplot spacing
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment