The R Project SVN R

Rev

Rev 77685 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 77685 Rev 81787
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
-
 
4
 *  Copyright (C) 2000-2015 The R Core Team
3
 *  Copyright (C) 2000-2015 The R Core Team
5
 *  Copyright (C) 2005 The R Foundation
4
 *  Copyright (C) 2005 The R Foundation
-
 
5
 *  Copyright (C) 1998 Ross Ihaka
6
 *
6
 *
7
 *  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
8
 *  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
9
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  (at your option) any later version.
10
 *  (at your option) any later version.
Line 41... Line 41...
41
     */
41
     */
42
 
42
 
43
    if (df1 <= df2 && df2 > 4e5) {
43
    if (df1 <= df2 && df2 > 4e5) {
44
	if(!R_FINITE(df1)) /* df1 == df2 == Inf : */
44
	if(!R_FINITE(df1)) /* df1 == df2 == Inf : */
45
	    return 1.;
45
	    return 1.;
46
	/* else */
46
	/* else value for df2 == Inf : */
47
	return qchisq(p, df1, lower_tail, log_p) / df1;
47
	return qchisq(p, df1, lower_tail, log_p) / df1;
48
    }
48
    }
49
    if (df1 > 4e5) { /* and so  df2 < df1 */
49
    else if (df1 > 4e5) { /* and so  df2 < df1 -- return value for df1 == Inf */
50
	return df2 / qchisq(p, df2, !lower_tail, log_p);
50
	return df2 / qchisq(p, df2, !lower_tail, log_p);
51
    }
51
    }
52
 
52
 
53
    // FIXME: (1/qb - 1) = (1 - qb)/qb; if we know qb ~= 1, should use other tail
53
    // FIXME: (1/qb - 1) = (1 - qb)/qb; if we know qb ~= 1, should use other tail
54
    p = (1. / qbeta(p, df2/2, df1/2, !lower_tail, log_p) - 1.) * (df2 / df1);
54
    p = (1. / qbeta(p, df2/2, df1/2, !lower_tail, log_p) - 1.) * (df2 / df1);