00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _RANLIB_H_
00018 #define _RANLIB_H_
00019
00020
00021 #include "ranlib.h"
00022 #include "cdflib.h"
00023 #include <time.h>
00024
00025
00027
00035 class RandLibURG
00036 {
00037 public:
00039
00040 RandLibURG(long i1,long i2) {
00041 setall(i1,i2);
00042 }
00043
00045 RandLibURG() {
00046 setall(time(NULL),time(NULL));
00047 long low = irand(0,32000);
00048 long high = irand(0,32000);
00049 setall(low,high);
00050
00051 }
00052
00053
00055 float rand() {
00056 return ranf();
00057 }
00058
00059
00061 float rand(float low,float high) {
00062 return genunf( low, high);
00063 }
00064
00065
00067 long irand(long low,long high){
00068 return ignuin( low, high);
00069 }
00070 };
00071
00072
00074 class RandLib
00075 {
00076 public:
00078
00079 static RandLibURG ur;
00080
00081
00083 static double chiPValue( int idf, double alpha ){
00084 int which = 2;
00085 double p = 1.0 - alpha;
00086 double q = alpha;
00087 double x;
00088 double df = idf;
00089 int status;
00090 double bound;
00091
00092 cdfchi(&which,&p,&q,&x,&df,&status,&bound);
00093
00094 return x;
00095 }
00096
00097 };
00098 #endif