00001
00020
00021
00022
00023
00024 # include <stdio.h>
00025 # include <stdlib.h>
00026 # include <math.h>
00027
00028 # include "global.h"
00029 # include "rand.h"
00030
00031
00032 void randomize()
00033 {
00034
00035 return;
00036 }
00037
00038
00039 long double randomperc()
00040 {
00041
00042 return m_random->rand();
00043 }
00044
00045
00046 int rnd (int low, int high)
00047 {
00048 int res;
00049 if (low >= high)
00050 {
00051 res = low;
00052 }
00053 else
00054 {
00055 res = (int) (low + (randomperc()*(high-low+1)));
00056 if (res > high)
00057 {
00058 res = high;
00059 }
00060 }
00061 return (res);
00062 }
00063
00064
00065 long double rndreal (long double low, long double high)
00066 {
00067 return (low + (high-low)*randomperc());
00068 }
00069
00070
00071 void initrandomnormaldeviate()
00072 {
00073 rndcalcflag = 1;
00074 return;
00075 }
00076
00077
00078 long double noise (long double mu, long double sigma)
00079 {
00080 return((randomnormaldeviate()*sigma) + mu);
00081 }
00082
00083
00084 long double randomnormaldeviate()
00085 {
00086 long double t;
00087 if(rndcalcflag)
00088 {
00089 rndx1 = sqrt(- 2.0*log(randomperc()));
00090 t = 6.2831853072*randomperc();
00091 rndx2 = sin(t);
00092 rndcalcflag = 0;
00093 return(rndx1*cos(t));
00094 }
00095 else
00096 {
00097 rndcalcflag = 1;
00098 return(rndx1*rndx2);
00099 }
00100 }