public abstract class AbstractRng64 extends Object implements PseudoRandom
Derived classes need to supply an implementation of nextLong().
nextDouble(),
nextGaussian() and nextBytes(byte[]) but somehow wasteful
for the other methods because it dissipates valuable random bits piled up in
the call to nextLong() whenever less than 33 random bits are
needed for the result type.| Modifier and Type | Field and Description |
|---|---|
protected static double |
DOUBLE_NORM |
protected static float |
FLOAT_NORM |
protected double |
nextGaussian
cache for the next gaussian
|
protected static byte |
unused |
| Constructor and Description |
|---|
AbstractRng64() |
| Modifier and Type | Method and Description |
|---|---|
DoubleStream |
beta(double alpha,
double beta)
Returns an effectively unlimited stream of pseudorandomly chosen
Beta-distributed variates with shape parameters
alpha and
beta. |
DoubleStream |
beta(long streamSize,
double alpha,
double beta)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen Beta-distributed variates with shape parameters
alpha and beta. |
DoubleStream |
cauchy(double location,
double scale)
Returns an effectively unlimited stream of pseudorandomly chosen
Cauchy-distributed variates with location parameter
location and
scale parameter scale. |
DoubleStream |
cauchy(long streamSize,
double location,
double scale)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen Cauchy-distributed variates with location parameter
location and scale parameter scale. |
DoubleStream |
chiSquare(double degreesOfFreedom)
Returns an effectively unlimited stream of pseudorandomly chosen
Chi-squared distributed variates with
k degrees of freedom. |
DoubleStream |
chiSquare(long streamSize,
double degreesOfFreedom)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen Chi-squared distributed variates with k
degrees of freedom. |
DoubleStream |
doubles()
Returns an effectively unlimited stream of pseudorandomly chosen
double values. |
DoubleStream |
doubles(double min,
double max)
Returns an effectively unlimited stream of pseudorandomly chosen
double values, where each value is between the specified min
(inclusive) and the specified max (inclusive). |
DoubleStream |
doubles(long streamSize)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen double values. |
DoubleStream |
doubles(long streamSize,
double min,
double max)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen double values, where each value is between
the specified min (inclusive) and the specified max (inclusive). |
DoubleStream |
exponential(double lambda)
Returns an effectively unlimited stream of pseudorandomly chosen
exponentially distributed variates with rate parameter
lambda. |
DoubleStream |
exponential(long streamSize,
double lambda)
Returns a stream producing the given
streamSize number of
exponentially distributed variates with rate parameter lambda. |
DoubleStream |
gamma(double k,
double theta)
Returns an effectively unlimited stream of pseudorandomly chosen
Gamma-distributed variates with shape parameter
k and scale
parameter theta. |
DoubleStream |
gamma(long streamSize,
double k,
double theta)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen Gamma-distributed variates with shape parameter
k and scale parameter theta. |
String |
getAlgorithm() |
long[] |
getSeed() |
IntStream |
ints()
Returns an effectively unlimited stream of pseudorandomly chosen
int values. |
IntStream |
ints(int min,
int max)
Returns an effectively unlimited stream of pseudorandomly chosen
int values, where each value is between the specified min
(inclusive) and the specified max (inclusive). |
IntStream |
ints(long streamSize)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen int values. |
IntStream |
ints(long streamSize,
int min,
int max)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen int values, where each value is between the
specified min (inclusive) and the specified max (inclusive). |
DoubleStream |
logNormal(double mu,
double sigma)
Returns an effectively unlimited stream of pseudorandomly chosen
Log-normal variates whose natural logarithm has expectation
mu
and standard deviation sigma. |
DoubleStream |
logNormal(long streamSize,
double mu,
double sigma)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen Log-normal variates whose natural logarithm has
expectation mu and standard deviation sigma. |
LongStream |
longs()
Returns an effectively unlimited stream of pseudorandomly chosen
long values. |
LongStream |
longs(long streamSize)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen long values. |
LongStream |
longs(long min,
long max)
Returns an effectively unlimited stream of pseudorandomly chosen
long values, where each value is between the specified min
(inclusive) and the specified max (inclusive). |
LongStream |
longs(long streamSize,
long min,
long max)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen long values, where each value is between
the specified min (inclusive) and the specified max (inclusive). |
int |
next(int bits) |
boolean |
nextBoolean() |
void |
nextBytes(byte[] bytes) |
double |
nextDouble() |
double |
nextDouble(double min,
double max) |
void |
nextDoubles(double[] doubles) |
float |
nextFloat() |
float |
nextFloat(float min,
float max) |
double |
nextGaussian() |
double |
nextGaussian(double mean,
double stdDeviation) |
int |
nextInt() |
int |
nextInt(int n) |
int |
nextInt(int min,
int max) |
abstract long |
nextLong() |
long |
nextLong(long n) |
long |
nextLong(long min,
long max) |
void |
nextLongs(long[] longs) |
DoubleStream |
normal(double mu,
double sigma)
Returns an effectively unlimited stream of pseudorandomly chosen normal
variates with expectation
mu and standard deviation
sigma. |
DoubleStream |
normal(long streamSize,
double mu,
double sigma)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen normal variates with expectation mu and
standard deviation sigma. |
protected void |
saveSeed(long seed) |
protected void |
saveSeed(long[] seed) |
DoubleStream |
studentT(double df)
Returns an effectively unlimited stream of pseudorandomly chosen StudentT
distributed variates with
df degrees of freedom. |
DoubleStream |
studentT(long streamSize,
double df)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen StudentT distributed variates with df
degrees of freedom. |
DoubleStream |
weibull(double scale,
double shape)
Returns an effectively unlimited stream of pseudorandomly chosen Weibull
distributed variates with parameters
scale and shape. |
DoubleStream |
weibull(long streamSize,
double scale,
double shape)
Returns a stream producing the given
streamSize number of
pseudorandomly chosen Weibull distributed variates with parameters
scale and shape. |
protected static final double DOUBLE_NORM
protected static final float FLOAT_NORM
protected static byte unused
protected double nextGaussian
public abstract long nextLong()
nextLong in interface PseudoRandompublic double nextDouble()
nextDouble in interface PseudoRandompublic double nextDouble(double min,
double max)
nextDouble in interface PseudoRandompublic final double nextGaussian()
nextGaussian in interface PseudoRandompublic double nextGaussian(double mean,
double stdDeviation)
nextGaussian in interface PseudoRandompublic float nextFloat()
nextFloat in interface PseudoRandompublic float nextFloat(float min,
float max)
nextFloat in interface PseudoRandompublic int nextInt()
nextInt in interface PseudoRandompublic void nextBytes(byte[] bytes)
nextBytes in interface PseudoRandompublic void nextLongs(long[] longs)
nextLongs in interface PseudoRandompublic void nextDoubles(double[] doubles)
nextDoubles in interface PseudoRandompublic boolean nextBoolean()
nextBoolean in interface PseudoRandompublic long nextLong(long n)
nextLong in interface PseudoRandompublic int nextInt(int n)
nextInt in interface PseudoRandompublic int nextInt(int min,
int max)
nextInt in interface PseudoRandompublic long nextLong(long min,
long max)
nextLong in interface PseudoRandompublic int next(int bits)
next in interface PseudoRandompublic String getAlgorithm()
getAlgorithm in interface PseudoRandompublic long[] getSeed()
getSeed in interface PseudoRandompublic IntStream ints()
PseudoRandomStreamint values.ints in interface PseudoRandomStreamint valuespublic IntStream ints(long streamSize)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen int values.ints in interface PseudoRandomStreamstreamSize - the number of values to generateint valuespublic IntStream ints(int min, int max)
PseudoRandomStreamint values, where each value is between the specified min
(inclusive) and the specified max (inclusive).ints in interface PseudoRandomStreammin - the smallest value that can be producedmax - the largest value that can be producedint values, each
between the specified min (inclusive) and the specified max
(inclusive)public IntStream ints(long streamSize, int min, int max)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen int values, where each value is between the
specified min (inclusive) and the specified max (inclusive).ints in interface PseudoRandomStreamstreamSize - the number of values to generatemin - the smallest value that can be producedmax - the largest value that can be producedint values, each
between the specified min (inclusive) and the specified max
(inclusive)public LongStream longs()
PseudoRandomStreamlong values.longs in interface PseudoRandomStreamlong valuespublic LongStream longs(long streamSize)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen long values.longs in interface PseudoRandomStreamstreamSize - the number of values to generatelong valuespublic LongStream longs(long min, long max)
PseudoRandomStreamlong values, where each value is between the specified min
(inclusive) and the specified max (inclusive).longs in interface PseudoRandomStreammin - the smallest value that can be producedmax - the largest value that can be producedlong values, each
between the specified min (inclusive) and the specified max
(inclusive)public LongStream longs(long streamSize, long min, long max)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen long values, where each value is between
the specified min (inclusive) and the specified max (inclusive).longs in interface PseudoRandomStreamstreamSize - the number of values to generatemin - the smallest value that can be producedmax - the largest value that can be producedlong values, each
between the specified min (inclusive) and the specified max
(inclusive)public DoubleStream doubles()
PseudoRandomStreamdouble values.doubles in interface PseudoRandomStreamdouble valuespublic DoubleStream doubles(long streamSize)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen double values.doubles in interface PseudoRandomStreamstreamSize - the number of values to generatedouble valuespublic DoubleStream doubles(double min, double max)
PseudoRandomStreamdouble values, where each value is between the specified min
(inclusive) and the specified max (inclusive).doubles in interface PseudoRandomStreammin - the smallest value that can be producedmax - the largest value that can be produceddouble values, each
between the specified min and the specified maxpublic DoubleStream doubles(long streamSize, double min, double max)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen double values, where each value is between
the specified min (inclusive) and the specified max (inclusive).doubles in interface PseudoRandomStreamstreamSize - the number of values to generatemin - the smallest value that can be producedmax - the largest value that can be produceddouble values, each
between the specified min and the specified maxpublic DoubleStream normal(double mu, double sigma)
PseudoRandomStreammu and standard deviation
sigma.normal in interface PseudoRandomStreammu - the expectation of the normal variatesigma - the standard deviation of the normal variatepublic DoubleStream normal(long streamSize, double mu, double sigma)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen normal variates with expectation mu and
standard deviation sigma.normal in interface PseudoRandomStreamstreamSize - the number of values to generatemu - the expectation of the normal variatesigma - the standard deviation of the normal variatepublic DoubleStream cauchy(double location, double scale)
PseudoRandomStreamlocation and
scale parameter scale.cauchy in interface PseudoRandomStreamlocation - the location parameter of the Cauchy distributionscale - the scale parameter of the Cauchy distributionpublic DoubleStream cauchy(long streamSize, double location, double scale)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen Cauchy-distributed variates with location parameter
location and scale parameter scale.cauchy in interface PseudoRandomStreamstreamSize - the number of values to generatelocation - the location parameter of the Cauchy distributionscale - the scale parameter of the Cauchy distributionpublic DoubleStream exponential(double lambda)
PseudoRandomStreamlambda.exponential in interface PseudoRandomStreamlambda - the rate parameter lambda of the Exponential
distributionlambdapublic DoubleStream exponential(long streamSize, double lambda)
PseudoRandomStreamstreamSize number of
exponentially distributed variates with rate parameter lambda.exponential in interface PseudoRandomStreamstreamSize - the number of values to generatelambda - the rate parameter lambda of the Exponential
distributionlambdapublic DoubleStream gamma(double k, double theta)
PseudoRandomStreamk and scale
parameter theta.gamma in interface PseudoRandomStreamk - the shape parameter of the Gamma distributiontheta - the scale parameter of the Gamma distributionk and scale parameter thetapublic DoubleStream gamma(long streamSize, double k, double theta)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen Gamma-distributed variates with shape parameter
k and scale parameter theta.gamma in interface PseudoRandomStreamstreamSize - the number of values to generatek - the shape parameter of the Gamma distributiontheta - the scale parameter of the Gamma distributionk and scale parameter thetapublic DoubleStream beta(double alpha, double beta)
PseudoRandomStreamalpha and
beta.beta in interface PseudoRandomStreamalpha - the shape parameter alpha of the Beta distributionbeta - the shape parameter beta of the Beta distributionalpha and betapublic DoubleStream beta(long streamSize, double alpha, double beta)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen Beta-distributed variates with shape parameters
alpha and beta.beta in interface PseudoRandomStreamstreamSize - the number of values to generatealpha - the shape parameter alpha of the Beta distributionbeta - the shape parameter beta of the Beta distributionalpha and betapublic DoubleStream chiSquare(double degreesOfFreedom)
PseudoRandomStreamk degrees of freedom.chiSquare in interface PseudoRandomStreamdegreesOfFreedom - the number of degrees of freedomk degrees of freedompublic DoubleStream chiSquare(long streamSize, double degreesOfFreedom)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen Chi-squared distributed variates with k
degrees of freedom.chiSquare in interface PseudoRandomStreamstreamSize - the number of values to generatedegreesOfFreedom - the number of degrees of freedomk degrees of freedompublic DoubleStream logNormal(double mu, double sigma)
PseudoRandomStreammu
and standard deviation sigma.logNormal in interface PseudoRandomStreammu - the expectation of the natural logarithm of the Log-normal
variatesigma - the standard deviation of the natural logarithm of the
Log-normal variatepublic DoubleStream logNormal(long streamSize, double mu, double sigma)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen Log-normal variates whose natural logarithm has
expectation mu and standard deviation sigma.logNormal in interface PseudoRandomStreamstreamSize - the number of values to generatemu - the expectation of the natural logarithm of the Log-normal
variatesigma - the standard deviation of the natural logarithm of the
Log-normal variatepublic DoubleStream studentT(double df)
PseudoRandomStreamdf degrees of freedom.studentT in interface PseudoRandomStreamdf - degrees of freedomdf degrees of freedompublic DoubleStream studentT(long streamSize, double df)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen StudentT distributed variates with df
degrees of freedom.studentT in interface PseudoRandomStreamstreamSize - the number of values to generatedf - degrees of freedomdf degrees of freedompublic DoubleStream weibull(double scale, double shape)
PseudoRandomStreamscale and shape.weibull in interface PseudoRandomStreamscale - the scale parameter of the Weibull distributionshape - the shape parameter of the Weibull distributionscale and shapepublic DoubleStream weibull(long streamSize, double scale, double shape)
PseudoRandomStreamstreamSize number of
pseudorandomly chosen Weibull distributed variates with parameters
scale and shape.weibull in interface PseudoRandomStreamstreamSize - the number of values to generatescale - the scale parameter of the Weibull distributionshape - the shape parameter of the Weibull distributionscale and shapeprotected void saveSeed(long[] seed)
protected void saveSeed(long seed)
Copyright © 2022. All rights reserved.