Beispiel #1
0
from Model.QgyModel import *

qgy = QgyModel()
qgy.n_per_year = 10
N = qgy.n_per_year * (qgy.n - 1)
sigma1 = np.repeat(1, N)
sigma2 = np.repeat(2, N)
rho = -0.1
dt = 1 / qgy.n_per_year

num_sim = 10000
res1 = []
res2 = []

for i in range(num_sim):
    [x_n, x_y1] = qgy.generate_two_correlated_gauss(sigma1, sigma2, rho, N, dt)
    res1.append(x_n[-1])
    res2.append(x_y1[-1])

corr = np.corrcoef(res1, res2)
print("corr = ", corr)
Beispiel #2
0
from Model.QgyModel import *

test = [10, 20, 40, 80, 160, 320]
num_sim = 10000

for num_per_year in test:
    dt = 1 / num_per_year
    qgy = QgyModel()
    qgy.n_per_year = num_per_year
    N = num_per_year * (qgy.n - 1)
    sigma = np.repeat(1, N)

    res = []
    for i in range(num_sim):
        one_path = qgy.generate_one_gauss(sigma, N, dt)
        res.append(one_path[-1])
        #plt.plot(one_path, 'g-')
    #plt.show()

    var = np.var(res)
    mean = np.mean(res)

    print("num_per_year = ", num_per_year, "mean = ", mean, ", var = ", var)
Beispiel #3
0
from Model.QgyModel import *
from scipy import stats
import seaborn as sns

qgy = QgyModel()
qgy.n_per_year = 500
N = qgy.n_per_year * (qgy.n - 1)
sigma2 = []
sigma2_prime = []
dt = 1 / qgy.n_per_year
for i in range(1, len(qgy.R_Tk_y)):
    for j in range(qgy.n_per_year):
        t = qgy.Tk[i - 1] + dt * (j + 1)
        sigma2.append(qgy.inf_vol(t))
        sigma2_prime.append(qgy.inf_vol_prime(t))

sigma_n = np.repeat(1, N)
sigma_n_prime = np.repeat(0, N)
t = np.linspace(1, qgy.Tk[-1], qgy.n_per_year * (qgy.n - 1))

dist = []
N = 100
for i in range(0, N):
    [x_n,
     x_y1] = qgy.generate_two_correlated_gauss(sigma_n, sigma2, qgy.rho_n_y1,
                                               (qgy.n - 1) * qgy.n_per_year,
                                               1 / qgy.n_per_year,
                                               sigma_n_prime, sigma2_prime)
    x_y2 = qgy.generate_one_gauss(sigma2, (qgy.n - 1) * qgy.n_per_year,
                                  1 / qgy.n_per_year, sigma2_prime)
    x_Tk_y1 = x_y1[::qgy.n_per_year]