#include <RandPoisson.h>
- Author
Definition at line 43 of file RandPoisson.h.
◆ RandPoisson() [1/2]
◆ RandPoisson() [2/2]
◆ ~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 221 of file RandPoisson.cc.
221 {
222
223
224
225
226
227
228 double em, t, y;
229 double sq, alxm, g1;
230
231 sq = status[0];
232 alxm = status[1];
233 g1 = status[2];
234
235 if( xm == -1 ) return 0;
236 if( xm < 12.0 ) {
237 if( xm != oldm ) {
238 oldm = xm;
239 g1 = std::exp(-xm);
240 }
241 em = -1;
242 t = 1.0;
243 do {
244 em += 1.0;
245 t *= localEngine->flat();
246 } while( t > g1 );
247 }
249 if ( xm != oldm ) {
250 oldm = xm;
251 sq = std::sqrt(2.0*xm);
252 alxm = std::log(xm);
253 g1 = xm*alxm -
gammln(xm + 1.0);
254 }
255 do {
256 do {
257 y = std::tan(CLHEP::pi*localEngine->flat());
258 em = sq*y + xm;
259 } while( em < 0.0 );
260 em = std::floor(em);
261 t = 0.9*(1.0 + y*y)* std::exp(em*alxm -
gammln(em + 1.0) - g1);
262 } while( localEngine->flat() > t );
263 }
264 else {
265 em = xm + std::sqrt(xm) * normal (localEngine.get());
266 if ( static_cast<long>(em) < 0 )
267 em =
static_cast<long>(xm) >= 0 ? xm :
getMaxMean();
268 }
269 status[0] = sq; status[1] = alxm; status[2] = g1;
270 return long(em);
271}
static double getMaxMean()
◆ fireArray() [1/2]
void CLHEP::RandPoisson::fireArray |
( |
const int |
size, |
|
|
long * |
vect |
|
) |
| |
Definition at line 273 of file RandPoisson.cc.
274{
275 for( long* v = vect; v != vect + size; ++v )
277}
◆ fireArray() [2/2]
void CLHEP::RandPoisson::fireArray |
( |
const int |
size, |
|
|
long * |
vect, |
|
|
double |
mean |
|
) |
| |
Definition at line 279 of file RandPoisson.cc.
280{
281 for( long* v = vect; v != vect + size; ++v )
283}
◆ get()
std::istream & CLHEP::RandPoisson::get |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandom.
Reimplemented in CLHEP::RandPoissonQ, and CLHEP::RandPoissonT.
Definition at line 314 of file RandPoisson.cc.
314 {
315 std::string inName;
316 is >> inName;
317 if (inName !=
name()) {
318 is.clear(std::ios::badbit | is.rdstate());
319 std::cerr << "Mismatch when expecting to read state of a "
320 <<
name() <<
" distribution\n"
321 << "Name found was " << inName
322 << "\nistream is left in the badbit state\n";
323 return is;
324 }
326 std::vector<unsigned long> t(2);
333 return is;
334 }
335
336 is >>
defaultMean >> status[0] >> status[1] >> status[2];
337 return is;
338}
static double longs2double(const std::vector< unsigned long > &v)
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Referenced by CLHEP::RandPoissonQ::get(), and CLHEP::RandPoissonT::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]
◆ put()
std::ostream & CLHEP::RandPoisson::put |
( |
std::ostream & |
os | ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandom.
Reimplemented in CLHEP::RandPoissonQ, and CLHEP::RandPoissonT.
Definition at line 285 of file RandPoisson.cc.
285 {
286 long pr=os.precision(20);
287 std::vector<unsigned long> t(2);
288 os <<
" " <<
name() <<
"\n";
289 os << "Uvec" << "\n";
291 os <<
meanMax <<
" " << t[0] <<
" " << t[1] <<
"\n";
293 os <<
defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
295 os << status[0] << " " << t[0] << " " << t[1] << "\n";
297 os << status[1] << " " << t[0] << " " << t[1] << "\n";
299 os << status[2] << " " << t[0] << " " << t[1] << "\n";
301 os << oldm << " " << t[0] << " " << t[1] << "\n";
302 os.precision(pr);
303 return os;
304#ifdef REMOVED
305 long pr=os.precision(20);
306 os <<
" " <<
name() <<
"\n";
308 os << status[0] << " " << status[1] << " " << status[2] << "\n";
309 os.precision(pr);
310 return os;
311#endif
312}
static std::vector< unsigned long > dto2longs(double d)
Referenced by CLHEP::RandPoissonQ::put(), and CLHEP::RandPoissonT::put().
◆ setOldMean()
static void CLHEP::RandPoisson::setOldMean |
( |
double |
val | ) |
|
|
inlinestaticprotected |
◆ setPStatus()
Definition at line 111 of file RandPoisson.h.
111 {
112 status_st[0] = sq; status_st[1] = alxm; status_st[2] = g1;
113 }
Referenced by shoot().
◆ shoot() [1/2]
long CLHEP::RandPoisson::shoot |
( |
double |
mean = 1.0 | ) |
|
|
static |
Definition at line 95 of file RandPoisson.cc.
95 {
96
97
98
99
100
101
102 double em, t, y;
103 double sq, alxm, g1;
106
108 sq = pstatus[0];
109 alxm = pstatus[1];
110 g1 = pstatus[2];
111
112 if( xm == -1 ) return 0;
113 if( xm < 12.0 ) {
114 if( xm != om ) {
116 g1 = std::exp(-xm);
117 }
118 em = -1;
119 t = 1.0;
120 do {
121 em += 1.0;
122 t *= anEngine->flat();
123 } while( t > g1 );
124 }
126 if ( xm != om ) {
128 sq = std::sqrt(2.0*xm);
129 alxm = std::log(xm);
130 g1 = xm*alxm -
gammln(xm + 1.0);
131 }
132 do {
133 do {
134 y = std::tan(CLHEP::pi*anEngine->flat());
135 em = sq*y + xm;
136 } while( em < 0.0 );
137 em = std::floor(em);
138 t = 0.9*(1.0 + y*y)* std::exp(em*alxm -
gammln(em + 1.0) - g1);
139 } while( anEngine->flat() > t );
140 }
141 else {
142 em = xm + std::sqrt(xm) * normal (anEngine);
143 if ( static_cast<long>(em) < 0 )
144 em =
static_cast<long>(xm) >= 0 ? xm :
getMaxMean();
145 }
147 return long(em);
148}
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 captureStatics(), CLHEP::RandPoissonT::fire(), layout(), randomizeStatics(), CLHEP::RandPoissonT::shoot(), shootArray(), and user_layout().
◆ shoot() [2/2]
Definition at line 156 of file RandPoisson.cc.
156 {
157
158
159
160
161
162
163 double em, t, y;
164 double sq, alxm, g1;
166
168 sq = pstatus[0];
169 alxm = pstatus[1];
170 g1 = pstatus[2];
171
172 if( xm == -1 ) return 0;
173 if( xm < 12.0 ) {
174 if( xm != om ) {
176 g1 = std::exp(-xm);
177 }
178 em = -1;
179 t = 1.0;
180 do {
181 em += 1.0;
182 t *= anEngine->flat();
183 } while( t > g1 );
184 }
186 if ( xm != om ) {
188 sq = std::sqrt(2.0*xm);
189 alxm = std::log(xm);
190 g1 = xm*alxm -
gammln(xm + 1.0);
191 }
192 do {
193 do {
194 y = std::tan(CLHEP::pi*anEngine->flat());
195 em = sq*y + xm;
196 } while( em < 0.0 );
197 em = std::floor(em);
198 t = 0.9*(1.0 + y*y)* std::exp(em*alxm -
gammln(em + 1.0) - g1);
199 } while( anEngine->flat() > t );
200 }
201 else {
202 em = xm + std::sqrt(xm) * normal (anEngine);
203 if ( static_cast<long>(em) < 0 )
204 em =
static_cast<long>(xm) >= 0 ? xm :
getMaxMean();
205 }
207 return long(em);
208}
◆ shootArray() [1/2]
void CLHEP::RandPoisson::shootArray |
( |
const int |
size, |
|
|
long * |
vect, |
|
|
double |
mean = 1.0 |
|
) |
| |
|
static |
Definition at line 150 of file RandPoisson.cc.
151{
152 for( long* v = vect; v != vect + size; ++v )
154}
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 210 of file RandPoisson.cc.
212{
213 for( long* v = vect; v != vect + size; ++v )
214 *v =
shoot(anEngine,m1);
215}
◆ defaultMean
double CLHEP::RandPoisson::defaultMean |
|
protected |
◆ meanMax
double CLHEP::RandPoisson::meanMax |
|
protected |
The documentation for this class was generated from the following files: