The R Project SVN R

Rev

Rev 19500 | Rev 42302 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19500 Rev 27260
Line 1... Line 1...
1
/*
1
/*
2
 *  Mathlib : A C Library of Special Functions
2
 *  Mathlib : A C Library of Special Functions
3
 *  Copyright (C) 1998 Ross Ihaka
3
 *  Copyright (C) 1998 Ross Ihaka
4
 *  Copyright (C) 2000 The R Development Core Team
4
 *  Copyright (C) 2000 The R Development Core Team
-
 
5
 *  Copyright (C) 2003 The R Foundation
5
 *
6
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *  (at your option) any later version.
Line 69... Line 70...
69
	corr = lgammacor(q) - lgammacor(p + q);
70
	corr = lgammacor(q) - lgammacor(p + q);
70
	return lgammafn(p) + corr + p - p * log(p + q)
71
	return lgammafn(p) + corr + p - p * log(p + q)
71
		+ (q - 0.5) * log1p(-p / (p + q));
72
		+ (q - 0.5) * log1p(-p / (p + q));
72
    }
73
    }
73
    else
74
    else
74
	/* p and q are small: p <= q > 10. */
75
	/* p and q are small: p <= q < 10. */
75
	return log(gammafn(p) * (gammafn(q) / gammafn(p + q)));
76
	return log(gammafn(p) * (gammafn(q) / gammafn(p + q)));
76
}
77
}