Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate beta distribution in Python

In R, the following is used to calculate the integral between points 0 and 0.5 on beta distribution with the parameters 10 and 20:

 integrate(function(p) dbeta(p,10,20),0,0.5)

The result is:

0.9692858 absolute error < 6.6e-08

How can this be done in Python?

like image 248
A.E Avatar asked Jan 21 '26 10:01

A.E


1 Answers

You can use the .cdf attribute of scipy.stats.beta. For a proper interval use the difference, e.g.

betacdf = scipy.stats.beta(10,20).cdf
betacdf(0.5)-betacdf(0.2)
# 0.9200223098258666
like image 93
Paul Panzer Avatar answered Jan 24 '26 00:01

Paul Panzer



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!