File indexing completed on 2025-01-18 10:10:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef ROOT_Math_GSLRandomFunctions
0018 #define ROOT_Math_GSLRandomFunctions
0019
0020
0021
0022
0023 #include "Math/RandomFunctions.h"
0024
0025 #include "Math/GSLRndmEngines.h"
0026
0027 #include <vector>
0028
0029 namespace ROOT {
0030 namespace Math {
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 template <class EngineType >
0043 class RandomFunctions<EngineType, ROOT::Math::GSLRandomEngine> : public RandomFunctions<EngineType, DefaultEngineType> {
0044
0045
0046
0047
0048 public:
0049
0050 RandomFunctions() {}
0051
0052 RandomFunctions(EngineType & rng) : RandomFunctions<EngineType, DefaultEngineType>(rng) {}
0053
0054
0055 inline EngineType & Engine() { return RandomFunctions<EngineType,DefaultEngineType>::Rng(); }
0056
0057 double GausZig(double mean, double sigma) {
0058 return Engine().GaussianZig(sigma) + mean;
0059 }
0060
0061
0062
0063
0064
0065
0066
0067
0068 double Gaus(double mean = 0, double sigma = 1) {
0069 return mean + Engine().GaussianZig(sigma);
0070 }
0071
0072
0073
0074
0075 double GausBM(double mean = 0, double sigma = 1) {
0076 return mean + Engine().Gaussian(sigma);
0077 }
0078
0079
0080
0081
0082 double GausR(double mean = 0, double sigma = 1) {
0083 return mean + Engine().GaussianRatio(sigma);
0084 }
0085
0086
0087
0088
0089 double GaussianTail(double a, double sigma = 1) {
0090 return Engine().GaussianTail(a,sigma);
0091 }
0092
0093
0094
0095
0096 void Gaussian2D(double sigmaX, double sigmaY, double rho, double &x, double &y) {
0097 Engine().Gaussian2D(sigmaX, sigmaY, rho, x, y);
0098 }
0099
0100
0101
0102
0103
0104
0105
0106
0107 void GaussianND(size_t n, const double * meanVec, const double * covMatrix, double * x, double * lmat = nullptr) {
0108 Engine().GaussianND(n, meanVec,covMatrix,x,lmat);
0109 }
0110
0111
0112
0113
0114 double Exp(double tau) {
0115 return Engine().Exponential(tau);
0116 }
0117
0118
0119
0120 double BreitWigner(double mean = 0., double gamma = 1) {
0121 return mean + Engine().Cauchy( gamma/2.0 );
0122 }
0123
0124
0125
0126
0127 double Landau(double mean = 0, double sigma = 1) {
0128 return mean + sigma*Engine().Landau();
0129 }
0130
0131
0132
0133
0134 double Gamma(double a, double b) {
0135 return Engine().Gamma(a,b);
0136 }
0137
0138
0139
0140
0141 double Beta(double a, double b) {
0142 return Engine().Beta(a,b);
0143 }
0144
0145
0146
0147
0148 double LogNormal(double zeta, double sigma) {
0149 return Engine().LogNormal(zeta,sigma);
0150 }
0151
0152
0153
0154
0155 double ChiSquare(double nu) {
0156 return Engine().ChiSquare(nu);
0157 }
0158
0159
0160
0161
0162 double FDist(double nu1, double nu2) {
0163 return Engine().FDist(nu1,nu2);
0164 }
0165
0166
0167
0168
0169 double tDist(double nu) {
0170 return Engine().tDist(nu);
0171 }
0172
0173
0174
0175 double Rayleigh(double sigma) {
0176 return Engine().Rayleigh(sigma);
0177 }
0178
0179
0180
0181
0182 double Logistic(double a) {
0183 return Engine().Logistic(a);
0184 }
0185
0186
0187
0188
0189 double Pareto(double a, double b) {
0190 return Engine().Pareto(a,b);
0191 }
0192
0193
0194
0195
0196 void Circle(double &x, double &y, double r = 1) {
0197 Engine().Dir2D(x,y);
0198 x *= r;
0199 y *= r;
0200 }
0201
0202
0203
0204
0205 void Sphere(double &x, double &y, double &z,double r = 1) {
0206 Engine().Dir3D(x,y,z);
0207 x *= r;
0208 y *= r;
0209 z *= r;
0210 }
0211
0212
0213
0214
0215 unsigned int Poisson(double mu) {
0216 return Engine().Poisson(mu);
0217 }
0218
0219
0220
0221
0222 unsigned int Binomial(unsigned int ntot, double prob) {
0223 return Engine().Binomial(prob,ntot);
0224 }
0225
0226
0227
0228
0229
0230
0231 unsigned int NegativeBinomial(double n, double prob) {
0232 return Engine().NegativeBinomial(prob,n);
0233 }
0234
0235
0236
0237
0238 std::vector<unsigned int> Multinomial( unsigned int ntot, const std::vector<double> & p ) {
0239 return Engine().Multinomial(ntot,p);
0240 }
0241
0242
0243
0244 };
0245
0246
0247
0248
0249 }
0250 }
0251
0252 #endif