Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:38

0001 // $Id: RandSkewNormal.h,v 1.1 2011/05/27 20:36:28 garren Exp $
0002 // -*- C++ -*-
0003 //
0004 // -----------------------------------------------------------------------
0005 //                             HEP Random
0006 //                          --- RandSkewNormal ---
0007 //                          class header file
0008 // -----------------------------------------------------------------------
0009 
0010 // RandSkewNormal ---
0011 //    returns a skew-normal distribution with shape parameter k
0012 //    To get a distribution with scale parameter b and location m:
0013 //    r = m + b * RandSkewNormal.fire(k);
0014 // http://azzalini.stat.unipd.it/SN/
0015 // algorithm from K. McFarlane, June 2010.
0016 
0017 // =======================================================================
0018 // M Fischler and L Garren - Created: 26 May 2011
0019 // =======================================================================
0020 
0021 #ifndef RandSkewNormal_h
0022 #define RandSkewNormal_h 1
0023 
0024 #include "CLHEP/Random/defs.h"
0025 #include "CLHEP/Random/Random.h"
0026 #include "CLHEP/Utility/memory.h"
0027 
0028 namespace CLHEP {
0029 
0030 /**
0031  * @author <mf@fnal.gov>
0032  * @ingroup random
0033  */
0034 class RandSkewNormal : public HepRandom {
0035 
0036 public:
0037 
0038   inline RandSkewNormal ( HepRandomEngine& anEngine, double shape=0. );
0039   inline RandSkewNormal ( HepRandomEngine* anEngine, double shape=0. );
0040   // These constructors should be used to instantiate a RandSkewNormal
0041   // distribution object defining a local engine for it.
0042   // The static generator will be skipped using the non-static methods
0043   // defined below.
0044   // If the engine is passed by pointer the corresponding engine object
0045   // will be deleted by the RandSkewNormal destructor.
0046   // If the engine is passed by reference the corresponding engine object
0047   // will not be deleted by the RandSkewNormal destructor.
0048 
0049   virtual ~RandSkewNormal();
0050   // Destructor
0051 
0052   // Static methods to shoot random values using the static generator
0053 
0054   static  double shoot();
0055 
0056   static  double shoot( double shape );
0057 
0058   static  void shootArray ( const int size, double* vect,
0059                             double shape=0. );
0060 
0061   //  Static methods to shoot random values using a given engine
0062   //  by-passing the static generator.
0063 
0064   static  double shoot( HepRandomEngine* anEngine );
0065 
0066   static  double shoot( HepRandomEngine* anEngine, double shape );
0067 
0068   static  void shootArray ( HepRandomEngine* anEngine, const int size,
0069                             double* vect, double shape=0. );
0070 
0071   //  Methods using the localEngine to shoot random values, by-passing
0072   //  the static generator.
0073 
0074   double fire();
0075 
0076   double fire( double shape );
0077 
0078   void fireArray ( const int size, double* vect );
0079   void fireArray ( const int size, double* vect, double shape );
0080   
0081   double operator()();
0082   double operator()( double shape );
0083 
0084   // Save and restore to/from streams
0085   
0086   std::ostream & put ( std::ostream & os ) const;
0087   std::istream & get ( std::istream & is );
0088 
0089   std::string name() const;
0090   HepRandomEngine & engine();
0091 
0092   static std::string distributionName() {return "RandSkewNormal";}  
0093   // Provides the name of this distribution class
0094   
0095 protected:
0096 
0097   static double gaussianSkewNormal ( HepRandomEngine *e, double k);
0098   double getShapeParameter() { return shapeParameter; }
0099 
0100   inline HepRandomEngine* getLocalEngine();
0101 
0102 private:
0103 
0104   shared_ptr<HepRandomEngine> localEngine;
0105   double shapeParameter;
0106 
0107 };
0108 
0109 }  // namespace CLHEP
0110 
0111 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0112 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
0113 using namespace CLHEP;
0114 #endif
0115 
0116 #include "CLHEP/Random/RandSkewNormal.icc"
0117 
0118 #endif