Reputation: 1290
I run the following Python code to generate the attached figure of Kernel density with the horizontal axis from 0
to 500
. Given that the code generates 100 observations between -2.157
and 2.830
, I would expect the horizontal axis shows values like between -3
and 3
. What is actually measured on the horizon taxis?
import numpy as np
import statsmodels.api as sm
import matplotlib.pyplot as plt
np.random.seed(1234567)
k = np.random.normal(0, 1, 100)
dens = sm.nonparametric.KDEUnivariate(k)
dens.fit()
plt.plot(dens.density)
Thanks for your help in advance.
Upvotes: 0
Views: 92
Reputation: 1290
Replacing
plt.plot(dens.density)
with
plt.plot(dens.support, dens.density)
gives the following result I expected.
Upvotes: 1