(double z, double w)
| 537 | } |
| 538 | |
| 539 | public static double lnBeta(double z, double w) |
| 540 | { |
| 541 | /* |
| 542 | * The beta function is defined by |
| 543 | * |
| 544 | * Gamma(z) Gamma(w) |
| 545 | * B(z, w) = ----------------- |
| 546 | * Gamma(z + w) |
| 547 | * |
| 548 | * However, the definition is numericaly unstable (large value / large value to small result & small input). |
| 549 | * Taking the log of each size and then exponentiating gives a more stable method of computing the result |
| 550 | * |
| 551 | * lnGamma(z) + lnGamma(w) - lnGamma(z + w) |
| 552 | * B(z, w) = e |
| 553 | */ |
| 554 | return lnGamma(z)+lnGamma(w)-lnGamma(z+w); |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Computes the regularized incomplete beta function, I<sub>x</sub>(a, b). The result of which is always in the range [0, 1] |
no test coverage detected