MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Martin
on 3 Jun 2013

Hi!

I'm trying to compute the integral of the beta function, which is, up to a constant multiplier,

x^(1-alpha) * (1-x)^(1 - beta)

between 0 and 1. This function grows up to infinity in 0 (or 1) when alpha (or beta) < 1, and matlab has headache with the integral. If someone had an advise to help me, I'd be interested!

An approached value would suit me well with a not too large error. I thought about decomposing the function and simplify it near 0 and 1.

Thanks in advance :)

*No products are associated with this question.*

Answer by Roger Stafford
on 3 Jun 2013

Martin, I think you have written your parameters for the beta function backwards. It should be the integral of

x^(alpha-1)*(1-x)^(beta-1)

with respect to x from x = 0 to x = 1. Check the definition in Wikipedia:

https://en.wikipedia.org/wiki/Beta_function

As you say, if alpha or beta lie between 0 and 1, this integrand is singular at one or both end points. Matlab's 'integral' function claims to be able to handle singularities in the integrand at its lower limit which should take care of the alpha < 1 case. From their documentation it isn't clear whether singularities at the upper limit are accepted. If not, you could always break the integration range into two halves and reverse the direction for the upper part so that the singularity is moved to the lower limit. (I seriously doubt if this is necessary, however.) If there are singularities, it is probably advisable to set a stringent error tolerance to be assured of accurate results.

If the 'integral' function doesn't perform properly with such singularities or if your version of matlab doesn't have this function, you can always use the well-known trick in calculus of making a change of variable. Suppose 0<alpha<1, creating a singularity at x = 0. Define a new variable

y = x^alpha

Then the integral becomes the integral of 1/alpha*(1-y^(1/alpha)) with respect to y from y = 0 to y = 1, and the singularity at the lower limit is avoided. A similar trick can deal with a singularity stemming from 0<beta<1.

## 1 Comment

## Walter Roberson (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/77777#comment_152528

I am not clear on what you are doing. Are you saying that x^(1-alpha) * (1-x)^(1 - beta) is (to within a constant multiplier) the

integralof the beta function? With the beta function itself being defined with an integral? Or are you saying that you are trying to calculateand that this overall expression is what forms the beta function?

Is there a connection between the "beta" of your formula and the "beta" of the "beta function" name ? For example, is your formula

for some argument p, q (which might be related to x)?

MATLAB has a beta function which is defined as

When I try to match this against the formula you give, at first it appears that t should map to your x -- bit then the signs of your "1-alpha" and "1-beta" do not map to the "z-1" and "w-1" so I cannot map your expression as being beta(alpha,your beta). I would instead have to map your expression to beta(2 - alpha, 2 - your beta), which is sufficiently different as to cause me to question whether you are trying to write out the beta function formula or not.