Beta function based on the gamma function.
double beta(num x, num y) => x <= 0 || y <= 0 ? double.nan : gamma(x) * gamma(y) / gamma(x + y);