|
||||
File indexing completed on 2025-01-18 10:10:20
0001 // @(#)root/mathcore:$Id$ 0002 // Author: L. Moneta Tue Aug 4 2015 0003 0004 /********************************************************************** 0005 * * 0006 * Copyright (c) 2015 LCG ROOT Math Team, CERN/PH-SFT * 0007 * * 0008 * * 0009 **********************************************************************/ 0010 0011 // random engines based on ROOT 0012 0013 #ifndef ROOT_Math_MixMaxEngine 0014 #define ROOT_Math_MixMaxEngine 0015 0016 #include <cstdint> 0017 #include <vector> 0018 0019 #include "Math/TRandomEngine.h" 0020 0021 0022 // struct rng_state_st; /// forward declare generator state 0023 0024 // typedef struct rng_state_st rng_state_t; 0025 0026 // namespace mixmax { 0027 // template<int Ndim> 0028 // class mixmax_engine; 0029 // } 0030 0031 namespace ROOT { 0032 0033 namespace Math { 0034 0035 template<int N> 0036 class MixMaxEngineImpl; 0037 0038 /** 0039 MixMaxEngine is a wrapper class for the MIXMAX Random number generator. 0040 MIXMAX is a matrix-recursive random number generator introduced by 0041 G. Savvidy. 0042 0043 The real implementation of the generator, written in C, is in the mixmax.h and mixmax.cxx files. 0044 This generator code is available also at hepforge: http://mixmax.hepforge.org 0045 The MIXMAX code has been created and developed by Konstantin Savvidy and it is 0046 released under GNU Lesser General Public License v3. 0047 0048 This wrapper class provides 3 different variants of MIXMAX according to the template para extra parameter N. 0049 The extra parameter, `SkipNumber`, is used to perform additional iterations of the generator before returning the random numbers. 0050 For example, when `SkipNumber = 2`, the generator will have two extra iterations that will be discarder. 0051 0052 - MIXMAX with N = 240. This is a new version of the generator (version 2.0beta) described in the 0053 <a href="http://dx.doi.org/10.1016/j.chaos.2016.05.003">2016 paper</a> (3rd reference), with 0054 special number \f$s=487013230256099140\f$, \f$m=2^{51}+1\f$ and having a period of \f$10^{4389}\f$. 0055 0056 - MIXMAX with N = 17, from the 2.0 beta version with \f$s=0\f$ and \f$m=2^{36}+1\f$. The period of the 0057 generator is \f$10^{294}\f$. 0058 0059 - MIXMAX with N = 256 from the 1.0 version. The period is (for `SkipNumber=0`) \f$10^{4682}\f$. 0060 For this generator we recommend in ROOT using a default value of `SkipNumber=2, while for the 0061 previous two generators skipping is not needed. 0062 0063 This table describes the properties of the MIXMAX generators. MIXMAX is a genuine 61 bit 0064 generator on the Galois field GF[p], where \f$p=2^{61}-1\f$ is the Mersenne prime number. 0065 The MIXMAX generators with these parameters pass all of the BigCrush 0066 tests in the [TestU01 suite](http://simul.iro.umontreal.ca/testu01/tu01.html) 0067 0068 0069 0070 | Dimension | Entropy | Decorrelation Time | Iteration Time | Relaxation Time | Period q | 0071 |-----------|-------------|----------------------------------|-----------------|---------------------------------------------------|-------------------------------------| 0072 | N | \f$~h(T)\f$ | \f$\tau_0 = {1\over h(T) 2N }\f$ | t | \f$\tau ={1\over h(T) \ln {1\over \delta v_0}}\f$ | \f$\log_{10} (q)\f$ | 0073 | 256 | 194 | 0.000012 | 1 | 95.00 | 4682 (full period is not confirmed) | 0074 | 8 | 220 | 0.00028 | 1 | 1.54 | 129 | 0075 | 17 | 374 | 0.000079 | 1 | 1.92 | 294 | 0076 | 240 | 8679 | 0.00000024 | 1 | 1.17 | 4389 | 0077 0078 0079 The entropy \f$h(T)\f$, decorrelation time \f$\tau_0\f$ decorrelation time, relaxation 0080 time \f$\tau\f$ and period of the MIXMAX generator, expressed in units of the iteration 0081 time \f$t\f$, which is normalised to 1. Clearly \f$\tau_0~ < t ~< \tau\f$. 0082 0083 #### The References for MIXMAX are: 0084 0085 - G.K.Savvidy and N.G.Ter-Arutyunian, *On the Monte Carlo simulation of physical systems, 0086 J.Comput.Phys. 97, 566 (1991)*; 0087 Preprint EPI-865-16-86, Yerevan, Jan. 1986 0088 0089 - K.Savvidy, *The MIXMAX random number generator*, 0090 Computer Physics Communications 196 (2015), pp 161–165 0091 http://dx.doi.org/10.1016/j.cpc.2015.06.003 0092 0093 - K.Savvidy and G.Savvidy, *Spectrum and Entropy of C-systems MIXMAX Random Number Generator*, 0094 Chaos, Solitons & Fractals, Volume 91, (2016) pp. 33–38 0095 http://dx.doi.org/10.1016/j.chaos.2016.05.003 0096 0097 0098 @ingroup Random 0099 */ 0100 0101 template<int N, int SkipNumber> 0102 class MixMaxEngine : public TRandomEngine { 0103 0104 public: 0105 0106 typedef TRandomEngine BaseType; 0107 0108 // this should be changed for WINDOWS 0109 #ifndef __LP64__ 0110 typedef uint64_t StateInt_t; 0111 #else 0112 typedef unsigned long long StateInt_t; 0113 #endif 0114 typedef uint64_t Result_t; 0115 0116 0117 MixMaxEngine(uint64_t seed=1); 0118 0119 ~MixMaxEngine() override; 0120 0121 0122 /// Get the size of the generator 0123 static int Size(); 0124 0125 /// maximum integer that can be generated. For MIXMAX is 2^61-1 0126 static uint64_t MaxInt(); 0127 0128 /// minimum integer that can be generated. For MIXMAX is 0 0129 static uint64_t MinInt(); 0130 0131 /// set the generator seed 0132 void SetSeed(Result_t seed); 0133 0134 // generate a random number (virtual interface) 0135 double Rndm() override { return Rndm_impl(); } 0136 0137 /// generate a double random number (faster interface) 0138 inline double operator() () { return Rndm_impl(); } 0139 0140 /// generate an array of random numbers 0141 void RndmArray (int n, double * array); 0142 0143 /// generate a 64 bit integer number 0144 Result_t IntRndm(); 0145 0146 /// get name of the generator 0147 static const char *Name(); 0148 0149 protected: 0150 // protected functions used for testing the generator 0151 0152 /// get the state of the generator 0153 void GetState(std::vector<StateInt_t> & state) const; 0154 0155 0156 ///set the full initial generator state 0157 void SetState(const std::vector<StateInt_t> & state); 0158 0159 /// Get the counter (between 0 and Size-1) 0160 int Counter() const; 0161 0162 0163 private: 0164 0165 /// implementation function to generate the random number 0166 double Rndm_impl(); 0167 0168 //rng_state_t * fRngState; ///< mix-max generator state 0169 //mixmax::mixmax_engine<N> * fRng; ///< mixmax internal engine class 0170 MixMaxEngineImpl<N> * fRng; ///< mixmax internal engine class 0171 0172 }; 0173 0174 typedef MixMaxEngine<240,0> MixMaxEngine240; 0175 typedef MixMaxEngine<256,2> MixMaxEngine256; 0176 typedef MixMaxEngine<17,0> MixMaxEngine17; 0177 0178 extern template class MixMaxEngine<240,0>; 0179 extern template class MixMaxEngine<256,0>; 0180 extern template class MixMaxEngine<256,2>; 0181 extern template class MixMaxEngine<256,4>; 0182 extern template class MixMaxEngine<17,0>; 0183 extern template class MixMaxEngine<17,1>; 0184 extern template class MixMaxEngine<17,2>; 0185 0186 } // end namespace Math 0187 0188 } // end namespace ROOT 0189 0190 0191 #include "Math/MixMaxEngine.icc" 0192 0193 #endif /* ROOT_Math_MixMaxEngine */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |