source: sasview/src/sas/models/c_extension/cephes/pdtr.c @ 50a77df

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 50a77df was 79492222, checked in by krzywon, 10 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 2.5 KB
Line 
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 positive.
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 positive.
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 = igami( 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/*
124Cephes Math Library Release 2.8:  June, 2000
125Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
126*/
127
128#include "mconf.h"
129#ifdef ANSIPROT
130extern double igam ( double, double );
131extern double igamc ( double, double );
132extern double igami ( double, double );
133#else
134double igam(), igamc(), igami();
135#endif
136
137double pdtrc( k, m )
138int k;
139double m;
140{
141double v;
142
143if( (k < 0) || (m <= 0.0) )
144        {
145        mtherr( "pdtrc", DOMAIN );
146        return( 0.0 );
147        }
148v = k+1;
149return( igam( v, m ) );
150}
151
152
153
154double pdtr( k, m )
155int k;
156double m;
157{
158double v;
159
160if( (k < 0) || (m <= 0.0) )
161        {
162        mtherr( "pdtr", DOMAIN );
163        return( 0.0 );
164        }
165v = k+1;
166return( igamc( v, m ) );
167}
168
169
170double pdtri( k, y )
171int k;
172double y;
173{
174double v;
175
176if( (k < 0) || (y < 0.0) || (y >= 1.0) )
177        {
178        mtherr( "pdtri", DOMAIN );
179        return( 0.0 );
180        }
181v = k+1;
182v = igami( v, y );
183return( v );
184}
Note: See TracBrowser for help on using the repository browser.