Stan Math Library  2.20.0
reverse mode automatic differentiation
beta.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_BETA_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_BETA_HPP
3 
5 #include <boost/math/tools/promotion.hpp>
7 
8 namespace stan {
9 namespace math {
10 
50 template <typename T1, typename T2>
51 inline typename boost::math::tools::promote_args<T1, T2>::type beta(
52  const T1 a, const T2 b) {
53  using std::exp;
54  return exp(lgamma(a) + lgamma(b) - lgamma(a + b));
55 }
56 
57 } // namespace math
58 } // namespace stan
59 
60 #endif
fvar< T > lgamma(const fvar< T > &x)
Return the natural logarithm of the gamma function applied to the specified argument.
Definition: lgamma.hpp:21
fvar< T > beta(const fvar< T > &x1, const fvar< T > &x2)
Return fvar with the beta function applied to the specified arguments and its gradient.
Definition: beta.hpp:51
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:11

     [ Stan Home Page ] © 2011–2018, Stan Development Team.