Skip to content

feat: synth distribution hints for numeric fields (normal, lognormal, exponential) - #460

Merged
nightmoose merged 1 commit into
stagingfrom
feat/synth-distributions
Nov 26, 2026
Merged

nightmoose merged 1 commit into
stagingfrom
feat/synth-distributions

Conversation

@nightmoose

Copy link
Copy Markdown
Owner

Why

A user in the Bitol community asked whether synthetic data could follow a chosen distribution (mean and sd, or a skewed shape). Today synth draws evenly between min and max.

What

Optional per-field distribution hint for integer and number fields:

- name: order_total
  type: number
  min: 0
  distribution: { type: lognormal, mean: 3.5, sd: 0.6 }
  • uniform (default; rows are identical to having no hint), normal (mean, sd), lognormal (mean, sd of the underlying normal, documented), exponential (rate, starts at min or 0).
  • min / max still hold: draws outside are redrawn (truncation). Bounds that leave almost no mass fail with rule: distribution and the field named.
  • Deterministic per seed. Every row still goes through the validator oracle.
  • Synth-only: validation ignores the hint, existing contracts parse and serialize unchanged (no distribution key unless set).
  • Bad hints (sd: 0, unknown type, missing or extra parameter) are rejected at parse time with a clear message; a hint on a non-numeric field fails synth naming the field.
  • ODCS: x-cg-distribution in a property's customProperties (import and export).
  • Python SDK reads and checks the hint. Docs: synthetic data reference and ODCS docs.

No DB migration.

Not done

Dates and timestamps have no distribution hint (not cheap: they are generated as strings). skew is covered by lognormal and exponential.

Tests

tests/synth_distribution.rs (15): sample mean and sd within tolerance over 5,000 rows for normal, integer normal, lognormal (on the logs) and exponential; bounds; determinism; uniform unchanged; validator ignores the hint; error messages; ODCS round trip. Python SDK tests added.

… exponential)

Optional per-field distribution on integer and number fields. Uniform stays the default
and the rows are unchanged without a hint. Draws outside min/max are redrawn. Validation
ignores the hint. ODCS: x-cg-distribution customProperty (import and export).
Python SDK reads and checks the hint. Docs and tests.
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
contractgate Ready Ready Preview Nov 26, 2026 3:55pm UTC

Request Review

@nightmoose
nightmoose merged commit 3f536f9 into staging Nov 26, 2026
26 checks passed

This branch was successfully deployed

1 active deployment
Preview — 3642224a Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant