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

RandSkewNormal.h

Go to the documentation of this file.
00001 // $Id: RandSkewNormal.h,v 1.1 2011/05/27 20:36:28 garren Exp $
00002 // -*- C++ -*-
00003 //
00004 // -----------------------------------------------------------------------
00005 //                             HEP Random
00006 //                          --- RandSkewNormal ---
00007 //                          class header file
00008 // -----------------------------------------------------------------------
00009 
00010 // RandSkewNormal ---
00011 //    returns a skew-normal distribution with shape parameter k
00012 //    To get a distribution with scale parameter b and location m:
00013 //    r = m + b * RandSkewNormal.fire(k);
00014 // http://azzalini.stat.unipd.it/SN/
00015 // algorithm from K. McFarlane, June 2010.
00016 
00017 // =======================================================================
00018 // M Fischler and L Garren - Created: 26 May 2011
00019 // =======================================================================
00020 
00021 #ifndef RandSkewNormal_h
00022 #define RandSkewNormal_h 1
00023 
00024 #include "CLHEP/Random/defs.h"
00025 #include "CLHEP/Random/Random.h"
00026 #include "CLHEP/Utility/memory.h"
00027 
00028 namespace CLHEP {
00029 
00034 class RandSkewNormal : public HepRandom {
00035 
00036 public:
00037 
00038   inline RandSkewNormal ( HepRandomEngine& anEngine, double shape=0. );
00039   inline RandSkewNormal ( HepRandomEngine* anEngine, double shape=0. );
00040   // These constructors should be used to instantiate a RandSkewNormal
00041   // distribution object defining a local engine for it.
00042   // The static generator will be skipped using the non-static methods
00043   // defined below.
00044   // If the engine is passed by pointer the corresponding engine object
00045   // will be deleted by the RandSkewNormal destructor.
00046   // If the engine is passed by reference the corresponding engine object
00047   // will not be deleted by the RandSkewNormal destructor.
00048 
00049   virtual ~RandSkewNormal();
00050   // Destructor
00051 
00052   // Static methods to shoot random values using the static generator
00053 
00054   static  double shoot();
00055 
00056   static  double shoot( double shape );
00057 
00058   static  void shootArray ( const int size, double* vect,
00059                             double shape=0. );
00060 
00061   //  Static methods to shoot random values using a given engine
00062   //  by-passing the static generator.
00063 
00064   static  double shoot( HepRandomEngine* anEngine );
00065 
00066   static  double shoot( HepRandomEngine* anEngine, double shape );
00067 
00068   static  void shootArray ( HepRandomEngine* anEngine, const int size,
00069                             double* vect, double shape=0. );
00070 
00071   //  Methods using the localEngine to shoot random values, by-passing
00072   //  the static generator.
00073 
00074   double fire();
00075 
00076   double fire( double shape );
00077 
00078   void fireArray ( const int size, double* vect );
00079   void fireArray ( const int size, double* vect, double shape );
00080   
00081   double operator()();
00082   double operator()( double shape );
00083 
00084   // Save and restore to/from streams
00085   
00086   std::ostream & put ( std::ostream & os ) const;
00087   std::istream & get ( std::istream & is );
00088 
00089   std::string name() const;
00090   HepRandomEngine & engine();
00091 
00092   static std::string distributionName() {return "RandSkewNormal";}  
00093   // Provides the name of this distribution class
00094   
00095 protected:
00096 
00097   static double gaussianSkewNormal ( HepRandomEngine *e, double k);
00098   double getShapeParameter() { return shapeParameter; }
00099 
00100   inline HepRandomEngine* getLocalEngine();
00101 
00102 private:
00103 
00104   shared_ptr<HepRandomEngine> localEngine;
00105   double shapeParameter;
00106 
00107 };
00108 
00109 }  // namespace CLHEP
00110 
00111 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00112 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00113 using namespace CLHEP;
00114 #endif
00115 
00116 #include "CLHEP/Random/RandSkewNormal.icc"
00117 
00118 #endif

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7