如何比较Numpy.random的概率分布函数[关闭]

问题描述 投票:0回答:1

我想比较 numpy.random 提供的所有概率

分布
。理想情况下,我希望看到一组比较它们的图表,但我对其他想法持开放态度。

我可以想象遍历每个函数并使用 matplotlib 进行绘图。也许以前有人做过?

python numpy matplotlib distribution probability
1个回答
3
投票

我不确定所有功能都可以直接比较。但是,我可以比较的功能如下所示: numpy.random pdfs

代码:

    loc, scale = 0., 1
    x=np.arange(-8., 8., .01)
    laplace = np.exp(-abs(x-loc/scale))/(2.*scale)
    gumbel = (1/scale)*np.exp(-(x - scale)/scale)* np.exp( -np.exp( -(x - scale) /scale) )
    logistic = np.exp((loc-x)/scale)/(scale*(1+np.exp((loc-x)/scale))**2)
    normal = 1/(scale * np.sqrt(2 * np.pi))*np.exp( - (x - loc)**2 / (2 * scale**2) )
    lognormal = (np.exp(-(np.log(x) - loc)**2 / (2 * scale**2))/ (x * scale * np.sqrt(2 * np.pi)))
    rayleigh = (x/(scale*scale))*(np.exp((-x*x)/(2*scale*scale)))
    standard_cauchy = 1/(np.pi*(1+(x*x)))


    plt.plot(x,gumbel,label='gumbel scale=1')
    plt.plot(x,laplace,label='laplace scale=1, loc = 0')
    plt.plot(x,normal,label='normal scale=1, loc = 0')
    plt.plot(x,logistic,label='logistic scale=1, loc = 0')
    plt.plot(x,lognormal,label='lognormal scale=1, loc = 0')
    plt.plot(x,rayleigh,label='rayleigh scale=1')
    plt.plot(x,standard_cauchy,label='standard_cauchy')
© www.soinside.com 2019 - 2024. All rights reserved.