[Python] How to do Gamma Distribution in Python?

Discussão em 'Python' iniciado por Stack, Agosto 6, 2025.

  1. Stack

    Stack Membro Participativo

    When using Excel, there is a function for gamma distribution, I'm doing =GAMMADIST(B2,$K$2,$K$3, TRUE) which is nothing but GAMMADIST(x, alpha, beta, cumulative), here B2 is my first value of data, K2 and K3 are my alpha and beta values. How do we do this in Python?

    I have

    x = np.array([6150033,499568,76,85,0,3814592])
    alpha = 2
    beta = 3028594.65
    stats.gamma.pdf(x, a=alpha, scale=1/beta)


    Expected output: 60%, 1%, 0%, 0%, 0%, 36%

    I'm unable to understand how to use stats.gamma function in Python and which one to use for example there are different types like rvs, pdf, logpdf, cdf, etc.

    stats.gamma.pdf(x, a=alpha, scale=1/beta)


    Is that the correct way of doing it?

    Continue reading...

Compartilhe esta Página