Search code examples
pythonpandasscipydistributiongamma

Odd looking SciPy gamma probability distribution funtion


I have a DataFrame that has one column of large values (on the order of 1e6). When I try to fit this Series to a normal distribution I get an odd looking shape.

plt.plot(np.linspace(0,9e6), gamma.pdf(np.linspace(0,9e6), alpha, beta));

enter image description here

When I run the exact same code for smaller x values, I get a perfectly fine normal distribution:

plt.plot(np.linspace(0,10), gamma.pdf(np.linspace(0,10), 5));

enter image description here

So, whats up?


Solution

  • Everything is just fine, simply linspace is not continuous, it is just a sample of your x axis, if you want nice distribution for

    np.linspace(0,9e6)
    

    change it so it has lots of samples

    np.linspace(0, 9e6, 10e5)