So I'm trying to convert this bit of code to use in my Java program. However, it has a pointer and I'm not sure what would be the best way of translating that into Java.
/**
* 32-bit Multiplicative Congruential Pseudo Random Number Generator
* Microsoft Visual C++ Version
*/
#include <math.h>
/**
* The seed used by randomNumberGenerator.
*/
long gv_lRandomNumberSeed;
/**
* Returns a random number between 0.0 and 1.0.
* plSeed - Pointer to the seed value to use.
*/
double randomNumberGenerator( long* plSeed ) {
double dZ;
double dQuot;
long lQuot;
dZ = ( *plSeed ) * 16807;
dQuot = dZ / 2147483647;
lQuot = ( long ) floor( dQuot );
dZ -= lQuot * 2147483647;
( *plSeed ) = ( long ) floor( dZ );
return ( dZ / 2147483647 );
}
I need to be able to use the above number returned in this function:
/**
* Returns a random variate from an exponential probability
* distribution with the given mean value of dMean.
*/
double exponentialRVG( double dMean ) {
return ( -dMean * log( randomNumberGenerator( &gv_lRandomNumberSeed
) ) );
}
And be able to enter a value for dMean and get a value in return..
Any help?
(I know a lot of people get angry about poorly posted questions on this site, please try and refrain from the negatively and help me to ask the question better if that is the case)