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

#include <RandSkewNormal.h>

+ Inheritance diagram for CLHEP::RandSkewNormal:

Public Member Functions

 RandSkewNormal (HepRandomEngine &anEngine, double shape=0.)
 
 RandSkewNormal (HepRandomEngine *anEngine, double shape=0.)
 
virtual ~RandSkewNormal ()
 
double fire ()
 
double fire (double shape)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, double *vect, double shape)
 
double operator() ()
 
double operator() (double shape)
 
std::ostream & put (std::ostream &os) const
 
std::istream & get (std::istream &is)
 
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 shape)
 
static void shootArray (const int size, double *vect, double shape=0.)
 
static double shoot (HepRandomEngine *anEngine)
 
static double shoot (HepRandomEngine *anEngine, double shape)
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect, double shape=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 ()
 

Protected Member Functions

double getShapeParameter ()
 
HepRandomEnginegetLocalEngine ()
 

Static Protected Member Functions

static double gaussianSkewNormal (HepRandomEngine *e, double k)
 

Additional Inherited Members

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

Detailed Description

Author
mf@fn.nosp@m.al.g.nosp@m.ov

Definition at line 34 of file RandSkewNormal.h.

Constructor & Destructor Documentation

◆ RandSkewNormal() [1/2]

CLHEP::RandSkewNormal::RandSkewNormal ( HepRandomEngine anEngine,
double  shape = 0. 
)
inline

◆ RandSkewNormal() [2/2]

CLHEP::RandSkewNormal::RandSkewNormal ( HepRandomEngine anEngine,
double  shape = 0. 
)
inline

◆ ~RandSkewNormal()

CLHEP::RandSkewNormal::~RandSkewNormal ( )
virtual

Definition at line 29 of file RandSkewNormal.cc.

29{}

Member Function Documentation

◆ distributionName()

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

Definition at line 92 of file RandSkewNormal.h.

92{return "RandSkewNormal";}

◆ engine()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 27 of file RandSkewNormal.cc.

27{return *localEngine;}

◆ fire() [1/2]

double CLHEP::RandSkewNormal::fire ( )

Definition at line 85 of file RandSkewNormal.cc.

85 {
87}
static double gaussianSkewNormal(HepRandomEngine *e, double k)
HepRandomEngine * getLocalEngine()

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

◆ fire() [2/2]

double CLHEP::RandSkewNormal::fire ( double  shape)

Definition at line 89 of file RandSkewNormal.cc.

89 {
90 return gaussianSkewNormal( getLocalEngine(), shape );
91}

◆ fireArray() [1/2]

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

Definition at line 93 of file RandSkewNormal.cc.

94{
95 for( double* v = vect; v != vect+size; ++v )
96 *v = fire( shapeParameter );
97}

◆ fireArray() [2/2]

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

Definition at line 99 of file RandSkewNormal.cc.

101{
102 for( double* v = vect; v != vect+size; ++v )
103 *v = fire( shape );
104}

◆ gaussianSkewNormal()

double CLHEP::RandSkewNormal::gaussianSkewNormal ( HepRandomEngine e,
double  k 
)
staticprotected

Definition at line 108 of file RandSkewNormal.cc.

109{
110 // RandSkewNormal is an implementation of Azzalini's SN generator
111 // http://azzalini.stat.unipd.it/SN/
112 // K. McFarlane, June 2010.
113 // For location parameter m = 0., scale = 1.
114 // To get a distribution with scale parameter b and location m:
115 // r = m + b * RandSkewNormal.fire(k);
116 double u[2] = {0.};
117 RandGaussT::shootArray(e, 2, u, 0, 1);
118 double delta = k/std::sqrt(1. + k*k);
119 double u1 = delta*u[0] + std::sqrt(1 - delta*delta)*u[1];
120 double r = u[0] >= 0 ? u1 : -u1;
121 return r;
122}
static void shootArray(const int size, double *vect, double mean=0.0, double stdDev=1.0)
Definition: RandGaussT.cc:37

Referenced by fire(), and shoot().

◆ get()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 137 of file RandSkewNormal.cc.

137 {
138 std::string inName;
139 is >> inName;
140 if (inName != name()) {
141 is.clear(std::ios::badbit | is.rdstate());
142 std::cerr << "Mismatch when expecting to read state of a "
143 << name() << " distribution\n"
144 << "Name found was " << inName
145 << "\nistream is left in the badbit state\n";
146 return is;
147 }
148 if (possibleKeywordInput(is, "Uvec", shapeParameter)) {
149 std::vector<unsigned long> t(2);
150 is >> shapeParameter >> t[0] >> t[1]; shapeParameter = DoubConv::longs2double(t);
151 return is;
152 }
153 // is >> shapeParameter encompassed by possibleKeywordInput
154 return is;
155}
static double longs2double(const std::vector< unsigned long > &v)
Definition: DoubConv.cc:110
std::string name() const
bool possibleKeywordInput(IS &is, const std::string &key, T &t)
Definition: RandomEngine.h:168

◆ getLocalEngine()

HepRandomEngine * CLHEP::RandSkewNormal::getLocalEngine ( )
inlineprotected

Referenced by fire().

◆ getShapeParameter()

double CLHEP::RandSkewNormal::getShapeParameter ( )
inlineprotected

Definition at line 98 of file RandSkewNormal.h.

98{ return shapeParameter; }

Referenced by fire().

◆ name()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 26 of file RandSkewNormal.cc.

26{return "RandSkewNormal";}

Referenced by get(), and put().

◆ operator()() [1/2]

double CLHEP::RandSkewNormal::operator() ( )
virtual

Reimplemented from CLHEP::HepRandom.

Definition at line 31 of file RandSkewNormal.cc.

32{
33 return fire( shapeParameter );
34}

◆ operator()() [2/2]

double CLHEP::RandSkewNormal::operator() ( double  shape)

Definition at line 36 of file RandSkewNormal.cc.

37{
38 return fire( shape );
39}

◆ put()

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

Reimplemented from CLHEP::HepRandom.

Definition at line 126 of file RandSkewNormal.cc.

126 {
127 long pr=os.precision(20);
128 std::vector<unsigned long> t(2);
129 os << " " << name() << "\n";
130 os << "Uvec" << "\n";
131 t = DoubConv::dto2longs(shapeParameter);
132 os << shapeParameter << " " << t[0] << " " << t[1] << "\n";
133 os.precision(pr);
134 return os;
135}
static std::vector< unsigned long > dto2longs(double d)
Definition: DoubConv.cc:94

◆ shoot() [1/4]

double CLHEP::RandSkewNormal::shoot ( )
static

Definition at line 55 of file RandSkewNormal.cc.

56{
57 // really dumb use of RandSkewNormal
58 HepRandomEngine* anEngine = HepRandom::getTheEngine();
59 double k = 1;
60 return gaussianSkewNormal( anEngine, k );
61}
static HepRandomEngine * getTheEngine()
Definition: Random.cc:270

Referenced by captureStatics(), randomizeStatics(), and shootArray().

◆ shoot() [2/4]

double CLHEP::RandSkewNormal::shoot ( double  shape)
static

Definition at line 63 of file RandSkewNormal.cc.

64{
65 HepRandomEngine* anEngine = HepRandom::getTheEngine();
66 return gaussianSkewNormal( anEngine, shape );
67}

◆ shoot() [3/4]

double CLHEP::RandSkewNormal::shoot ( HepRandomEngine anEngine)
static

Definition at line 43 of file RandSkewNormal.cc.

44{
45 // really dumb use of RandSkewNormal
46 double k = 1;
47 return gaussianSkewNormal( anEngine, k );
48}

◆ shoot() [4/4]

double CLHEP::RandSkewNormal::shoot ( HepRandomEngine anEngine,
double  shape 
)
static

Definition at line 50 of file RandSkewNormal.cc.

51{
52 return gaussianSkewNormal( anEngine, shape );
53}

◆ shootArray() [1/2]

void CLHEP::RandSkewNormal::shootArray ( const int  size,
double vect,
double  shape = 0. 
)
static

Definition at line 69 of file RandSkewNormal.cc.

71{
72 for( double* v = vect; v != vect+size; ++v )
73 *v = shoot(shape);
74}
static double shoot()

◆ shootArray() [2/2]

void CLHEP::RandSkewNormal::shootArray ( HepRandomEngine anEngine,
const int  size,
double vect,
double  shape = 0. 
)
static

Definition at line 76 of file RandSkewNormal.cc.

78{
79 for( double* v = vect; v != vect+size; ++v )
80 *v = shoot(anEngine, shape);
81}

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