1
$\begingroup$

In a computation, I need Log[Beta[alpha+j,beta-j+n]] of some kind.

Is there a LogBeta function built-in to avoid any under/over flow problems? There is one in R, called lbeta(a,b).

I could rewrite them in terms of Gamma functions and thus in terms of LogGamma. But I am lazy. I search a bit for it, just can't seem to find it.

So Mathematica does not have it?

On a related matter, Beta sometimes gives bad results, see here.

$\endgroup$
3
  • 5
    $\begingroup$ Beta[a,b]==Gamma[a] Gamma[b]/Gamma[a+b] So logBeta[a_, b_]:= LogGamma[a] + LogGamma[b] - LogGamma[a+b] $\endgroup$ Dec 22, 2014 at 1:02
  • $\begingroup$ @belisarius please post this as an answer! $\endgroup$ Dec 22, 2014 at 17:59
  • 1
    $\begingroup$ @OleksandrR. Done, but not sure if it's constructive. In any case logbeta[] is now available when googling the site :) $\endgroup$ Dec 22, 2014 at 19:29

1 Answer 1

4
$\begingroup$

From MathWorld

Beta[a,b] == Gamma[a] Gamma[b]/Gamma[a+b]

So we can define

logBeta[a_, b_]:= LogGamma[a] + LogGamma[b] - LogGamma[a+b]

GraphicsRow[ Plot3D[#@logBeta[x, y], {x, -10, 10}, {y, -10, 10}] & /@ {Re, Im}]

Mathematica graphics

$\endgroup$
3
  • $\begingroup$ What about the logarithm of the incomplete Beta function? That can't be reduced to LogGammas. Just asking cause I had a similar underflow/overflow problem using Beta or BetaRegularized to compute incomplete Beta values. $\endgroup$
    – a06e
    Dec 22, 2014 at 19:44
  • $\begingroup$ @becko I haven't thought about that. The question is about the complete beta (I guess). Let me see, but it seems a different problem. $\endgroup$ Dec 22, 2014 at 20:22
  • 1
    $\begingroup$ @becko, that is a much more difficult problem; the complete implementation of a polyalgorithm (algorithms valid for different domains patched together) will be needed for that. $\endgroup$ May 27, 2015 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.