I am trying to plot the output of the below function. The function itself calculates the probability density for given paramaters. The plot should be bell shaped like the normal distribution but not necessarily symmetric. How should I plot this? Any suggestions?
I tried to plot with plt.plot(x, y, 'b') but this wouldn't work.
import math
import numpy as np
from scipy import fftpack
from scipy.special import gamma
import matplotlib.pyplot as plt
u=1
T=1
N=4096
du=0.001534
dt=0.001
mu=0.5
eta=0.25
args=(5,30,35,0.5)
scale=1
#### 1.1 Defining the parameters of the model
def cf_log_cgmy(u, lnS, T, mu ,half_etasq, C, G, M, Y):
omega = -C*gamma(-Y)*(np.power(M-1,Y)-np.power(M,Y)+np.power(G+1,Y)-np.power(G,Y ))
phi_CGMY = C*T*gamma(-Y)*(np.power(M-1j*u,Y)-np.power(M,Y)+np.power(G+1j*u,Y)- np.power(G,Y))
phi = 1j*u*(lnS + (mu+omega-half_etasq)*T) + phi_CGMY - half_etasq*np.power(u,2)
return np.exp(scale*phi)
#### 1.2 From the characteristic function to the probability density function
def cf_to_pdf(cf,du,N):
vec = np.linspace(0,N-1,N)
u = du* (vec-N/2)
res = np.fft.ifftshift(fftpack.fft(np.fft.fftshift(cf(u))))
x = np.linspace(-(np.pi)/du,(np.pi)/du,N, endpoint=False)
y = np.real(res*du/(2*np.pi))
return x , y
def dist_cgmy(args, du, N, dt,mu, eta):
cf = lambda u: cf_log_cgmy(u,0,dt,mu,0.5*np.power(eta,2),args[0],args[1],args[2],args[3])
return cf_to_pdf(cf ,du ,N)
dist_cgmy(args, du, N, dt,mu, eta)
## The output is below
(array([-2047.97435045, -2046.97436297, -2045.9743755 , ...,
2044.97438802, 2045.9743755 , 2046.97436297]),
array([-2.70244620e-08, 2.68320697e-08, -2.66397090e-08, ...,
2.76018306e-08, -2.74093422e-08, 2.72168861e-08]))