26 #ifndef __BIAS_Random_hh__
27 #define __BIAS_Random_hh__
29 #include <Base/Common/BIASpragmaStart.hh>
34 #include <Base/Debug/Error.hh>
35 #include <Base/Debug/Debug.hh>
37 #include "Matrix2x2.hh"
58 Random(
const long int seed);
67 void Reset(
const long int seed);
72 {
return (mean + (gasdevf_(&LongIdum_) * sigma)); };
75 double GetNormalDistributedGSL(
const double mean,
const double sigma);
79 void GetNormalDistributed(
const double mean,
const double sigma,
80 const int num, std::vector<double>& res);
85 {
return (min + (ran2_(&LongIdum_) * (max-min))); };
89 void GetUniformDistributed(
const double min,
const double max,
90 const int num, std::vector<double>& res);
94 int GetUniformDistributedInt(
const int min,
const int max);
98 unsigned GetUniformDistributedInt(
const unsigned min,
const unsigned max);
122 int GetQuasiUniformDistributed(
const int dim,
131 int GetQuasiUniformDistributed(
const int dim,
143 int GetQuasiNormalDistributed(
const int dim,
Vector<double>& res);
152 int GetQuasiNormalDistributed(
const int dim,
const unsigned num,
158 const int num,
double* res)
160 BIASERR(
"you are using a deprecated interface");
161 std::vector<double> mres;
162 GetNormalDistributed(mean, sigma, num, mres);
163 BIASASSERT((
int)mres.size()==num);
164 for (
int i=0; i<num; i++) res[i] = mres[i];
167 const int num,
double* res)
169 BIASERR(
"you are using a deprecated interface");
170 std::vector<double> mres;
171 GetUniformDistributed(min, max, num, mres);
172 BIASASSERT((
int)mres.size()==num);
173 for (
int i=0; i<num; i++) res[i] = mres[i];
177 void GetMeanAndCovariance(
const std::vector<double>& samples,
178 double &mean,
double &covariance)
const;
191 double ran1_(
int *idum);
192 double ran1c_(
int *idum);
193 double ran2_(
long *idum);
196 double gasdev_(
int *idum);
198 double gasdev3_(
int *idum);
200 double gasdevf_(
long *idum);
211 void sobseq_(
int *n,
double x[]);
228 int Uniform2Normal_(
const double src,
double& dst)
const;
247 int Uniform2Normal_(
const double src1,
const double src2,
248 double& dst1,
double& dst2)
const;
254 #include <Base/Common/BIASpragmaEnd.hh>
256 #endif // __Random_hh__
double GetUniformDistributed(const double min, const double max)
on succesive calls return uniform distributed random variable between min and max ...
void GetUniformDistributed(const double min, const double max, const int num, double *res)
double GetNormalDistributed(const double mean, const double sigma)
on succesive calls return normal distributed random variable with mean and standard deviation sigma ...
class for producing random numbers from different distributions
void GetNormalDistributed(const double mean, const double sigma, const int num, double *res)
old deprectade interfaces