Renamed function 'simple_interest' to 'compounding_interest'
This commit is contained in:
		
							parent
							
								
									b9a0ab4df6
								
							
						
					
					
						commit
						8763f28547
					
				
							
								
								
									
										24
									
								
								econ-demo.py
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								econ-demo.py
									
									
									
									
									
								
							| @ -2,7 +2,7 @@ | ||||
| import pandas as pd | ||||
| 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: | ||||
|         print("Number of terms must be >0!") | ||||
|         return | ||||
| @ -64,14 +64,14 @@ def illustrate_share_of_wealth(): | ||||
|     print("\n") | ||||
| 
 | ||||
|     df = get_balances_over_time ( | ||||
|         participants, balances, simple_interest | ||||
|         participants, balances, compounding_interest | ||||
|     ) | ||||
|     print(df.to_html()) | ||||
| 
 | ||||
|     terms = 222 | ||||
|     print(f"How much money exists after {terms} terms?") | ||||
|     #### In 222 terms, even C becomes a millionaire. | ||||
|     nb = simple_interest(balances, terms=terms) | ||||
|     nb = compounding_interest(balances, terms=terms) | ||||
|     print(nb) | ||||
|     print("\n") | ||||
| 
 | ||||
| @ -129,10 +129,12 @@ def visualize_ubi(terms=25): | ||||
|     plt.legend() | ||||
|     plt.xlabel("Terms") | ||||
|     plt.ylabel("Share of Wealth") | ||||
|     plt.show() | ||||
|     plt.savefig("ubi-wealth-distribution.png") | ||||
|     plt.close() | ||||
|     # plt.show() | ||||
|     return | ||||
| 
 | ||||
| # visualize_ubi(terms=50) | ||||
| visualize_ubi(terms=50) | ||||
| 
 | ||||
| def calc_total_supply(df): | ||||
|     total = [] | ||||
| @ -153,7 +155,7 @@ def visualize_inflation(terms=50): | ||||
|     total_supply_ubi = calc_total_supply(df) | ||||
| 
 | ||||
|     df_si = get_balances_over_time ( | ||||
|         participants, balances, simple_interest, | ||||
|         participants, balances, compounding_interest, | ||||
|         terms = terms | ||||
|     ) | ||||
|     total_supply_si = calc_total_supply(df_si) | ||||
| @ -163,15 +165,17 @@ def visualize_inflation(terms=50): | ||||
| 
 | ||||
|     plt.style.use('dark_background') | ||||
|     plt.plot( | ||||
|         x, total_supply_ubi, color="cyan", label="UBI" | ||||
|         x, total_supply_ubi, color="cyan", label="UBI (n=3, du=10)" | ||||
|     ) | ||||
|     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.xlabel("Terms") | ||||
|     plt.ylabel("Total Currency") | ||||
|     plt.show() | ||||
|     plt.savefig("inflation-ubi-vs-5apy.png") | ||||
|     plt.close() | ||||
|     # plt.show() | ||||
| 
 | ||||
| visualize_inflation(terms=75) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user