Renamed function 'simple_interest' to 'compounding_interest'

This commit is contained in:
likho 2025-08-23 21:01:20 -07:00
parent b9a0ab4df6
commit 8763f28547

View File

@ -2,7 +2,7 @@
import pandas as pd import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
def simple_interest(balances, rate=0.05, terms=3): def compounding_interest(balances, rate=0.05, terms=3):
if terms <= 0: if terms <= 0:
print("Number of terms must be >0!") print("Number of terms must be >0!")
return return
@ -64,14 +64,14 @@ def illustrate_share_of_wealth():
print("\n") print("\n")
df = get_balances_over_time ( df = get_balances_over_time (
participants, balances, simple_interest participants, balances, compounding_interest
) )
print(df.to_html()) print(df.to_html())
terms = 222 terms = 222
print(f"How much money exists after {terms} terms?") print(f"How much money exists after {terms} terms?")
#### In 222 terms, even C becomes a millionaire. #### In 222 terms, even C becomes a millionaire.
nb = simple_interest(balances, terms=terms) nb = compounding_interest(balances, terms=terms)
print(nb) print(nb)
print("\n") print("\n")
@ -129,10 +129,12 @@ def visualize_ubi(terms=25):
plt.legend() plt.legend()
plt.xlabel("Terms") plt.xlabel("Terms")
plt.ylabel("Share of Wealth") plt.ylabel("Share of Wealth")
plt.show() plt.savefig("ubi-wealth-distribution.png")
plt.close()
# plt.show()
return return
# visualize_ubi(terms=50) visualize_ubi(terms=50)
def calc_total_supply(df): def calc_total_supply(df):
total = [] total = []
@ -153,7 +155,7 @@ def visualize_inflation(terms=50):
total_supply_ubi = calc_total_supply(df) total_supply_ubi = calc_total_supply(df)
df_si = get_balances_over_time ( df_si = get_balances_over_time (
participants, balances, simple_interest, participants, balances, compounding_interest,
terms = terms terms = terms
) )
total_supply_si = calc_total_supply(df_si) total_supply_si = calc_total_supply(df_si)
@ -163,15 +165,17 @@ def visualize_inflation(terms=50):
plt.style.use('dark_background') plt.style.use('dark_background')
plt.plot( plt.plot(
x, total_supply_ubi, color="cyan", label="UBI" x, total_supply_ubi, color="cyan", label="UBI (n=3, du=10)"
) )
plt.plot( plt.plot(
x, total_supply_si, color="red", label="Debt (Simple Interest)" x, total_supply_si, color="red", label="Debt (n=3, APY=5%)"
) )
plt.title("Money Supply over Time: UBI vs Simple Interest") plt.title("Money Supply over Time: UBI vs Compounding Interest")
plt.legend() plt.legend()
plt.xlabel("Terms") plt.xlabel("Terms")
plt.ylabel("Total Currency") plt.ylabel("Total Currency")
plt.show() plt.savefig("inflation-ubi-vs-5apy.png")
plt.close()
# plt.show()
visualize_inflation(terms=75) visualize_inflation(terms=75)