📄 awgn.h
字号:
/*************************************** * * Random value generator for AWGN * * based on I[j+1] = a*I[j] mod m * Since it is not possible to implement this iteration * directly (the product a*I may exceed the maximum value * of a 32-bit integer) Schrage's algorithm is used * (see Numerical Recipes in C, p.278ff.) * * (for simulation results and goodness of this * random generator, see ~/svensson/dani/matlab/results/noise.m) * ***************************************/#ifndef AWGNH#define AWGNH#define IA 16807#define IM 2147483647 // 2^31 - 1#define AM (1.0/IM);#define IQ 127773#define IR 2836#define NTAB 32#define NDIV (1+(IM-1)/NTAB)#define EPSI 1.2e-7#define RNMX (1.0-EPSI)#define NOV 1000000 // number of values that are generated at randomclass AWGN {public: // constructor AWGN(long seed = 1, double sigma = 1); // set the standard deviation of this random variable void setSigma(double sigma); // get a random value double nextValue(void); // get the seed long getSeed(void); // test method static void test(void);private: long seed; double sigma; long iy; long iv[NTAB]; int iset; double gset; double random(long *idum);}; #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -