CDF of beta distribution: beta_cdf or inc_beta

I have a query regarding the two functions in the title. I believe the quantities they compute are identical. If so, in terms of efficiency, may I know which one might work faster? If not, how are they different?

I quote their definitions from the functions reference below:

real inc_beta(real alpha, real beta, real x)
Return the regularized incomplete beta function up to x applied to alpha and beta. Available since 2.10

real beta_cdf(reals theta, reals alpha, reals beta)
The beta cumulative distribution function of theta in [0, 1] given positive prior successes (plus one) alpha and prior failures (plus one) beta. Available since 2.0

Cool. I hadn’t realized the incomplete beta function computed the cdf, but this confirms it:

I would use beta_cdf as it’s easier to understand. In general, you can look at the code, but in this case, it’s not much help as we’ve implemented the derivatives along with the code in the beta_cdf, which also works for more arguments.

Neither one of these is going to be great, because you probably want this on the log scale, and our implementation for that just takes the log of the cdf.

In general, though, you can just try both and see which is fastest and most stable for your problem. This may change in the future as we’re continually updating the code to be more stable and go faster (these two goals sometimes pull code in opposite directions).

1 Like