Package net.jqwik.api
Interface RandomDistribution
-
@API(status=EXPERIMENTAL, since="1.3.0") public interface RandomDistribution
Determines how generated numerical values are generated and distributed across the allowed range and a center withing this range.Since all random numeric value generation is going back to BigDecimal generation this interfaces uses only values of type BigDecimal.
The generation of an arbitrary's edge cases is not influenced by the distribution.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
RandomDistribution.RandomDistributionFacade
static interface
RandomDistribution.RandomNumericGenerator
Generator for BigInteger values which are behind all generated numeric values in jqwik.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static RandomDistribution
biased()
A distribution that generates values closer to the center of a numerical range with a higher probability.RandomDistribution.RandomNumericGenerator
createGenerator(int genSize, java.math.BigInteger min, java.math.BigInteger max, java.math.BigInteger center)
Return a generator that will generate value with the desired distributionstatic RandomDistribution
gaussian()
A gaussian distribution withborderSigma
of 3, i.e. approximately 99.7% of values are within the borders.static RandomDistribution
gaussian(double borderSigma)
A distribution that generates values with (potentially asymmetric) gaussian distribution the mean of which is the specified center and the probability at the borders is approximatelyborderSigma
times standard deviation.static RandomDistribution
uniform()
A distribution that generates values across the allowed range with a uniform probability distribution.
-
-
-
Method Detail
-
biased
static RandomDistribution biased()
A distribution that generates values closer to the center of a numerical range with a higher probability. The bigger the range the stronger the bias.- Returns:
- a random distribution instance
-
uniform
static RandomDistribution uniform()
A distribution that generates values across the allowed range with a uniform probability distribution.- Returns:
- a random distribution instance
-
gaussian
static RandomDistribution gaussian(double borderSigma)
A distribution that generates values with (potentially asymmetric) gaussian distribution the mean of which is the specified center and the probability at the borders is approximatelyborderSigma
times standard deviation.Gaussian generation is approximately 10 times slower than biased() or uniform() generation. But still, except in rare cases this will not make a noticeable difference in the runtime of your properties.
- Parameters:
borderSigma
- The approximate factor of standard deviation at the border(s)- Returns:
- a random distribution instance
-
gaussian
static RandomDistribution gaussian()
A gaussian distribution withborderSigma
of 3, i.e. approximately 99.7% of values are within the borders.- Returns:
- a random distribution instance
- See Also:
gaussian(double)
-
createGenerator
RandomDistribution.RandomNumericGenerator createGenerator(int genSize, java.math.BigInteger min, java.math.BigInteger max, java.math.BigInteger center)
Return a generator that will generate value with the desired distribution- Parameters:
genSize
- The approximate number of values to generate. Can be influenced by callers.min
- The minimum allowed value (included)max
- The maximum allowed value (included)center
- The center for the distribution. Must be within min and max.- Returns:
- generator for randomly generated BigInteger values
-
-