CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
CLHEP::RandStudentT Class Reference

#include <RandStudentT.h>

+ Inheritance diagram for CLHEP::RandStudentT:

Public Member Functions

 RandStudentT (HepRandomEngine &anEngine, double a=1.0)
 
 RandStudentT (HepRandomEngine *anEngine, double a=1.0)
 
virtual ~RandStudentT ()
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
double fire ()
 
double fire (double a)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, double *vect, double a)
 
double operator() ()
 
double operator() (double a)
 
std::string name () const
 
HepRandomEngineengine ()
 
- Public Member Functions inherited from CLHEP::HepRandom
 HepRandom ()
 
 HepRandom (long seed)
 
 HepRandom (HepRandomEngine &algorithm)
 
 HepRandom (HepRandomEngine *algorithm)
 
virtual ~HepRandom ()
 
double flat ()
 
void flatArray (const int size, double *vect)
 
double flat (HepRandomEngine *theNewEngine)
 
void flatArray (HepRandomEngine *theNewEngine, const int size, double *vect)
 
virtual double operator() ()
 
virtual std::string name () const
 
virtual HepRandomEngineengine ()
 
virtual std::ostream & put (std::ostream &os) const
 
virtual std::istream & get (std::istream &is)
 

Static Public Member Functions

static double shoot ()
 
static double shoot (double a)
 
static void shootArray (const int size, double *vect, double a=1.0)
 
static double shoot (HepRandomEngine *anEngine)
 
static double shoot (HepRandomEngine *anEngine, double a)
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect, double a=1.0)
 
static std::string distributionName ()
 
- Static Public Member Functions inherited from CLHEP::HepRandom
static void setTheSeed (long seed, int lxr=3)
 
static long getTheSeed ()
 
static void setTheSeeds (const long *seeds, int aux=-1)
 
static const long * getTheSeeds ()
 
static void getTheTableSeeds (long *seeds, int index)
 
static HepRandomgetTheGenerator ()
 
static void setTheEngine (HepRandomEngine *theNewEngine)
 
static HepRandomEnginegetTheEngine ()
 
static void saveEngineStatus (const char filename[]="Config.conf")
 
static void restoreEngineStatus (const char filename[]="Config.conf")
 
static std::ostream & saveFullState (std::ostream &os)
 
static std::istream & restoreFullState (std::istream &is)
 
static std::ostream & saveDistState (std::ostream &os)
 
static std::istream & restoreDistState (std::istream &is)
 
static std::ostream & saveStaticRandomStates (std::ostream &os)
 
static std::istream & restoreStaticRandomStates (std::istream &is)
 
static void showEngineStatus ()
 
static int createInstance ()
 
static std::string distributionName ()
 

Additional Inherited Members

- Static Protected Attributes inherited from CLHEP::HepRandom
static const long seedTable [215][2]
 

Detailed Description

Author

Definition at line 43 of file RandStudentT.h.

Constructor & Destructor Documentation

◆ RandStudentT() [1/2]

CLHEP::RandStudentT::RandStudentT ( HepRandomEngine anEngine,
double  a = 1.0 
)
inline

◆ RandStudentT() [2/2]

CLHEP::RandStudentT::RandStudentT ( HepRandomEngine anEngine,
double  a = 1.0 
)
inline

◆ ~RandStudentT()

CLHEP::RandStudentT::~RandStudentT ( )
virtual

Definition at line 35 of file RandStudentT.cc.

36{
37}

Member Function Documentation

◆ distributionName()

static std::string CLHEP::RandStudentT::distributionName ( )
inlinestatic

Definition at line 101 of file RandStudentT.h.

101{return "RandStudentT";}

◆ engine()

HepRandomEngine & CLHEP::RandStudentT::engine ( )
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 33 of file RandStudentT.cc.

33{return *localEngine;}

◆ fire() [1/2]

double CLHEP::RandStudentT::fire ( )
inline

Referenced by dist_layout(), fireArray(), and operator()().

◆ fire() [2/2]

double CLHEP::RandStudentT::fire ( double  a)

Definition at line 103 of file RandStudentT.cc.

103 {
104
105 double u,v,w;
106
107 do
108 {
109 u = 2.0 * localEngine->flat() - 1.0;
110 v = 2.0 * localEngine->flat() - 1.0;
111 }
112 while ((w = u * u + v * v) > 1.0);
113
114 return(u * std::sqrt( a * ( std::exp(- 2.0 / a * std::log(w)) - 1.0) / w));
115}

◆ fireArray() [1/2]

void CLHEP::RandStudentT::fireArray ( const int  size,
double vect 
)

Definition at line 117 of file RandStudentT.cc.

118{
119 for( double* v = vect; v != vect + size; ++v )
120 *v = fire(defaultA);
121}

◆ fireArray() [2/2]

void CLHEP::RandStudentT::fireArray ( const int  size,
double vect,
double  a 
)

Definition at line 123 of file RandStudentT.cc.

125{
126 for( double* v = vect; v != vect + size; ++v )
127 *v = fire(a);
128}

◆ get()

std::istream & CLHEP::RandStudentT::get ( std::istream &  is)
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 162 of file RandStudentT.cc.

162 {
163 std::string inName;
164 is >> inName;
165 if (inName != name()) {
166 is.clear(std::ios::badbit | is.rdstate());
167 std::cerr << "Mismatch when expecting to read state of a "
168 << name() << " distribution\n"
169 << "Name found was " << inName
170 << "\nistream is left in the badbit state\n";
171 return is;
172 }
173 if (possibleKeywordInput(is, "Uvec", defaultA)) {
174 std::vector<unsigned long> t(2);
175 is >> defaultA >> t[0] >> t[1]; defaultA = DoubConv::longs2double(t);
176 return is;
177 }
178 // is >> defaultA encompassed by possibleKeywordInput
179 return is;
180}
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:110
std::string name() const
Definition: RandStudentT.cc:32
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:168

◆ name()

std::string CLHEP::RandStudentT::name ( ) const
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 32 of file RandStudentT.cc.

32{return "RandStudentT";}

Referenced by get(), and put().

◆ operator()() [1/2]

double CLHEP::RandStudentT::operator() ( )
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 39 of file RandStudentT.cc.

39 {
40 return fire( defaultA );
41}

◆ operator()() [2/2]

double CLHEP::RandStudentT::operator() ( double  a)

Definition at line 43 of file RandStudentT.cc.

43 {
44 return fire( a );
45}

◆ put()

std::ostream & CLHEP::RandStudentT::put ( std::ostream &  os) const
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 144 of file RandStudentT.cc.

144 {
145 long pr=os.precision(20);
146 std::vector<unsigned long> t(2);
147 os << " " << name() << "\n";
148 os << "Uvec" << "\n";
149 t = DoubConv::dto2longs(defaultA);
150 os << defaultA << " " << t[0] << " " << t[1] << "\n";
151 os.precision(pr);
152 return os;
153#ifdef REMOVED
154 long pr=os.precision(20);
155 os << " " << name() << "\n";
156 os << defaultA << "\n";
157 os.precision(pr);
158 return os;
159#endif
160}
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:94

◆ shoot() [1/4]

static double CLHEP::RandStudentT::shoot ( )
inlinestatic

◆ shoot() [2/4]

double CLHEP::RandStudentT::shoot ( double  a)
static

Definition at line 47 of file RandStudentT.cc.

47 {
48/******************************************************************
49 * *
50 * Student-t Distribution - Polar Method *
51 * *
52 ******************************************************************
53 * *
54 * The polar method of Box/Muller for generating Normal variates *
55 * is adapted to the Student-t distribution. The two generated *
56 * variates are not independent and the expected no. of uniforms *
57 * per variate is 2.5464. *
58 * *
59 ******************************************************************
60 * *
61 * FUNCTION : - tpol samples a random number from the *
62 * Student-t distribution with parameter a > 0. *
63 * REFERENCE : - R.W. Bailey (1994): Polar generation of random *
64 * variates with the t-distribution, Mathematics *
65 * of Computation 62, 779-781. *
66 * SUBPROGRAM : - ... (0,1)-Uniform generator *
67 * *
68 * *
69 * Implemented by F. Niederl, 1994 *
70 ******************************************************************/
71
72 double u,v,w;
73
74// Check for valid input value
75
76 if( a < 0.0) return (DBL_MAX);
77
78 do
79 {
80 u = 2.0 * HepRandom::getTheEngine()->flat() - 1.0;
81 v = 2.0 * HepRandom::getTheEngine()->flat() - 1.0;
82 }
83 while ((w = u * u + v * v) > 1.0);
84
85 return(u * std::sqrt( a * ( std::exp(- 2.0 / a * std::log(w)) - 1.0) / w));
86}
virtual double flat()=0
static HepRandomEngine * getTheEngine()
Definition: Random.cc:270

◆ shoot() [3/4]

static double CLHEP::RandStudentT::shoot ( HepRandomEngine anEngine)
inlinestatic

◆ shoot() [4/4]

double CLHEP::RandStudentT::shoot ( HepRandomEngine anEngine,
double  a 
)
static

Definition at line 130 of file RandStudentT.cc.

130 {
131
132 double u,v,w;
133
134 do
135 {
136 u = 2.0 * anEngine->flat() - 1.0;
137 v = 2.0 * anEngine->flat() - 1.0;
138 }
139 while ((w = u * u + v * v) > 1.0);
140
141 return(u * std::sqrt( a * ( std::exp(- 2.0 / a * std::log(w)) - 1.0) / w));
142}

◆ shootArray() [1/2]

void CLHEP::RandStudentT::shootArray ( const int  size,
double vect,
double  a = 1.0 
)
static

Definition at line 88 of file RandStudentT.cc.

90{
91 for( double* v = vect; v != vect + size; ++v )
92 *v = shoot(a);
93}
static double shoot()

◆ shootArray() [2/2]

void CLHEP::RandStudentT::shootArray ( HepRandomEngine anEngine,
const int  size,
double vect,
double  a = 1.0 
)
static

Definition at line 95 of file RandStudentT.cc.

98{
99 for( double* v = vect; v != vect + size; ++v )
100 *v = shoot(anEngine,a);
101}

The documentation for this class was generated from the following files: