Package net.jqwik.api
Interface RandomDistribution
@API(status=MAINTAINED,
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
Modifier and TypeInterfaceDescriptionstatic class
static interface
Generator for BigInteger values which are behind all generated numeric values in jqwik. -
Method Summary
Modifier and TypeMethodDescriptionstatic RandomDistribution
biased()
A distribution that generates values closer to the center of a numerical range with a higher probability.createGenerator
(int genSize, BigInteger min, BigInteger max, 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 Details
-
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
A distribution that generates values across the allowed range with a uniform probability distribution.- Returns:
- a random distribution instance
-
gaussian
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
A gaussian distribution withborderSigma
of 3, i.e. approximately 99.7% of values are within the borders.- Returns:
- a random distribution instance
- See Also:
-
createGenerator
@API(status=INTERNAL) RandomDistribution.RandomNumericGenerator createGenerator(int genSize, BigInteger min, BigInteger max, 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
-