# Distributions & Sequences

Distributions and Sequences govern numerical properties, array counts, and unique identity keys throughout synthetic data synthesis.

## Probability distributions

A distribution specifies either discrete probabilities over categorical outcomes or parametric continuous distributions:

### Discrete probability tables

```text
P(triageCategory)
Immediate       0.05
VeryUrgent      0.15
Urgent          0.40
Standard        0.30
NonUrgent       0.10
```

Probabilities are automatically normalized to sum to `1.0`.

### Count distributions for array lengths

Count distributions define the frequency distribution for `0..N` list fields:

```text
P(conditionCount) ~ Count
0       40
1       30
2       20
3       8
4       2
```

In this example, 40% of generated records will have an empty list `[]`, 30% will contain 1 item, and 2% will contain 4 items.

> [!NOTE]
> If a count distribution does not include `0` in its definition, the generated field will never output an empty list.

## Sequential ID generators

Identity sequences produce monotonically increasing, uniquely formatted strings or numbers. Sequences ensure zero collisions across high-volume draws:

```text
Seq(orderId)
ORD-{n:08}
```

The template placeholder `{n:WIDTH}` indicates zero-padding:

- `{n:06}` produces `000001`, `000002`, `000003`...
- `{n}` without width formatting produces `1`, `2`, `3`...
- Literals surrounding `{n}` are preserved verbatim (e.g. `PAT-{n:05}-US` -> `PAT-00001-US`).

## Built-in mathematical generators

SimHealth includes built-in functions for continuous parameters:

| Function | Signature | Description |
| --- | --- | --- |
| `uniformInt(min, max)` | Integer bounds | Uniform integer draw between `min` and `max` inclusive. |
| `normal(mean, stddev)` | Floating-point | Gaussian normal distribution with specified mean and standard deviation. |
| `dateBetween(start, end)` | ISO 8601 strings | Random date within the calendar range. |
| `timestamp()` | Current epoch | High-resolution UTC ISO timestamp. |
| `boolean(trueProb)` | Float `0.0`–`1.0` | Bernoulli trial with specified true probability. |

> [!IMPORTANT]
> Built-in generators are completely deterministic under a master seed. Running `normal(120, 15)` twice with the same seed will return the exact same value.
