Class Distributions
java.lang.Object
io.bloviate.db.Distributions
Ready-made
ColumnGeneratorFactories for non-uniform value
distributions, so a column can opt into a distribution without writing a generator factory:
new TableConfiguration("orders", 100_000, Set.of(
new ColumnConfiguration("status", Distributions.weighted(Map.of("NEW", 0.7, "SHIPPED", 0.25, "CANCELLED", 0.05))),
new ColumnConfiguration("rating", Distributions.normalInt(4, 1, 1, 5)),
new ColumnConfiguration("product_id", Distributions.zipfian(10_000)),
new ColumnConfiguration("created_at", Distributions.recentTimestamps())));
Each factory builds its generator from the engine-supplied, column-seeded random, so the
output is reproducible (same seed ⇒ same data) and composes with foreign-key reseeding and parallel
fills exactly like any other generator. These are specified distributions, not distributions
learned from real data.
- Since:
- 2.11.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ColumnGeneratorFactorynormal(double mean, double standardDeviation, double min, double max) A normal (Gaussian)doubledistribution clamped to[min, max].static ColumnGeneratorFactorynormalInt(double mean, double standardDeviation, int min, int max) A normal (Gaussian)intdistribution, rounded and clamped to[min, max].static ColumnGeneratorFactoryRecency-skewed timestamps over the generator's default five-year window.static ColumnGeneratorFactoryrecentTimestamps(Instant start, Instant end, double skew) Recency-skewed timestamps over[start, end]with the given skew (1.0= uniform).static <T> ColumnGeneratorFactoryA categorical distribution over the given values, each weighted by its (relative) probability.static ColumnGeneratorFactoryzipfian(int size) A Zipfian (power-law) distribution over[1, size]with the classic exponent1.0.static ColumnGeneratorFactoryzipfian(int start, int size, double exponent) A Zipfian (power-law) distribution over[start, start + size)with the given exponent.
-
Method Details
-
weighted
A categorical distribution over the given values, each weighted by its (relative) probability.- Type Parameters:
T- the value type (matched to the column, e.g. String or Integer)- Parameters:
weights- value → weight; weights need not sum to 1- Returns:
- a factory for a
WeightedCategoricalGenerator
-
normal
public static ColumnGeneratorFactory normal(double mean, double standardDeviation, double min, double max) A normal (Gaussian)doubledistribution clamped to[min, max].- Parameters:
mean- the center of the distributionstandardDeviation- the spreadmin- the inclusive lower clampmax- the inclusive upper clamp- Returns:
- a factory for a
NormalDoubleGenerator
-
normalInt
public static ColumnGeneratorFactory normalInt(double mean, double standardDeviation, int min, int max) A normal (Gaussian)intdistribution, rounded and clamped to[min, max].- Parameters:
mean- the center of the distributionstandardDeviation- the spreadmin- the inclusive lower clampmax- the inclusive upper clamp- Returns:
- a factory for a
NormalIntegerGenerator
-
zipfian
A Zipfian (power-law) distribution over[1, size]with the classic exponent1.0.- Parameters:
size- the number of distinct values- Returns:
- a factory for a
ZipfianIntegerGenerator
-
zipfian
A Zipfian (power-law) distribution over[start, start + size)with the given exponent.- Parameters:
start- the first (most frequent) valuesize- the number of distinct valuesexponent- the skew exponent (larger ⇒ more skew)- Returns:
- a factory for a
ZipfianIntegerGenerator
-
recentTimestamps
Recency-skewed timestamps over the generator's default five-year window.- Returns:
- a factory for a
SkewedTimestampGenerator
-
recentTimestamps
Recency-skewed timestamps over[start, end]with the given skew (1.0= uniform).- Parameters:
start- the inclusive start of the windowend- the inclusive end of the windowskew- the recency skew (1.0= uniform, larger ⇒ more weight towardend)- Returns:
- a factory for a
SkewedTimestampGenerator
-