0

I'd like to plot a Levy distribution characterized by the following PDF's:

enter image description here

Below there's my code:

import matplotlib.pyplot as plt
from scipy.special import gamma
import numpy as np

def Levy(x, n, a):
    num1 = gamma((n+1)/2)
    den1 = (gamma(1/2))*(gamma(n/2))
    num2 = a**n
    den2 = ((x**2)+(a**2))**((n+1)/2)
    return (num1/den1)*(num2/den2)

t = np.linspace(0, 4, 500)

plt.plot(t, Levy(t, 2, 2))
plt.show()

But the plot returns me an horizontal line in y=0.

I know that the equation that I have implemented should return me something similar to a Gaussian distribution. I've tried to implement it also on Wolfram Alpha, and it plots what I expected.

I've think that maybe the problem in the python code could be the gamma function, but I think I've used it in the right way.

Could anyone help me, please?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
XaBla
  • 43
  • 2
  • 13

0 Answers0