CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

Random/CLHEP/Random/RandBinomial.h
Go to the documentation of this file.
1 // $Id: RandBinomial.h,v 1.5 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- RandBinomial ---
7 // class header file
8 // -----------------------------------------------------------------------
9 
10 // Class defining methods for shooting binomial distributed random values,
11 // given a sample size n (default=1) and a probability p (default=0.5).
12 // Default values are used for operator()().
13 //
14 // Valid input values satisfy the relation n*min(p,1-p) > 0. When invalid
15 // values are presented, the code silently returns -1.0.
16 
17 // =======================================================================
18 // John Marraffino - Created: 12th May 1998 Based on the C-Rand package
19 // by Ernst Stadlober and Franz Niederl of the Technical
20 // University of Graz, Austria.
21 // Gabriele Cosmo - Removed useless methods and data: 5th Jan 1999
22 // M Fischler - put and get to/from streams 12/10/04
23 // =======================================================================
24 
25 #ifndef RandBinomial_h
26 #define RandBinomial_h 1
27 
28 #include "CLHEP/Random/Random.h"
29 #include "CLHEP/Utility/memory.h"
30 
31 namespace CLHEP {
32 
37 class RandBinomial : public HepRandom {
38 
39 public:
40 
41  inline RandBinomial ( HepRandomEngine& anEngine, long n=1,
42  double p=0.5 );
43  inline RandBinomial ( HepRandomEngine* anEngine, long n=1,
44  double p=0.5 );
45  // These constructors should be used to instantiate a RandBinomial
46  // distribution object defining a local engine for it.
47  // The static generator will be skipped using the non-static methods
48  // defined below.
49  // If the engine is passed by pointer the corresponding engine object
50  // will be deleted by the RandBinomial destructor.
51  // If the engine is passed by reference the corresponding engine object
52  // will not be deleted by the RandBinomial destructor.
53 
54  virtual ~RandBinomial();
55  // Destructor
56 
57  // Static methods to shoot random values using the static generator
58 
59  static inline double shoot();
60 
61  static double shoot( long n, double p );
62 
63  static void shootArray ( const int size, double* vect,
64  long n=1, double p=0.5 );
65 
66  // Static methods to shoot random values using a given engine
67  // by-passing the static generator.
68 
69  static inline double shoot( HepRandomEngine* anEngine );
70 
71  static double shoot( HepRandomEngine* anEngine,
72  long n, double p );
73 
74  static void shootArray ( HepRandomEngine* anEngine, const int size,
75  double* vect, long n=1,
76  double p=0.5 );
77 
78  // Methods using the localEngine to shoot random values, by-passing
79  // the static generator.
80 
81  inline double fire();
82 
83  double fire( long n, double p );
84 
85  void fireArray ( const int size, double* vect);
86  void fireArray ( const int size, double* vect,
87  long n, double p );
88  inline double operator()();
89  inline double operator()( long n, double p );
90 
91  // Save and restore to/from streams
92 
93  std::ostream & put ( std::ostream & os ) const;
94  std::istream & get ( std::istream & is );
95 
96  std::string name() const;
97  HepRandomEngine & engine();
98 
99  static std::string distributionName() {return "RandBinomial";}
100  // Provides the name of this distribution class
101 
102 private:
103 
104  static double genBinomial( HepRandomEngine *anEngine, long n, double p );
105 
106  shared_ptr<HepRandomEngine> localEngine;
107  long defaultN;
108  double defaultP;
109 
110 };
111 
112 } // namespace CLHEP
113 
114 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
115 // backwards compatibility will be enabled ONLY in CLHEP 1.9
116 using namespace CLHEP;
117 #endif
118 
119 #include "CLHEP/Random/RandBinomial.icc"
120 
121 #endif
CLHEP::shared_ptr
Definition: Matrix/CLHEP/Utility/memory.h:66
CLHEP::HepRandomEngine
Definition: Matrix/CLHEP/Random/RandomEngine.h:55
CLHEP::RandBinomial::shoot
static double shoot()
is
HepRotation and so forth isNear() norm2() rectify() static Rotation row1 row4(To avoid bloat in the code pulled in for programs which don 't use all these features, we split the implementation .cc files. Only isNear() goes into the original Rotation.cc) --------------------------------------- HepAxisAngle and HepEulerAngles classes --------------------------------------- These classes are very useful and simple structures for holding the result of a nice intuituve decomposition of a rotation there is no longer much content in the distinct ZOOM PhysicsVectors library The only content left in the library is the object files representing the various Exception objects When we build the CLHEP classes for the ZOOM we will set up so as to use ZOOM SpaceVector is(but we can disable namespace usage and most of our users do so at this point). What I do is leave Hep3Vector in the global namespace
CLHEP::RandBinomial::engine
HepRandomEngine & engine()
Definition: RandBinomial.cc:28
CLHEP::RandBinomial::fire
double fire()
CLHEP::detail::n
n
Definition: Ranlux64Engine.cc:85
size
user code seldom needs to call this function directly ZMerrno whether or not they are still recorded ZMerrno size() Return the(integer) number of ZMthrow 'n exceptions currently recorded. 5) ZMerrno.clear() Set an internal counter to zero. This counter is available(see next function) to user code to track ZMthrow 'n exceptions that have occurred during any arbitrary time interval. 6) ZMerrno.countSinceCleared() Return the(integer) number of ZMthrow 'n exceptions that have been recorded via ZMerrno.write()
CLHEP::RandBinomial::name
std::string name() const
Definition: RandBinomial.cc:27
CLHEP
Definition: ClhepVersion.h:13
CLHEP::RandBinomial::operator()
double operator()()
CLHEP::RandBinomial::shootArray
static void shootArray(const int size, double *vect, long n=1, double p=0.5)
Definition: RandBinomial.cc:47
CLHEP::RandBinomial::distributionName
static std::string distributionName()
Definition: Random/CLHEP/Random/RandBinomial.h:99
CLHEP::RandBinomial::get
std::istream & get(std::istream &is)
Definition: RandBinomial.cc:348
CLHEP::RandBinomial::fireArray
void fireArray(const int size, double *vect)
Definition: RandBinomial.cc:62
CLHEP::RandBinomial::RandBinomial
RandBinomial(HepRandomEngine &anEngine, long n=1, double p=0.5)
CLHEP::RandBinomial::put
std::ostream & put(std::ostream &os) const
Definition: RandBinomial.cc:330
CLHEP::RandBinomial::~RandBinomial
virtual ~RandBinomial()
Definition: RandBinomial.cc:30