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.
Martin, I think you have written your parameters for the beta function backwards. It should be the integral of
with respect to x from x = 0 to x = 1. Check the definition in Wikipedia:
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.
Ok that's great it works! I used a simple integration by parts and it killed dramatically the difficulties on the edge of the integration domain! Back to the school days I didn't think this was so useful and powerful :)
Play games and win prizes!Learn more