擅长:python、mysql、java
<p>您需要做的是使用scipy.stats.kde包中的高斯kde。</p>
<p>根据您的数据,您可以这样做:</p>
<pre><code>from scipy.stats.kde import gaussian_kde
from numpy import linspace
# create fake data
data = randn(1000)
# this create the kernel, given an array it will estimate the probability over that values
kde = gaussian_kde( data )
# these are the values over wich your kernel will be evaluated
dist_space = linspace( min(data), max(data), 100 )
# plot the results
plt.plot( dist_space, kde(dist_space) )
</code></pre>
<p>内核密度可以随意配置,可以轻松处理N维数据。
它还可以避免在askewchan给出的绘图中看到的样条曲线扭曲。</p>
<p><img src="https://i.stack.imgur.com/sc3y7.png" alt="enter image description here"/></p>