Frage

I'd like to compare all of the probability distributions provided by numpy.random. Ideally I'd like to see a set of graphs comparing them but I am open to other ideas.

I can imagine going through each function and plotting using matplotlib. Perhaps someone has done it before?

War es hilfreich?

Lösung

I am not sure that all of the functions are all directly comparable. However, the functions that I could compare are shown below: numpy.random pdfs

code:

    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')
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top