The R Project SVN R

Rev

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

Rev 69237 Rev 74458
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) 2003--2015 The R Foundation
3
 *  Copyright (C) 2003--2016 The R Foundation
4
 *
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
8
 *  (at your option) any later version.
Line 56... Line 56...
56
 
56
 
57
#include "nmath.h"
57
#include "nmath.h"
58
 
58
 
59
double rnchisq(double df, double lambda)
59
double rnchisq(double df, double lambda)
60
{
60
{
61
    if (!R_FINITE(df) || !R_FINITE(lambda) || df < 0. || lambda < 0.)
61
    if (ISNAN(df) || !R_FINITE(lambda) || df < 0. || lambda < 0.)
62
	ML_ERR_return_NAN;
62
	ML_ERR_return_NAN;
63
 
63
 
64
    if(lambda == 0.) {
64
    if(lambda == 0.) {
65
	return (df == 0.) ? 0. : rgamma(df / 2., 2.);
65
	return (df == 0.) ? 0. : rgamma(df / 2., 2.);
66
    }
66
    }