001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.numbers.gamma; 018 019/** 020 * <a href="https://mathworld.wolfram.com/BetaFunction.html">Beta function</a>. 021 * 022 * <p>\[ B(a, b) = \frac{\Gamma(a)\ \Gamma(b)}{\Gamma(a+b)} = \frac{(a-1)!\ (b-1)!}{(a+b-1)!} \] 023 * 024 * <p>where \( \Gamma(z) \) is the gamma function. 025 * 026 * <p>This code has been adapted from the <a href="https://www.boost.org/">Boost</a> 027 * {@code c++} implementation {@code <boost/math/special_functions/beta.hpp>}. 028 * 029 * @see 030 * <a href="https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/sf_beta/beta_function.html"> 031 * Boost C++ Beta function</a> 032 * @since 1.1 033 */ 034public final class Beta { 035 036 /** Private constructor. */ 037 private Beta() { 038 // intentionally empty. 039 } 040 041 /** 042 * Computes the value of the 043 * <a href="https://mathworld.wolfram.com/BetaFunction.html"> 044 * beta function</a> B(a, b). 045 * 046 * <p>\[ B(a, b) = \frac{\Gamma(a)\ \Gamma(b)}{\Gamma(a+b)} \] 047 * 048 * <p>where \( \Gamma(z) \) is the gamma function. 049 * 050 * @param a Parameter {@code a}. 051 * @param b Parameter {@code b}. 052 * @return the beta function \( B(a, b) \). 053 */ 054 public static double value(double a, 055 double b) { 056 return BoostBeta.beta(a, b); 057 } 058}