pdtr.c
Go to the documentation of this file.
1 /* pdtr.c
2  *
3  * Poisson distribution
4  *
5  *
6  *
7  * SYNOPSIS:
8  *
9  * int k;
10  * double m, y, pdtr();
11  *
12  * y = pdtr( k, m );
13  *
14  *
15  *
16  * DESCRIPTION:
17  *
18  * Returns the sum of the first k terms of the Poisson
19  * distribution:
20  *
21  * k j
22  * -- -m m
23  * > e --
24  * -- j!
25  * j=0
26  *
27  * The terms are not summed directly; instead the incomplete
28  * Gamma integral is employed, according to the relation
29  *
30  * y = pdtr( k, m ) = igamc( k+1, m ).
31  *
32  * The arguments must both be nonnegative.
33  *
34  *
35  *
36  * ACCURACY:
37  *
38  * See igamc().
39  *
40  */
41 /* pdtrc()
42  *
43  * Complemented poisson distribution
44  *
45  *
46  *
47  * SYNOPSIS:
48  *
49  * int k;
50  * double m, y, pdtrc();
51  *
52  * y = pdtrc( k, m );
53  *
54  *
55  *
56  * DESCRIPTION:
57  *
58  * Returns the sum of the terms k+1 to infinity of the Poisson
59  * distribution:
60  *
61  * inf. j
62  * -- -m m
63  * > e --
64  * -- j!
65  * j=k+1
66  *
67  * The terms are not summed directly; instead the incomplete
68  * Gamma integral is employed, according to the formula
69  *
70  * y = pdtrc( k, m ) = igam( k+1, m ).
71  *
72  * The arguments must both be nonnegative.
73  *
74  *
75  *
76  * ACCURACY:
77  *
78  * See igam.c.
79  *
80  */
81 /* pdtri()
82  *
83  * Inverse Poisson distribution
84  *
85  *
86  *
87  * SYNOPSIS:
88  *
89  * int k;
90  * double m, y, pdtr();
91  *
92  * m = pdtri( k, y );
93  *
94  *
95  *
96  *
97  * DESCRIPTION:
98  *
99  * Finds the Poisson variable x such that the integral
100  * from 0 to x of the Poisson density is equal to the
101  * given probability y.
102  *
103  * This is accomplished using the inverse Gamma integral
104  * function and the relation
105  *
106  * m = igamci( k+1, y ).
107  *
108  *
109  *
110  *
111  * ACCURACY:
112  *
113  * See igami.c.
114  *
115  * ERROR MESSAGES:
116  *
117  * message condition value returned
118  * pdtri domain y < 0 or y >= 1 0.0
119  * k < 0
120  *
121  */
122 
123 /*
124  * Cephes Math Library Release 2.3: March, 1995
125  * Copyright 1984, 1987, 1995 by Stephen L. Moshier
126  */
127 
128 #include "mconf.h"
129 
130 double pdtrc(double k, double m)
131 {
132  double v;
133 
134  if (k < 0.0 || m < 0.0) {
135  sf_error("pdtrc", SF_ERROR_DOMAIN, NULL);
136  return (NAN);
137  }
138  if (m == 0.0) {
139  return 0.0;
140  }
141  v = floor(k) + 1;
142  return (igam(v, m));
143 }
144 
145 
146 double pdtr(double k, double m)
147 {
148  double v;
149 
150  if (k < 0 || m < 0) {
151  sf_error("pdtr", SF_ERROR_DOMAIN, NULL);
152  return (NAN);
153  }
154  if (m == 0.0) {
155  return 1.0;
156  }
157  v = floor(k) + 1;
158  return (igamc(v, m));
159 }
160 
161 
162 double pdtri(int k, double y)
163 {
164  double v;
165 
166  if ((k < 0) || (y < 0.0) || (y >= 1.0)) {
167  sf_error("pdtri", SF_ERROR_DOMAIN, NULL);
168  return (NAN);
169  }
170  v = k + 1;
171  v = igamci(v, y);
172  return (v);
173 }
igamc
double igamc(double a, double x)
Definition: igam.c:169
igam
double igam(double a, double x)
Definition: igam.c:128
pdtr
double pdtr(double k, double m)
Definition: pdtr.c:146
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
y
Scalar * y
Definition: level1_cplx_impl.h:124
pdtri
double pdtri(int k, double y)
Definition: pdtr.c:162
mconf.h
pdtrc
double pdtrc(double k, double m)
Definition: pdtr.c:130
sf_error
void sf_error(const char *func_name, sf_error_t code, const char *fmt,...)
Definition: sf_error.c:41
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
NULL
#define NULL
Definition: ccolamd.c:609
SF_ERROR_DOMAIN
@ SF_ERROR_DOMAIN
Definition: sf_error.h:16
floor
const EIGEN_DEVICE_FUNC FloorReturnType floor() const
Definition: ArrayCwiseUnaryOps.h:481
igamci
double igamci(double a, double q)
Definition: igami.c:301


gtsam
Author(s):
autogenerated on Thu Jun 13 2024 03:04:17