random.h
来自「文化算法的实际应用」· C头文件 代码 · 共 59 行
H
59 行
// Functions for the random handling of n úm eros, genetic.// Without modifying, except for randomize to receive the seed from invocaci ón. #ifndef RANDOM_H#define RANDOM_H#include <CMath>namespace CAEP{ class CARandom { private: int seed; int jRand; double oldRand[55]; double randX2; int randCalcFlag; public: CARandom(float seed = 1); void Init(float seed); void InitNormalDeviate(float calcFlag = 1); /* Create next batch of 55 random numbers */ void AdvanceRandom(); /* Get random off and running */ void WarmUpRandom(float random_seed); /* random normal deviate after ACM algorithm 267 / Box-Muller Method */ double RandomNormalDeviate(); /* Flip a biased coin - true if heads */ int Flip(float prob); /* Fetch a single random number between 0.0 and 1.0 - Subtractive Method */ /* See Knuth, D. (1969), v. 2 for details */ /* name changed from random() to avoid library conflicts on some machines*/ float RandomPerc(); /* Pick a random integer between low and high */ int NextInt(int low, int high); /* real random number between specified limits */ float NextFloat(float lo ,float hi); /* normal noise with specified mean & std dev: mu & sigma */ double Noise(double mu,double sigma); };}#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?