/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:33:18 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv pf=,p_sranr s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include #include #include "p_sranr.h" /* program DRSRANR *>> 2001-05-22 DRSRANR Krogh Minor change for making .f90 version. *>> 1996-05-28 DRSRANR Krogh Added external statement. *>> 1994-10-19 DRSRANR Krogh Changes to use M77CON *>> 1987-12-09 DRSRANR Lawson Initial Code. *--S replaces "?": DR?RANR, ?RANR, ?STAT1, ?STAT2 * * Driver to demonstrate use of SRANR to generate random numbers * from the Rayleigh distribution with parameter, ALPHA. * Program computes histogram for N numbers * */ /* PARAMETER translations */ #define NCELLS (13 + 2) #define ONE 1.0e0 #define TWO 2.0e0 #define ZERO 0.0e0 /* end of PARAMETER translations */ int main( ) { long int i, ihist[NCELLS]; float piov2, stats[5], ytab[1]; static long n = 10000; static float y1 = 0.0e0; static float y2 = 4.33333e0; static float alpha = 1.0e0; /* OFFSET Vectors w/subscript range: 1 to dimension */ long *const Ihist = &ihist[0] - 1; float *const Stats = &stats[0] - 1; float *const Ytab = &ytab[0] - 1; /* end of OFFSET VECTORS */ /* ------------------------------------------------------------------ */ piov2 = TWO*atanf( ONE ); Stats[1] = ZERO; for (i = 1; i <= n; i++) { /* Get random number */ Ytab[1] = sranr( alpha ); /* Accumulate statistics and histogram. * */ sstat1( &Ytab[1], 1, stats, ihist, NCELLS, y1, y2 ); } /* Print the statistics and histogram. * */ printf(" Rayleigh random numbers from SRANR\n"); printf(" with ALPHA = %12.4g\n", alpha); printf(" The Mean and Std. Dev. of the theoretical distribution are\n %13.5g" " and %13.5g\n \n", alpha*sqrtf( piov2 ), alpha*sqrtf( TWO - piov2 )); sstat2( stats, ihist, NCELLS, y1, y2 ); exit(0); } /* end of function */