1 // $Id: RandStudentT.h,v 1.5 2010/06/16 17:24:53 garren Exp $
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 //                             HEP Random
6 //                         --- RandStudentT ---
7 //                          class header file
8 // -----------------------------------------------------------------------
9 
10 // Class defining methods for shooting Student's t- distributed random
11 // values, given a number of degrees of freedom a (default=1.0).
12 // Default values are used for operator()().
13 
14 // Valid input values are a > 0.  When invalid values are presented, the
15 // code silently returns DBL_MAX from <float.h> which is the same as
16 // MAXDOUBLE in <values.h> on systems where the latter exists.
17 
18 // =======================================================================
19 // John Marraffino - Created: Based on the C-Rand package
20 //                   by Ernst Stadlober and Franz Niederl of the Technical
21 //                   University of Graz, Austria : 12th May 1998
22 //                 - Removed <values.h> because that won't work
23 //                   on NT : 26th Jun 1998
24 // Gabriele Cosmo  - Fixed minor bug on inline definition for shoot()
25 //                   methods. Created .icc file : 20th Aug 1998
26 //                 - Removed useless methods and data: 5th Jan 1999
27 // M Fischler      - put and get to/from streams 12/10/04
28 // =======================================================================
29 
30 #ifndef RandStudentT_h
31 #define RandStudentT_h 1
32 
33 #include "CLHEP/Random/defs.h"
34 #include "CLHEP/Random/Random.h"
35 #include "CLHEP/Utility/memory.h"
36 
37 namespace CLHEP {
38 
39 /**
40  * @author
41  * @ingroup random
42  */
43 class RandStudentT : public HepRandom {
44 
45 public:
46 
47   inline RandStudentT ( HepRandomEngine& anEngine, double a=1.0 );
48   inline RandStudentT ( HepRandomEngine* anEngine, double a=1.0 );
49   // These constructors should be used to instantiate a RandStudentT
50   // distribution object defining a local engine for it.
51   // The static generator will be skipped using the non-static methods
52   // defined below.
53   // If the engine is passed by pointer the corresponding engine object
54   // will be deleted by the RandStudentT destructor.
55   // If the engine is passed by reference the corresponding engine object
56   // will not be deleted by the RandStudentT destructor.
57 
58   virtual ~RandStudentT();
59   // Destructor
60 
61   // Save and restore to/from streams
62 
63   std::ostream & put ( std::ostream & os ) const;
64   std::istream & get ( std::istream & is );
65 
66   // Static methods to shoot random values using the static generator
67 
68   static  inline double shoot();
69 
70   static  double shoot( double a );
71 
72   static  void shootArray ( const int size, double* vect,
73                             double a=1.0 );
74 
75   //  Static methods to shoot random values using a given engine
76   //  by-passing the static generator.
77 
78   static  inline double shoot( HepRandomEngine* anEngine );
79 
80   static  double shoot( HepRandomEngine* anEngine,
81                            double a );
82 
83   static  void shootArray ( HepRandomEngine* anEngine, const int size,
84                             double* vect, double a=1.0 );
85 
86   //  Methods using the localEngine to shoot random values, by-passing
87   //  the static generator.
88 
89   inline double fire();
90 
91   double fire( double a );
92 
93   void fireArray ( const int size, double* vect );
94   void fireArray ( const int size, double* vect, double a );
95   double operator()();
96   double operator()( double a );
97 
98   std::string name() const;
99   HepRandomEngine & engine();
100 
distributionName()101   static std::string distributionName() {return "RandStudentT";}
102   // Provides the name of this distribution class
103 
104 
105 private:
106 
107   std::shared_ptr<HepRandomEngine> localEngine;
108   double defaultA;
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/RandStudentT.icc"
120 
121 #endif
122