- 博客(6)
- 收藏
- 关注
原创 StockOption
"""Store common attributes of a stock option""" import math class StockOption(object): def __init__(self,S0,K,r,T,N,params): self.S0 = S0 self.K = K self.r = r self.T= T self.N = max(1,N) self.STs = None
2020-08-04 10:29:42
227
原创 The Newton-Raphson method
"""The Newton-Raphson method""" def newton(f,df,x,tol=0.001,maxiter=100): """ f:the function to solve df:the derivative function of f x:initial guess value of x tol:the precision of the solution maxiter:max number of interations
2020-08-03 15:57:03
241
原创 The bisection method
"""The bisection method""" def bisection(f,a,b,tol=0.1,maxiter=10): """ f:the function to solve a:the x-axis value where f(a)<0 b:the x-axis value where f(b)>0 tol:the precision of the solution maxiter:max number of interation
2020-08-03 15:44:37
203
原创 An incremental_search algorithm
"""An incremental search algorithm""" import numpy as np def incremental_search(f,a,b,dx): """ f:the function to sovle a:the left boundary x-axis value b:the right boundary x-axis value dx:the invreamental value in searching return:
2020-08-03 15:24:33
273
原创 Least squares regression with statsmodels
import numpy as np import statsmodels.api as sm #generate some sample data num_periods = 9 all_values = np.array([np.random.random(8) for i in range(num_periods)]) #Filter the data y_values = all_values[:, 0] #First column values as Y
2020-07-22 19:28:59
152
原创 using matplotlib to draw pic of function of cos and sin
```import numpy as np import math import matplotlib.pyplot as plt x=np.linspace(0,2*math.pi) plt.plot(x,np.sin(x),label=r"$\sin(x)$") plt.plot(x,np.cos(x),"ro",label=r"$\cos(x)$") plt.title(r"Two plots in a graph") plt.legend()
2020-07-22 18:06:07
139
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅