Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Python equivalent of Excel's Beta distribution?

What is the Python equivalent of the Beta distribution in Excel? In Excel, the formula is:

=BETA.DIST(A2,A3,A4,FALSE,A5,A6).

This gives the Beta probability density function for the given parameters, and we get the result as some decimal value.

But the Python SciPy reference does not give the function parameters and its definition in a similar form as Excel.

I am not getting how to do this in SciPy and pass the parameter correctly.

like image 696
suraj Avatar asked Oct 20 '25 02:10

suraj


1 Answers

as you can see here, the probability density function of the beta distribution in scipy has exactly the same three parameters as excel (excel docs).

ALPHA is equivalent to a and represents a parameter of the distribution.

BETA is equivalent to b and represents a parameter of the distribution.

X is equivalent to x and value at which the distribution should be evaluated.

Weather or not the Cumulativ parameter in excel is True is represented by calling different functions in scipy. If you want the cumulative distribution (Cumulativ = True) you just call myBeta.cdf(<myParams>), if you want the probability density function (Cumulativ = False) you call myBeta.pdf(<myParams>). That means:

BETA.DIST(X,Alpha,Beta,TRUE) <=>
scipy.stats.beta.cdf(x,a,b)

and

BETA.DIST(X,Alpha,Beta,FALSE) <=>
scipy.stats.beta.pdf(x,a,b) 
like image 149
Chris Avatar answered Oct 21 '25 17:10

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!