Package org.flag4j.rng
Class RandomCNumber
java.lang.Object
java.util.Random
org.flag4j.rng.RandomCNumber
- All Implemented Interfaces:
Serializable
,RandomGenerator
An instance of this class is used to generate a stream of random
complex numbers
. Extends the
Random
class.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator
-
Constructor Summary
ConstructorDescriptionConstructs a complex value random number generator.RandomCNumber
(long seed) Constructs a complex value random number generator. -
Method Summary
Modifier and TypeMethodDescriptionrandn()
Generates a pseudorandom complex number with normally distributed magnitude with a mean of 0.0 and standard deviation of 1.0.randn
(double mean, double std) Generates a pseudorandom complex number with normally distributed magnitude with a specified mean and standard deviation.random()
Generates a pseudorandom complex number which is uniformly distributed on the unit disk within the complex plane.random
(double mag) Generates pseudorandom complex number with specified magnitude which is uniformly distributed around the origin.random
(double min, double max) Generates a pseudorandom complex number with magnitude in[min, max)
which is uniformly distributed in the annulus (i.e.Methods inherited from class java.util.Random
doubles, doubles, doubles, doubles, from, ints, ints, ints, ints, longs, longs, longs, longs, next, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeed
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.random.RandomGenerator
equiDoubles, isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextInt, nextLong, nextLong
-
Constructor Details
-
RandomCNumber
public RandomCNumber()Constructs a complex value random number generator. The seed of this random number generator is very likely to be distinct from any other invocation of this constructor. -
RandomCNumber
public RandomCNumber(long seed) Constructs a complex value random number generator. Use this constructor with a seed value for reproducible results.- Parameters:
seed
- Seed for this random number generator.
-
-
Method Details
-
random
Generates a pseudorandom complex number which is uniformly distributed on the unit disk within the complex plane.- Returns:
- A pseudorandom complex number uniformly distributed on the unit disk within the complex plane.
-
random
Generates pseudorandom complex number with specified magnitude which is uniformly distributed around the origin. That is, a pseudorandom complex number which is uniformly distributed around the circle in the complex plane with radius equal to the specified magnitude.- Parameters:
mag
- Magnitude of the pseudorandom complex number to generate. Must be non-negative.- Returns:
- pseudorandom complex number uniformly distributed around the origin with the specified magnitude.
- Throws:
IllegalArgumentException
- If the magnitude is negative.
-
random
Generates a pseudorandom complex number with magnitude in[min, max)
which is uniformly distributed in the annulus (i.e. washer) with minimum and maximum radii equal tomin
andmax
respectively.- Parameters:
min
- Minimum value for random number. Must be non-negative.max
- Maximum value for random number. Must be larger than or equal to min.- Returns:
- A pseudorandom complex number with magnitude uniformly distributed in
[min, max)
. - Throws:
IllegalArgumentException
- Ifmin
is not positive or ifmax
is less thanmin
.
-
randn
Generates a pseudorandom complex number with normally distributed magnitude with a mean of 0.0 and standard deviation of 1.0.- Returns:
- A pseudorandom complex number with normally distributed magnitude with a mean of 0.0 and standard deviation of 1.0.
-
randn
Generates a pseudorandom complex number with normally distributed magnitude with a specified mean and standard deviation.- Parameters:
mean
- Mean of normal distribution to sample magnitude from.std
- Standard deviation of normal distribution to sample magnitude from.- Returns:
- A pseudorandom complex number with normally distributed magnitude with a specified mean and standard deviation.
- Throws:
IllegalArgumentException
- If standard deviation is negative.
-