Class Distributions

java.lang.Object
io.bloviate.db.Distributions

public final class Distributions extends Object
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 Details

    • weighted

      public static <T> ColumnGeneratorFactory weighted(Map<? extends T, ? extends Number> weights)
      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) double distribution clamped to [min, max].
      Parameters:
      mean - the center of the distribution
      standardDeviation - the spread
      min - the inclusive lower clamp
      max - 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) int distribution, rounded and clamped to [min, max].
      Parameters:
      mean - the center of the distribution
      standardDeviation - the spread
      min - the inclusive lower clamp
      max - the inclusive upper clamp
      Returns:
      a factory for a NormalIntegerGenerator
    • zipfian

      public static ColumnGeneratorFactory zipfian(int size)
      A Zipfian (power-law) distribution over [1, size] with the classic exponent 1.0.
      Parameters:
      size - the number of distinct values
      Returns:
      a factory for a ZipfianIntegerGenerator
    • zipfian

      public static ColumnGeneratorFactory zipfian(int start, int size, double exponent)
      A Zipfian (power-law) distribution over [start, start + size) with the given exponent.
      Parameters:
      start - the first (most frequent) value
      size - the number of distinct values
      exponent - the skew exponent (larger ⇒ more skew)
      Returns:
      a factory for a ZipfianIntegerGenerator
    • recentTimestamps

      public static ColumnGeneratorFactory recentTimestamps()
      Recency-skewed timestamps over the generator's default five-year window.
      Returns:
      a factory for a SkewedTimestampGenerator
    • recentTimestamps

      public static ColumnGeneratorFactory recentTimestamps(Instant start, Instant end, double skew)
      Recency-skewed timestamps over [start, end] with the given skew (1.0 = uniform).
      Parameters:
      start - the inclusive start of the window
      end - the inclusive end of the window
      skew - the recency skew (1.0 = uniform, larger ⇒ more weight toward end)
      Returns:
      a factory for a SkewedTimestampGenerator