简体   繁体   中英

Plotting Continuous Compounding interest rate using numpy in python

I am trying to draw the interest rate line (compound, continuously compound, simple). However, I am having trouble drawing continuously compound interest rate.

Could someone help me out? I believe both the continuous & compound interest line should draw the same line, but I see the gaps between them.

Thanks in advance!

在此处输入图像描述 click to see the plot

import numpy as np
import matplotlib.pyplot as plot
import seaborn
import math

pv=5
r=0.15
n=60

t=np.linspace(0,n,n) 

continous = pv * math.e**(r*t)
simple = pv*(1+r*t)
compound = pv*(1+r)**t

plot.figure(figsize = (7,7))
plot.title('difference of interest rates')
plot.xlabel('Number of years')
plot.ylabel('Values')
plot.xlim(0,5)
plot.ylim(5,11)
plot.plot(t, continous, 'g--', label = 'continous')
plot.plot(t, simple, 'b-', label = 'simple Interest')
plot.plot(t, compound, 'r-', label = 'compound Interest')
plot.legend(fontsize = 10)
show()
print(simple)

Your plot looks good. I don't think there is any mistake.

Regular compounding is calculated over specific time intervals such as monthly, quarterly, semi-annually, and on an annual basis. Continuous compounding is the mathematical limit that compound interest can reach if it's calculated and reinvested into an account's balance over a theoretically infinite number of periods. Although theoretically, continuous compounding is not possible, the concept holds a lot of importance in finance.

There is a marginal difference in interest amount between the two.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM