From b9a0ab4df62d20de951d51cdfc1a655accd4f9c9 Mon Sep 17 00:00:00 2001 From: likho Date: Sat, 23 Aug 2025 20:27:19 -0700 Subject: [PATCH] added chart of inflation: debt vs ubi --- econ-demo.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/econ-demo.py b/econ-demo.py index 0f84788..05546f3 100644 --- a/econ-demo.py +++ b/econ-demo.py @@ -107,7 +107,7 @@ def visualize_ubi(terms=25): continue shares.append(calc_share_of_wealth(data)) sow = pd.DataFrame(shares) - print(sow.keys()) + # print(sow.keys()) x = [i for i in range(1,terms)] assert(len(x) == len(shares)) @@ -132,5 +132,46 @@ def visualize_ubi(terms=25): plt.show() return -visualize_ubi(terms=50) +# visualize_ubi(terms=50) +def calc_total_supply(df): + total = [] + for key, data in df.items(): + if key == "name": + continue + total.append(sum(data)) + return total + +def visualize_inflation(terms=50): + participants = ["Alice", "Bob", "Charlie"] + balances = [100,40,20] + + df = get_balances_over_time ( + participants, balances, ubi, + terms = terms + ) + total_supply_ubi = calc_total_supply(df) + + df_si = get_balances_over_time ( + participants, balances, simple_interest, + terms = terms + ) + total_supply_si = calc_total_supply(df_si) + # + 1 because the initial frame is included this time + x = [i for i in range(1,terms+1)] + assert(len(x) == len(total_supply_si)) + + plt.style.use('dark_background') + plt.plot( + x, total_supply_ubi, color="cyan", label="UBI" + ) + plt.plot( + x, total_supply_si, color="red", label="Debt (Simple Interest)" + ) + plt.title("Money Supply over Time: UBI vs Simple Interest") + plt.legend() + plt.xlabel("Terms") + plt.ylabel("Total Currency") + plt.show() + +visualize_inflation(terms=75)