69 inline double random(
double max = 1) {
72 return max*(static_cast<double>(rand()) / (1.0 + static_cast<double>(RAND_MAX)));
82 inline double random(
double min,
double max) {
83 return ((max - min) *
random() + min);
95 inline unsigned int random(
unsigned int max) {
96 unsigned int val = static_cast<unsigned int>(floor(
random (static_cast<double>(max)+1.0)));
179 inline operator unsigned int()
const{
return random(
max); }
213 if(subsetSize > containerSize){
214 throw ICLException(
"get_random_index_subset: subsetsize must be <= containerSize");
216 std::vector<int> s(containerSize);
217 for(
int i=0;i<containerSize;++i) s[i] = i;
218 std::random_shuffle(s.begin(), s.end());
219 return std::vector<int>(s.begin(), s.begin()+subsetSize);
226 std::vector<T> subset(subsetSize);
227 for(
int i=0;i<subsetSize;++i){
228 subset[i] = s[indices[i]];
235 std::vector<T> &subset)
238 subset.resize(subsetSize);
239 for(
int i=0;i<subsetSize;++i){
240 subset[i] = s[indices[i]];
246 std::vector<T> &subset, std::vector<int> &indices)
249 subset.resize(subsetSize);
250 for(
int i=0;i<subsetSize;++i){
251 subset[i] = s[indices[i]];
class representing a range defined by min and max value
Definition: Range.h:49
icl64f mean
Definition: Random.h:185
URandI(unsigned int max)
Create with given max value.
Definition: Random.h:176
Type maxVal
maximum value of this range
Definition: Range.h:92
undocument this line if you encounter any issues!
Definition: Any.h:37
void randomSeed(long int seedval)
Initilaize the random number generator.
Definition: Random.h:51
lightweight Random generator class for uniform random distributions in positive integer domain
Definition: Random.h:172
double mean(ForwardIterator begin, ForwardIterator end)
computes the mean value of a data range
Definition: MathFunctions.h:78
lightweight Random generator class for uniform random distributions
Definition: Random.h:154
#define ICLUtils_API
this macros are important for creating dll's
Definition: CompatMacros.h:171
GRandClip(icl64f mean, icl64f var, const Range64f &range)
Create with optionally given mean and variance.
Definition: Random.h:201
URand()
Range [0,1].
Definition: Random.h:158
std::vector< T > get_random_subset(const std::vector< T > &s, int subsetSize)
Definition: Random.h:223
#define iclMin(A, B)
Definition: Macros.h:204
std::vector< int > get_random_index_subset(int containerSize, int subsetSize)
Definition: Random.h:210
Ipp64f icl64f
64Bit floating point type for the ICL
Definition: BasicTypes.h:52
Type minVal
minimum value of this range
Definition: Range.h:89
icl64f var
Definition: Random.h:197
Range64f range
Definition: Random.h:155
GRand(icl64f mean=0, icl64f var=1.0)
Create with optionally given mean and variance.
Definition: Random.h:188
lightweight Random generator class for gaussian distributed numbers
Definition: Random.h:184
unsigned int max
Definition: Random.h:173
lightweight Random generator class for gaussian distributed numbers clipped to a given range
Definition: Random.h:196
ICLUtils_API double gaussRandom(double mean, double var)
Generate a gaussian random number with given mean and variance.
URand(icl64f min, icl64f max)
Given range.
Definition: Random.h:161
icl64f var
Definition: Random.h:185
Base class for Exception handling in the ICL.
Definition: Exception.h:42
icl64f mean
Definition: Random.h:197
Object based random seed caller.
Definition: Random.h:64
URand(const Range64f &range)
Given range.
Definition: Random.h:164
RandomSeeder()
Definition: Random.h:65
double random(double max=1)
Generates random numbers in range [0,1].
Definition: Random.h:69
Range64f range
Definition: Random.h:198