我正在使用scipy.stats.beta
来生成Beta分布概率密度函数.
You can see the expected result for the standard interval of [0,1] here:
I would like to create the distribution on the interval [-1,1] instead. For a,b = 0.5, 0.5
one would expect the "u" shaped curve to distribute with the mean at 0 and ending at [-1,1]. However, with std = 1
and mean = 0
I get the following:
Now, if I set mean = -1
and std = 2
then I get close to what the desired result is:
为什么PDF不能使用标准偏差和平均输入按预期进行zoom /居中?我一定不理解分配函数的控制.
from scipy.stats import beta
import matplotlib.pyplot as plt
fig,ax = plt.subplots(nrows=1, ncols=1)
#x = np.linspace(beta.ppf(0.01, a, b),beta.ppf(0.99, a, b), 100)
x = np.arange(-1.0,1.0,0.01)
a, b = 0.5,0.5 #2.31, 0.627
mean = -1
std = 2
#mean, var, skew, kurt = beta.stats(a, b, moments='mvsk')
pdf = beta.pdf(x, a, b, loc=mean, scale=std)
ax.plot(x, pdf,'r-', lw=5, alpha=0.6, label='beta pdf')
mean = np.nanmean(pdf[np.isfinite(pdf)])
std = np.nanstd(pdf[np.isfinite(pdf)])