Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#5433 closed Bugs (invalid)

beta function: when b<epsilon return tgamma(b)?

Reported by: Eric Butter <egbutter@…> Owned by: John Maddock
Milestone: To Be Determined Component: math
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

In the beta.hpp header for the beta function (i.e., *not* the beta distribution) around line 131, you have:

if((c == a) && (b < tools::epsilon<T>()))

return boost::math::tgamma(b, pol);

else if((c == b) && (a < tools::epsilon<T>()))

return boost::math::tgamma(a, pol);

Don't you actually want if b<epsilon, tgamma(a)? beta(a,b) reduces to (approximately) gamma(a)b-a for a>>b, which seems like the case for which you are trying to account?

Cheers,

Eric

Change History (2)

comment:1 by John Maddock, 12 years ago

Resolution: invalid
Status: newclosed

I believe the code to be correct:

if a >> b such that a + b == a (at the precision we're working to), then:

gamma(a) / gamma(a+b) == 1

so:

beta(a, b) = gamma(a) * gamma(b) / gamma(a+b) ~ gamma(b) ~ 1/b

comment:2 by Eric Butter <egbutter@…>, 12 years ago

Ah yes that makes sense. I definitely misinterpreted that identity. Thanks for setting me straight!

Note: See TracTickets for help on using tickets.