Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/2.5.0/ALGLIB-2.5.0/poissondistr.cs @ 4068

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 4.1 KB
Line 
1/*************************************************************************
2Cephes Math Library Release 2.8:  June, 2000
3Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
4
5Contributors:
6    * Sergey Bochkanov (ALGLIB project). Translation from C to
7      pseudocode.
8
9See subroutines comments for additional copyrights.
10
11>>> SOURCE LICENSE >>>
12This program is free software; you can redistribute it and/or modify
13it under the terms of the GNU General Public License as published by
14the Free Software Foundation (www.fsf.org); either version 2 of the
15License, or (at your option) any later version.
16
17This program is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20GNU General Public License for more details.
21
22A copy of the GNU General Public License is available at
23http://www.fsf.org/licensing/licenses
24
25>>> END OF LICENSE >>>
26*************************************************************************/
27
28
29namespace alglib {
30  public class poissondistr {
31    /*************************************************************************
32    Poisson distribution
33
34    Returns the sum of the first k+1 terms of the Poisson
35    distribution:
36
37      k         j
38      --   -m  m
39      >   e    --
40      --       j!
41     j=0
42
43    The terms are not summed directly; instead the incomplete
44    gamma integral is employed, according to the relation
45
46    y = pdtr( k, m ) = igamc( k+1, m ).
47
48    The arguments must both be positive.
49    ACCURACY:
50
51    See incomplete gamma function
52
53    Cephes Math Library Release 2.8:  June, 2000
54    Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
55    *************************************************************************/
56    public static double poissondistribution(int k,
57        double m) {
58      double result = 0;
59
60      System.Diagnostics.Debug.Assert(k >= 0 & (double)(m) > (double)(0), "Domain error in PoissonDistribution");
61      result = igammaf.incompletegammac(k + 1, m);
62      return result;
63    }
64
65
66    /*************************************************************************
67    Complemented Poisson distribution
68
69    Returns the sum of the terms k+1 to infinity of the Poisson
70    distribution:
71
72     inf.       j
73      --   -m  m
74      >   e    --
75      --       j!
76     j=k+1
77
78    The terms are not summed directly; instead the incomplete
79    gamma integral is employed, according to the formula
80
81    y = pdtrc( k, m ) = igam( k+1, m ).
82
83    The arguments must both be positive.
84
85    ACCURACY:
86
87    See incomplete gamma function
88
89    Cephes Math Library Release 2.8:  June, 2000
90    Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
91    *************************************************************************/
92    public static double poissoncdistribution(int k,
93        double m) {
94      double result = 0;
95
96      System.Diagnostics.Debug.Assert(k >= 0 & (double)(m) > (double)(0), "Domain error in PoissonDistributionC");
97      result = igammaf.incompletegamma(k + 1, m);
98      return result;
99    }
100
101
102    /*************************************************************************
103    Inverse Poisson distribution
104
105    Finds the Poisson variable x such that the integral
106    from 0 to x of the Poisson density is equal to the
107    given probability y.
108
109    This is accomplished using the inverse gamma integral
110    function and the relation
111
112       m = igami( k+1, y ).
113
114    ACCURACY:
115
116    See inverse incomplete gamma function
117
118    Cephes Math Library Release 2.8:  June, 2000
119    Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
120    *************************************************************************/
121    public static double invpoissondistribution(int k,
122        double y) {
123      double result = 0;
124
125      System.Diagnostics.Debug.Assert(k >= 0 & (double)(y) >= (double)(0) & (double)(y) < (double)(1), "Domain error in InvPoissonDistribution");
126      result = igammaf.invincompletegammac(k + 1, y);
127      return result;
128    }
129  }
130}
Note: See TracBrowser for help on using the repository browser.