Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
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 lux=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 42 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 30 of file RandStudentT.cc.

31{
32}

Member Function Documentation

◆ distributionName()

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

Definition at line 100 of file RandStudentT.h.

100{return "RandStudentT";}

◆ engine()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 28 of file RandStudentT.cc.

28{return *localEngine;}

◆ fire() [1/2]

double CLHEP::RandStudentT::fire ( )
inline

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

◆ fire() [2/2]

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

Definition at line 98 of file RandStudentT.cc.

98 {
99
100 double u,v,w;
101
102 do
103 {
104 u = 2.0 * localEngine->flat() - 1.0;
105 v = 2.0 * localEngine->flat() - 1.0;
106 }
107 while ((w = u * u + v * v) > 1.0);
108
109 return(u * std::sqrt( a * ( std::exp(- 2.0 / a * std::log(w)) - 1.0) / w));
110}

◆ fireArray() [1/2]

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

Definition at line 112 of file RandStudentT.cc.

113{
114 for( double* v = vect; v != vect + size; ++v )
115 *v = fire(defaultA);
116}

◆ fireArray() [2/2]

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

Definition at line 118 of file RandStudentT.cc.

120{
121 for( double* v = vect; v != vect + size; ++v )
122 *v = fire(a);
123}

◆ get()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 150 of file RandStudentT.cc.

150 {
151 std::string inName;
152 is >> inName;
153 if (inName != name()) {
154 is.clear(std::ios::badbit | is.rdstate());
155 std::cerr << "Mismatch when expecting to read state of a "
156 << name() << " distribution\n"
157 << "Name found was " << inName
158 << "\nistream is left in the badbit state\n";
159 return is;
160 }
161 if (possibleKeywordInput(is, "Uvec", defaultA)) {
162 std::vector<unsigned long> t(2);
163 is >> defaultA >> t[0] >> t[1]; defaultA = DoubConv::longs2double(t);
164 return is;
165 }
166 // is >> defaultA encompassed by possibleKeywordInput
167 return is;
168}
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:114
std::string name() const
Definition: RandStudentT.cc:27
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:167

◆ name()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 27 of file RandStudentT.cc.

27{return "RandStudentT";}

Referenced by get(), and put().

◆ operator()() [1/2]

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

Reimplemented from CLHEP::HepRandom.

Definition at line 34 of file RandStudentT.cc.

34 {
35 return fire( defaultA );
36}

◆ operator()() [2/2]

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

Definition at line 38 of file RandStudentT.cc.

38 {
39 return fire( a );
40}

◆ put()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 139 of file RandStudentT.cc.

139 {
140 int pr=os.precision(20);
141 std::vector<unsigned long> t(2);
142 os << " " << name() << "\n";
143 os << "Uvec" << "\n";
144 t = DoubConv::dto2longs(defaultA);
145 os << defaultA << " " << t[0] << " " << t[1] << "\n";
146 os.precision(pr);
147 return os;
148}
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:98

◆ shoot() [1/4]

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

Referenced by shootArray().

◆ shoot() [2/4]

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

Definition at line 42 of file RandStudentT.cc.

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

◆ 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 125 of file RandStudentT.cc.

125 {
126
127 double u,v,w;
128
129 do
130 {
131 u = 2.0 * anEngine->flat() - 1.0;
132 v = 2.0 * anEngine->flat() - 1.0;
133 }
134 while ((w = u * u + v * v) > 1.0);
135
136 return(u * std::sqrt( a * ( std::exp(- 2.0 / a * std::log(w)) - 1.0) / w));
137}

◆ shootArray() [1/2]

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

Definition at line 83 of file RandStudentT.cc.

85{
86 for( double* v = vect; v != vect + size; ++v )
87 *v = shoot(a);
88}
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 90 of file RandStudentT.cc.

93{
94 for( double* v = vect; v != vect + size; ++v )
95 *v = shoot(anEngine,a);
96}

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