1 ## Copyright (C) 1998-2012 Nicol N. Schraudolph
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Mapping Function} {} betaln (@var{a}, @var{b})
21 ## Return the natural logarithm of the Beta function,
24 ## {\rm betaln} (a, b) = \ln (B (a,b)) \equiv \ln ({\Gamma (a) \Gamma (b) \over \Gamma (a + b)}).
30 ## betaln (a, b) = log (beta (a, b))
34 ## calculated in a way to reduce the occurrence of underflow.
35 ## @seealso{beta, betainc, gammaln}
38 ## Author: Nicol N. Schraudolph <nic@idsia.ch>
39 ## Created: 06 Aug 1998
40 ## Keywords: log beta special function
42 function retval = betaln (a, b)
48 retval = gammaln (a) + gammaln (b) - gammaln (a + b);
53 %!assert (betaln (3,4), log (beta(3,4)),eps);
55 %% Test input validation
57 %!error (betaln (1,2,3))