Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/2.5.0/ALGLIB-2.5.0/poissondistr.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/2.5.0/ALGLIB-2.5.0/poissondistr.cs
r3839 r4068 26 26 *************************************************************************/ 27 27 28 using System;29 28 30 namespace alglib 31 { 32 public class poissondistr 33 { 34 /************************************************************************* 35 Poisson distribution 29 namespace alglib { 30 public class poissondistr { 31 /************************************************************************* 32 Poisson distribution 36 33 37 38 34 Returns the sum of the first k+1 terms of the Poisson 35 distribution: 39 36 40 41 42 43 44 37 k j 38 -- -m m 39 > e -- 40 -- j! 41 j=0 45 42 46 47 43 The terms are not summed directly; instead the incomplete 44 gamma integral is employed, according to the relation 48 45 49 46 y = pdtr( k, m ) = igamc( k+1, m ). 50 47 51 52 48 The arguments must both be positive. 49 ACCURACY: 53 50 54 51 See incomplete gamma function 55 52 56 Cephes Math Library Release 2.8: June, 2000 57 Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier 58 *************************************************************************/ 59 public static double poissondistribution(int k, 60 double m) 61 { 62 double result = 0; 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; 63 59 64 System.Diagnostics.Debug.Assert(k>=0 & (double)(m)>(double)(0), "Domain error in PoissonDistribution");65 result = igammaf.incompletegammac(k+1, m);66 67 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 } 68 64 69 65 70 71 66 /************************************************************************* 67 Complemented Poisson distribution 72 68 73 74 69 Returns the sum of the terms k+1 to infinity of the Poisson 70 distribution: 75 71 76 77 78 79 80 72 inf. j 73 -- -m m 74 > e -- 75 -- j! 76 j=k+1 81 77 82 83 78 The terms are not summed directly; instead the incomplete 79 gamma integral is employed, according to the formula 84 80 85 81 y = pdtrc( k, m ) = igam( k+1, m ). 86 82 87 83 The arguments must both be positive. 88 84 89 85 ACCURACY: 90 86 91 87 See incomplete gamma function 92 88 93 Cephes Math Library Release 2.8: June, 2000 94 Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier 95 *************************************************************************/ 96 public static double poissoncdistribution(int k, 97 double m) 98 { 99 double result = 0; 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; 100 95 101 System.Diagnostics.Debug.Assert(k>=0 & (double)(m)>(double)(0), "Domain error in PoissonDistributionC");102 result = igammaf.incompletegamma(k+1, m);103 104 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 } 105 100 106 101 107 108 102 /************************************************************************* 103 Inverse Poisson distribution 109 104 110 111 112 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. 113 108 114 115 109 This is accomplished using the inverse gamma integral 110 function and the relation 116 111 117 112 m = igami( k+1, y ). 118 113 119 114 ACCURACY: 120 115 121 116 See inverse incomplete gamma function 122 117 123 Cephes Math Library Release 2.8: June, 2000 124 Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier 125 *************************************************************************/ 126 public static double invpoissondistribution(int k, 127 double y) 128 { 129 double result = 0; 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; 130 124 131 System.Diagnostics.Debug.Assert(k>=0 & (double)(y)>=(double)(0) & (double)(y)<(double)(1), "Domain error in InvPoissonDistribution"); 132 result = igammaf.invincompletegammac(k+1, y); 133 return result; 134 } 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; 135 128 } 129 } 136 130 }
Note: See TracChangeset
for help on using the changeset viewer.