2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
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 |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
1026
|
19 |
3381
|
20 ## -*- texinfo -*- |
3321
|
21 ## @deftypefn {Mapping Function} {} beta (@var{a}, @var{b}) |
|
22 ## Return the Beta function, |
|
23 ## @iftex |
|
24 ## @tex |
|
25 ## $$ |
|
26 ## B (a, b) = {\Gamma (a) \Gamma (b) \over \Gamma (a + b)}. |
|
27 ## $$ |
|
28 ## @end tex |
|
29 ## @end iftex |
|
30 ## @ifinfo |
3426
|
31 ## |
3321
|
32 ## @example |
|
33 ## beta (a, b) = gamma (a) * gamma (b) / gamma (a + b). |
|
34 ## @end example |
|
35 ## @end ifinfo |
|
36 ## @end deftypefn |
2311
|
37 |
5428
|
38 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
2312
|
39 ## Created: 13 June 1993 |
|
40 ## Adapted-By: jwe |
|
41 |
1026
|
42 function retval = beta (a, b) |
2325
|
43 |
1026
|
44 if (nargin != 2) |
|
45 usage ("beta (a, b)"); |
|
46 endif |
|
47 |
4031
|
48 retval = exp (gammaln (a) + gammaln (b) - gammaln (a+b)); |
715
|
49 |
|
50 endfunction |