Coverage Report

Created: 2026-10-16 07:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/r-source/src/nmath/rchisq.c
Line
Count
Source
1
/*
2
 *  Mathlib : A C Library of Special Functions
3
 *  Copyright (C) 1998 Ross Ihaka
4
 *  Copyright (C) 2000 The R Core Team
5
 *
6
 *  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
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, a copy is available at
18
 *  https://www.R-project.org/Licenses/
19
 *
20
 *  SYNOPSIS
21
 *
22
 *    #include <Rmath.h>
23
 *    double rchisq(double df);
24
 *
25
 *  DESCRIPTION
26
 *
27
 *    Random variates from the chi-squared distribution.
28
 *
29
 *  NOTES
30
 *
31
 *    Calls rgamma to do the real work.
32
 */
33
34
#include "nmath.h"
35
36
double rchisq(double df)
37
0
{
38
0
    if (!R_FINITE(df) || df < 0.0) ML_WARN_return_NAN;
39
40
0
    return rgamma(df / 2.0, 2.0);
41
0
}