/* tprand.c CCMATH mathematics library source code. * * Copyright (C) 2000 Daniel A. Atkinson All rights reserved. * This code may be redistributed under the terms of the GNU library * public license (LGPL). ( See the lgpl.license file for details.) * ------------------------------------------------------------------------ */ /* Test: autcor hist Uses: setunfl setunfl2 setnrml setnorm2 unfl unfl2 nrml norm2 Input parameter: seed -> unsigned int: random generator seed */ #include "ccmath.h" #include void main(int na,char **av) { int n,f,k,i,j,lag,kb,*his; unsigned int seed; double *x,*p,a,b,h,bin,err[2]; if(na!=2){ printf("para: seed(hex)\n"); exit(1);} sscanf(*++av,"%x",&seed); lag=20; n=1000000; x=(double *)calloc(sizeof(*x),n); printf(" Test of Pseudorandom Generator Distributions\n\n"); for(i=0; i<4 ;++i){ switch(i){ case 0: f=0; k=0; break; case 1: f=1; k=0; break; case 2: f=0; k=1; break; case 3: f=1; k=1; break; } if(f) printf(" normal distribution "); else printf(" uniform distribution "); printf("generator type %d\n",k); printf(" seed = %x\n",seed); /* generate sample of requested type */ if(f){ a= -(b=3.); kb=12; if(k) setnorm2(seed); else setnrml(seed); for(j=0,p=x; j