<jupyter_start><jupyter_text>Preliminary Models<jupyter_code># Geometric Sums of c, 0<c<1.

c, T = 0.99, 5

# Infinite Series: 1/(1-c)
print(round(sum([c**t for t in range(0,T+100000)]), 4) == round(1/(1-c), 4))

# Finite Series of length T: (1-c^(T+1))/(1-c)
print(round(sum([c**t for t in range(0,T+1)]), 4) == round((1-c**(T+1))/(1-c),4))
# Money Multiplier Model

T = 10000 #rounds of lending
D = [100 for i in range(T+1)]
L = [100 for i in range(T)]
R = [100 for i in range(T)]
r = 0.2

for i in range(T):
    R[i] = r*D[i] #fraction of deposit is reserved
    L[i] = D[i] - R[i] #rest is lent
    D[i+1] = L[i] #loans added to lender's deposit accnt

# D[i+1] = (1-r)*D[i]
# D = D[0] + D[0](1-r) + D[0](1-r)^2....
# Sum(D) = D[i]/(1-(1-r))

print(round(sum(D), 4) == round(D[0]/(1-(1-r)), 4))
# Dynamic Keynesian Multiplier

T, A = 40, 100 
Y = [100 for i in range(T)]
c = 0.7

for t in range(T):
    C = c*Y[t-1]
    Y[t] = C + A
    
# Y[t] = r*Y[t-1] + A
# Y[t] = A(1-c^(t+1)/(1-c)

print(round(Y[-1], 4) == round(A*(1-c**(T+1))/(1-c), 4))
# Asset Pricing: Gordon formula for Lease Pricing
# Accumulation (money grows at rate r), Discounting (money discounted at rate r)

# Gordon Formula for Present Value of Payment stream
g, r, T = 0.01, 0.02, 20
x = [1 for i in range(T)]
p = [1 for i in range(T)]

for t in range(T):
    x[t] = x[0]*(1+g)**t #lease payments rise at rate g
    p[t] = x[t]/(r**t) #present value of lease

sum(p) == p[0]/(1-g/r)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23066577000672495, 'fraction_numerical': 0.0652320107599193, 'mean_word_length': 3.4550898203592815, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '245106', 'license': 'MIT', 'n_tokens_mistral': 760, 'n_tokens_neox': 697, 'n_words': 198, 'path': 'Theory/Preliminaries.ipynb', 'repo_name': 'pranjalrawat007/QuantitativeMacroeconomics', 'size': '1487'}