5820
|
1 ## Copyright (C) 1998 by Nicol N. Schraudolph |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
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 |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
5820
|
9 ## |
|
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. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
5820
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Mapping Function} {} betaln (@var{a}, @var{b}) |
|
21 ## Return the log of the Beta function, |
|
22 ## @iftex |
|
23 ## @tex |
|
24 ## $$ |
|
25 ## B (a, b) = \log {\Gamma (a) \Gamma (b) \over \Gamma (a + b)}. |
|
26 ## $$ |
|
27 ## @end tex |
|
28 ## @end iftex |
|
29 ## @ifinfo |
|
30 ## |
|
31 ## @example |
|
32 ## betaln (a, b) = gammaln (a) + gammaln (b) - gammaln (a + b) |
|
33 ## @end example |
|
34 ## @end ifinfo |
|
35 ## @seealso{beta, betai, gammaln} |
|
36 ## @end deftypefn |
|
37 |
|
38 ## Author: Nicol N. Schraudolph <nic@idsia.ch> |
|
39 ## Created: 06 Aug 1998 |
|
40 ## Keywords: log beta special function |
|
41 |
|
42 function retval = betaln (a, b) |
|
43 if (nargin != 2) |
6046
|
44 print_usage (); |
5820
|
45 endif |
|
46 |
|
47 retval = gammaln (a) + gammaln (b) - gammaln (a + b); |
|
48 endfunction |
|
49 |
|
50 %!assert (betaln(3,4),log(beta(3,4)),eps) |
|
51 |
|
52 %!error (betaln(1.)) |
|
53 %!error (betaln(1.,1.,1.)) |