#include <RandPoisson.h>
- Author
Definition at line 41 of file RandPoisson.h.
◆ RandPoisson() [1/2]
CLHEP::RandPoisson::RandPoisson |
( |
HepRandomEngine & |
anEngine, |
|
|
double |
m = 1.0 |
|
) |
| |
|
inline |
◆ RandPoisson() [2/2]
CLHEP::RandPoisson::RandPoisson |
( |
HepRandomEngine * |
anEngine, |
|
|
double |
m = 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 |
m | ) |
|
Definition at line 217 of file RandPoisson.cc.
217 {
218
219
220
221
222
223
224 double em, t, y;
225 double sq, alxm, g1;
226
227 sq = status[0];
228 alxm = status[1];
229 g1 = status[2];
230
231 if( xm == -1 ) return 0;
232 if( xm < 12.0 ) {
233 if( xm != oldm ) {
234 oldm = xm;
235 g1 = std::exp(-xm);
236 }
237 em = -1;
238 t = 1.0;
239 do {
240 em += 1.0;
241 t *= localEngine->flat();
242 } while( t > g1 );
243 }
245 if ( xm != oldm ) {
246 oldm = xm;
247 sq = std::sqrt(2.0*xm);
248 alxm = std::log(xm);
249 g1 = xm*alxm -
gammln(xm + 1.0);
250 }
251 do {
252 do {
253 y = std::tan(CLHEP::pi*localEngine->flat());
254 em = sq*y + xm;
255 } while( em < 0.0 );
256 em = std::floor(em);
257 t = 0.9*(1.0 + y*y)* std::exp(em*alxm -
gammln(em + 1.0) - g1);
258 } while( localEngine->flat() > t );
259 }
260 else {
261 em = xm + std::sqrt(xm) * normal (localEngine.get());
262 if ( static_cast<long>(em) < 0 )
263 em =
static_cast<long>(xm) >= 0 ? xm :
getMaxMean();
264 }
265 status[0] = sq; status[1] = alxm; status[2] = g1;
266 return long(em);
267}
static double getMaxMean()
◆ fireArray() [1/2]
void CLHEP::RandPoisson::fireArray |
( |
const int |
size, |
|
|
long * |
vect |
|
) |
| |
Definition at line 269 of file RandPoisson.cc.
270{
271 for( long* v = vect; v != vect + size; ++v )
273}
◆ fireArray() [2/2]
void CLHEP::RandPoisson::fireArray |
( |
const int |
size, |
|
|
long * |
vect, |
|
|
double |
m |
|
) |
| |
Definition at line 275 of file RandPoisson.cc.
276{
277 for( long* v = vect; v != vect + size; ++v )
279}
◆ get()
std::istream & CLHEP::RandPoisson::get |
( |
std::istream & |
is | ) |
|
|
virtual |
Reimplemented from CLHEP::HepRandom.
Reimplemented in CLHEP::RandPoissonQ.
Definition at line 302 of file RandPoisson.cc.
302 {
303 std::string inName;
304 is >> inName;
305 if (inName !=
name()) {
306 is.clear(std::ios::badbit | is.rdstate());
307 std::cerr << "Mismatch when expecting to read state of a "
308 <<
name() <<
" distribution\n"
309 << "Name found was " << inName
310 << "\nistream is left in the badbit state\n";
311 return is;
312 }
314 std::vector<unsigned long> t(2);
321 return is;
322 }
323
324 is >>
defaultMean >> status[0] >> status[1] >> status[2];
325 return is;
326}
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 |
m | ) |
|
◆ put()
std::ostream & CLHEP::RandPoisson::put |
( |
std::ostream & |
os | ) |
const |
|
virtual |
Reimplemented from CLHEP::HepRandom.
Reimplemented in CLHEP::RandPoissonQ.
Definition at line 281 of file RandPoisson.cc.
281 {
282 int pr=os.precision(20);
283 std::vector<unsigned long> t(2);
284 os <<
" " <<
name() <<
"\n";
285 os << "Uvec" << "\n";
287 os <<
meanMax <<
" " << t[0] <<
" " << t[1] <<
"\n";
289 os <<
defaultMean <<
" " << t[0] <<
" " << t[1] <<
"\n";
291 os << status[0] << " " << t[0] << " " << t[1] << "\n";
293 os << status[1] << " " << t[0] << " " << t[1] << "\n";
295 os << status[2] << " " << t[0] << " " << t[1] << "\n";
297 os << oldm << " " << t[0] << " " << t[1] << "\n";
298 os.precision(pr);
299 return os;
300}
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 |
m = 1.0 | ) |
|
|
static |
Definition at line 91 of file RandPoisson.cc.
91 {
92
93
94
95
96
97
98 double em, t, y;
99 double sq, alxm, g1;
102
104 sq = status[0];
105 alxm = status[1];
106 g1 = status[2];
107
108 if( xm == -1 ) return 0;
109 if( xm < 12.0 ) {
110 if( xm != om ) {
112 g1 = std::exp(-xm);
113 }
114 em = -1;
115 t = 1.0;
116 do {
117 em += 1.0;
118 t *= anEngine->flat();
119 } while( t > g1 );
120 }
122 if ( xm != om ) {
124 sq = std::sqrt(2.0*xm);
125 alxm = std::log(xm);
126 g1 = xm*alxm -
gammln(xm + 1.0);
127 }
128 do {
129 do {
130 y = std::tan(CLHEP::pi*anEngine->flat());
131 em = sq*y + xm;
132 } while( em < 0.0 );
133 em = std::floor(em);
134 t = 0.9*(1.0 + y*y)* std::exp(em*alxm -
gammln(em + 1.0) - g1);
135 } while( anEngine->flat() > t );
136 }
137 else {
138 em = xm + std::sqrt(xm) * normal (anEngine);
139 if ( static_cast<long>(em) < 0 )
140 em =
static_cast<long>(xm) >= 0 ? xm :
getMaxMean();
141 }
143 return long(em);
144}
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 |
m = 1.0 |
|
) |
| |
|
static |
Definition at line 152 of file RandPoisson.cc.
152 {
153
154
155
156
157
158
159 double em, t, y;
160 double sq, alxm, g1;
162
164 sq = status[0];
165 alxm = status[1];
166 g1 = status[2];
167
168 if( xm == -1 ) return 0;
169 if( xm < 12.0 ) {
170 if( xm != om ) {
172 g1 = std::exp(-xm);
173 }
174 em = -1;
175 t = 1.0;
176 do {
177 em += 1.0;
178 t *= anEngine->flat();
179 } while( t > g1 );
180 }
182 if ( xm != om ) {
184 sq = std::sqrt(2.0*xm);
185 alxm = std::log(xm);
186 g1 = xm*alxm -
gammln(xm + 1.0);
187 }
188 do {
189 do {
190 y = std::tan(CLHEP::pi*anEngine->flat());
191 em = sq*y + xm;
192 } while( em < 0.0 );
193 em = std::floor(em);
194 t = 0.9*(1.0 + y*y)* std::exp(em*alxm -
gammln(em + 1.0) - g1);
195 } while( anEngine->flat() > t );
196 }
197 else {
198 em = xm + std::sqrt(xm) * normal (anEngine);
199 if ( static_cast<long>(em) < 0 )
200 em =
static_cast<long>(xm) >= 0 ? xm :
getMaxMean();
201 }
203 return long(em);
204}
◆ shootArray() [1/2]
void CLHEP::RandPoisson::shootArray |
( |
const int |
size, |
|
|
long * |
vect, |
|
|
double |
m = 1.0 |
|
) |
| |
|
static |
Definition at line 146 of file RandPoisson.cc.
147{
148 for( long* v = vect; v != vect + size; ++v )
150}
static long shoot(double m=1.0)
◆ shootArray() [2/2]
void CLHEP::RandPoisson::shootArray |
( |
HepRandomEngine * |
anEngine, |
|
|
const int |
size, |
|
|
long * |
vect, |
|
|
double |
m = 1.0 |
|
) |
| |
|
static |
Definition at line 206 of file RandPoisson.cc.
208{
209 for( long* v = vect; v != vect + size; ++v )
210 *v =
shoot(anEngine,m1);
211}
◆ defaultMean
double CLHEP::RandPoisson::defaultMean |
|
protected |
◆ meanMax
double CLHEP::RandPoisson::meanMax |
|
protected |
The documentation for this class was generated from the following files: