#include <RandPoisson.h>
- Author
Definition at line 41 of file RandPoisson.h.
◆ RandPoisson() [1/2]
CLHEP::RandPoisson::RandPoisson |
( |
HepRandomEngine & |
anEngine, |
|
|
double |
a1 = 1.0 |
|
) |
| |
|
inline |
◆ RandPoisson() [2/2]
CLHEP::RandPoisson::RandPoisson |
( |
HepRandomEngine * |
anEngine, |
|
|
double |
a1 = 1.0 |
|
) |
| |
|
inline |
◆ ~RandPoisson()
CLHEP::RandPoisson::~RandPoisson |
( |
| ) |
|
|
virtual |
◆ distributionName()
static std::string CLHEP::RandPoisson::distributionName |
( |
| ) |
|
|
inlinestatic |
◆ engine()
◆ fire() [1/2]
long CLHEP::RandPoisson::fire |
( |
| ) |
|
◆ fire() [2/2]
long CLHEP::RandPoisson::fire |
( |
double |
mean | ) |
|
Definition at line 219 of file RandPoisson.cc.
219 {
220
221
222
223
224
225
226 double em, t, y;
227 double sq, alxm, g1;
228
229 sq = status[0];
230 alxm = status[1];
231 g1 = status[2];
232
233 if( xm == -1 ) return 0;
234 if( xm < 12.0 ) {
235 if( xm != oldm ) {
236 oldm = xm;
237 g1 = std::exp(-xm);
238 }
239 em = -1;
240 t = 1.0;
241 do {
242 em += 1.0;
243 t *= localEngine->flat();
244 } while( t > g1 );
245 }
247 if ( xm != oldm ) {
248 oldm = xm;
249 sq = std::sqrt(2.0*xm);
250 alxm = std::log(xm);
251 g1 = xm*alxm -
gammln(xm + 1.0);
252 }
253 do {
254 do {
255 y = std::tan(CLHEP::pi*localEngine->flat());
256 em = sq*y + xm;
257 } while( em < 0.0 );
258 em = std::floor(em);
259 t = 0.9*(1.0 + y*y)* std::exp(em*alxm -
gammln(em + 1.0) - g1);
260 } while( localEngine->flat() > t );
261 }
262 else {
263 em = xm + std::sqrt(xm) * normal (localEngine.get());
264 if ( static_cast<long>(em) < 0 )
265 em =
static_cast<long>(xm) >= 0 ? xm :
getMaxMean();
266 }
267 status[0] = sq; status[1] = alxm; status[2] = g1;
268 return long(em);
269}
static double getMaxMean()
◆ fireArray() [1/2]
void CLHEP::RandPoisson::fireArray |
( |
const int |
size, |
|
|
long * |
vect |
|
) |
| |
Definition at line 271 of file RandPoisson.cc.
272{
273 for( long* v = vect; v != vect + size; ++v )
275}
◆ fireArray() [2/2]
void CLHEP::RandPoisson::fireArray |
( |
const int |
size, |
|
|
long * |
vect, |
|
|
double |
mean |
|
) |
| |
Definition at line 277 of file RandPoisson.cc.
278{
279 for( long* v = vect; v != vect + size; ++v )
281}
◆ get()
std::istream & CLHEP::RandPoisson::get |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandom.
Reimplemented in CLHEP::RandPoissonQ.
Definition at line 304 of file RandPoisson.cc.
304 {
305 std::string inName;
306 is >> inName;
307 if (inName !=
name()) {
308 is.clear(std::ios::badbit | is.rdstate());
309 std::cerr << "Mismatch when expecting to read state of a "
310 <<
name() <<
" distribution\n"
311 << "Name found was " << inName
312 << "\nistream is left in the badbit state\n";
313 return is;
314 }
316 std::vector<unsigned long> t(2);
323 return is;
324 }
325
326 is >>
defaultMean >> status[0] >> status[1] >> status[2];
327 return is;
328}
static double longs2double(const std::vector< unsigned long > &v)
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Referenced by CLHEP::RandPoissonQ::get().
◆ getLocalEngine()
◆ getMaxMean()
static double CLHEP::RandPoisson::getMaxMean |
( |
| ) |
|
|
inlinestaticprotected |
◆ getOldMean()
static double CLHEP::RandPoisson::getOldMean |
( |
| ) |
|
|
inlinestaticprotected |
◆ getPStatus()
static double * CLHEP::RandPoisson::getPStatus |
( |
| ) |
|
|
inlinestaticprotected |
◆ name()
std::string CLHEP::RandPoisson::name |
( |
| ) |
const |
|
virtual |
◆ operator()() [1/2]
double CLHEP::RandPoisson::operator() |
( |
| ) |
|
|
virtual |
◆ operator()() [2/2]
double CLHEP::RandPoisson::operator() |
( |
double |
mean | ) |
|
◆ put()
std::ostream & CLHEP::RandPoisson::put |
( |
std::ostream & |
os | ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandom.
Reimplemented in CLHEP::RandPoissonQ.
Definition at line 283 of file RandPoisson.cc.
283 {
284 int pr=os.precision(20);
285 std::vector<unsigned long> t(2);
286 os <<
" " <<
name() <<
"\n";
287 os << "Uvec" << "\n";
289 os <<
meanMax <<
" " << t[0] <<
" " << t[1] <<
"\n";
291 os <<
defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
293 os << status[0] << " " << t[0] << " " << t[1] << "\n";
295 os << status[1] << " " << t[0] << " " << t[1] << "\n";
297 os << status[2] << " " << t[0] << " " << t[1] << "\n";
299 os << oldm << " " << t[0] << " " << t[1] << "\n";
300 os.precision(pr);
301 return os;
302}
static std::vector< unsigned long > dto2longs(double d)
Referenced by CLHEP::RandPoissonQ::put().
◆ setOldMean()
static void CLHEP::RandPoisson::setOldMean |
( |
double |
val | ) |
|
|
inlinestaticprotected |
◆ setPStatus()
static void CLHEP::RandPoisson::setPStatus |
( |
double |
sq, |
|
|
double |
alxm, |
|
|
double |
g1 |
|
) |
| |
|
inlinestaticprotected |
Definition at line 109 of file RandPoisson.h.
109 {
110 status_st[0] = sq; status_st[1] = alxm; status_st[2] = g1;
111 }
Referenced by shoot().
◆ shoot() [1/2]
long CLHEP::RandPoisson::shoot |
( |
double |
mean = 1.0 | ) |
|
|
static |
Definition at line 93 of file RandPoisson.cc.
93 {
94
95
96
97
98
99
100 double em, t, y;
101 double sq, alxm, g1;
104
106 sq = pstatus[0];
107 alxm = pstatus[1];
108 g1 = pstatus[2];
109
110 if( xm == -1 ) return 0;
111 if( xm < 12.0 ) {
112 if( xm != om ) {
114 g1 = std::exp(-xm);
115 }
116 em = -1;
117 t = 1.0;
118 do {
119 em += 1.0;
120 t *= anEngine->flat();
121 } while( t > g1 );
122 }
124 if ( xm != om ) {
126 sq = std::sqrt(2.0*xm);
127 alxm = std::log(xm);
128 g1 = xm*alxm -
gammln(xm + 1.0);
129 }
130 do {
131 do {
132 y = std::tan(CLHEP::pi*anEngine->flat());
133 em = sq*y + xm;
134 } while( em < 0.0 );
135 em = std::floor(em);
136 t = 0.9*(1.0 + y*y)* std::exp(em*alxm -
gammln(em + 1.0) - g1);
137 } while( anEngine->flat() > t );
138 }
139 else {
140 em = xm + std::sqrt(xm) * normal (anEngine);
141 if ( static_cast<long>(em) < 0 )
142 em =
static_cast<long>(xm) >= 0 ? xm :
getMaxMean();
143 }
145 return long(em);
146}
static HepRandomEngine * getTheEngine()
static double getOldMean()
static void setOldMean(double val)
static void setPStatus(double sq, double alxm, double g1)
static double * getPStatus()
Referenced by shootArray().
◆ shoot() [2/2]
long CLHEP::RandPoisson::shoot |
( |
HepRandomEngine * |
anEngine, |
|
|
double |
mean = 1.0 |
|
) |
| |
|
static |
Definition at line 154 of file RandPoisson.cc.
154 {
155
156
157
158
159
160
161 double em, t, y;
162 double sq, alxm, g1;
164
166 sq = pstatus[0];
167 alxm = pstatus[1];
168 g1 = pstatus[2];
169
170 if( xm == -1 ) return 0;
171 if( xm < 12.0 ) {
172 if( xm != om ) {
174 g1 = std::exp(-xm);
175 }
176 em = -1;
177 t = 1.0;
178 do {
179 em += 1.0;
180 t *= anEngine->flat();
181 } while( t > g1 );
182 }
184 if ( xm != om ) {
186 sq = std::sqrt(2.0*xm);
187 alxm = std::log(xm);
188 g1 = xm*alxm -
gammln(xm + 1.0);
189 }
190 do {
191 do {
192 y = std::tan(CLHEP::pi*anEngine->flat());
193 em = sq*y + xm;
194 } while( em < 0.0 );
195 em = std::floor(em);
196 t = 0.9*(1.0 + y*y)* std::exp(em*alxm -
gammln(em + 1.0) - g1);
197 } while( anEngine->flat() > t );
198 }
199 else {
200 em = xm + std::sqrt(xm) * normal (anEngine);
201 if ( static_cast<long>(em) < 0 )
202 em =
static_cast<long>(xm) >= 0 ? xm :
getMaxMean();
203 }
205 return long(em);
206}
◆ shootArray() [1/2]
void CLHEP::RandPoisson::shootArray |
( |
const int |
size, |
|
|
long * |
vect, |
|
|
double |
mean = 1.0 |
|
) |
| |
|
static |
Definition at line 148 of file RandPoisson.cc.
149{
150 for( long* v = vect; v != vect + size; ++v )
152}
static long shoot(double mean=1.0)
◆ shootArray() [2/2]
void CLHEP::RandPoisson::shootArray |
( |
HepRandomEngine * |
anEngine, |
|
|
const int |
size, |
|
|
long * |
vect, |
|
|
double |
mean = 1.0 |
|
) |
| |
|
static |
Definition at line 208 of file RandPoisson.cc.
210{
211 for( long* v = vect; v != vect + size; ++v )
212 *v =
shoot(anEngine,m1);
213}
◆ defaultMean
double CLHEP::RandPoisson::defaultMean |
|
protected |
◆ meanMax
double CLHEP::RandPoisson::meanMax |
|
protected |
The documentation for this class was generated from the following files: