Esempio n. 1
0
def generate_plot1():
    cpp = CPPSimulation(rate=0.3, distribution=Gaussian())
    jumps = cpp.observe_jumps(0.4, n_obs=5000)
    spectralconv = SpectralConv(0.15, 4096, 10)
    density = spectralconv.compute_density(jumps, 0.4, 0.3)
    x = spectralconv.compute_x()

    y = np.arange(-5, 5, 0.01)
    plt.plot(x, density)
    plt.xlim(-4, 4)
    plt.ylim(0, 0.5)
    plt.plot(y, Gaussian().pdf(y))
    plt.show()
Esempio n. 2
0
def generate_plot1():
    cpp = CPPSimulation(0.3, Gaussian())
    jumps = cpp.observe_jumps(0.4, n_obs=5000)
    spectralkde = SpectralKDE(0.14, 16384, 0.01)
    density = spectralkde.compute_density(jumps, wand_kernel, 0.4)
    x = spectralkde.compute_x()

    plt.plot(x, density)
    plt.xlim(-4, 4)
    plt.ylim(0, 0.5)
    plt.plot(x, Gaussian().pdf(x))
    plt.legend(['Estimate', 'True'])
    plt.show()
Esempio n. 3
0
def generate_plot2():
    true_dist = MixtureOfDistribution(Gaussian, [0.3, 0.7], [-2, 1], [1, 1])
    cpp = CPPSimulation(rate=0.3, distribution=true_dist)
    jumps = cpp.observe_jumps(0.4, n_obs=5000)
    spectralconv = SpectralConv(0.15, 16384, 10)
    density = spectralconv.compute_density(jumps, 0.4, 0.3)
    x = spectralconv.compute_x()

    y = np.arange(-5, 5, 0.01)
    plt.plot(x, density)
    plt.xlim(-4, 4)
    plt.ylim(0, 0.5)
    plt.plot(y, true_dist.pdf(y))
    plt.show()
Esempio n. 4
0
def generate_plot4():
    cauchy = Cauchy(0, 1)
    cpp = CPPSimulation(0.3, cauchy)
    jumps = cpp.observe_jumps(0.4, n_obs=5000)
    spectralkde = SpectralKDE(0.14, 16384, 0.01)
    density = spectralkde.compute_density(jumps, wand_kernel, 0.4)
    x = spectralkde.compute_x()

    plt.plot(x, density)
    plt.xlim(-6, 6)
    plt.ylim(0, 0.5)
    plt.plot(x, cauchy.pdf(x))
    plt.legend(['Estimate', 'True'])
    plt.show()
Esempio n. 5
0
def generate_plot3():
    laplace = Laplace(0, 1)
    cpp = CPPSimulation(0.3, laplace)
    jumps = cpp.observe_jumps(0.4, n_obs=5000)
    spectralkde = SpectralKDE(0.1, 16384, 0.01)
    density = spectralkde.compute_density(jumps, wand_kernel, 0.4)
    x = spectralkde.compute_x()

    plt.plot(x, density)
    plt.xlim(-5, 5)
    plt.ylim(0, 0.6)
    plt.plot(x, laplace.pdf(x))
    plt.legend(['Estimate', 'True'])
    plt.show()
Esempio n. 6
0
def generate_plot2():
    mog = MixtureOfDistribution(Gaussian, [0.3, 0.7], [-2, 1], [1, 1])
    cpp = CPPSimulation(0.3, mog)
    jumps = cpp.observe_jumps(0.4, n_obs=5000)
    spectralkde = SpectralKDE(0.14, 16384, 0.01)
    density = spectralkde.compute_density(jumps, wand_kernel, 0.4)
    x = spectralkde.compute_x()

    plt.plot(x, density)
    plt.xlim(-5, 5)
    plt.ylim(0, 0.5)
    plt.plot(x, mog.pdf(x))
    plt.legend(['Estimate', 'True'])
    plt.show()
plt.rcParams.update(params)
x = np.arange(-5, 5, 0.01)
plt.plot(x, density.pdf(x))
plt.xlim(-5, 5)
plt.ylim(0, 0.5)
plt.plot(x, mog.pdf(x))
plt.legend(['Estimate', 'True'])
plt.show()
"""

#example 2
mog = MixtureOfDistribution(Gaussian, [0.2, 0.3, 0.3, 0.2], [-6, -2, 1, 4],
                            [1, 1, 1, 1])
x = np.arange(-10, 8, 0.01)
plt.plot(x, mog.pdf(x))
jumps = CPPSimulation(1, mog).observe_jumps(1, T=8000)
bayesmix = BayesianMoG(4, 15000, jumps, 8000, 1, 1)
bayesmix.performMCMC()
file = open("saved_MCMC2.pickle", 'wb')
pickle.dump(bayesmix, file)
params = bayesmix.calculate_posterior()
density = MixtureOfDistribution(Gaussian, params['mixing_coeffs'],
                                params['means'],
                                np.repeat(params['precision'], 4))

f = open("saved_MCMC2.pickle", "rb")
bin_data = f.read()
bayesmix = pickle.loads(bin_data)
plt.plot(np.arange(15000), bayesmix.means[:, 2:])
plt.ylim(-5, 5)
plt.show()