Description
Draw supplied cluster IDs under explicit cluster weights and return every original row per selected cluster occurrence with conditional draw probabilities.
Sampling selects from a supplied population under rules for replacement, grouping, or eligibility. Draw probabilities, inclusion probabilities, and repeat counts describe different aspects of selection; a reproducible sample is not automatically representative of a real population.
Draw supplied cluster IDs under explicit cluster weights and return every original row per selected cluster occurrence with conditional draw probabilities.
When to use this tool
Use this generator to create reproducible cluster based row sample cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.
How to use the tool and how it works
- Supply rows, count, replacement, weighting in the field shapes below. Set seed when you need an explicit replay.
- Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
- Read clusters, draws, returnedRowCount. Use the conventions below. Keep answer-bearing fields separate when presenting an exercise.
Group supplied rows by literal cluster label and sample whole clusters uniformly or proportional to their row counts. Return all rows for every draw, the current conditional selection probability, and total returned row count, removing clusters when replacement is disabled.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| rows | Rows | Required. Array of Object; no unknown keys.; minimum items 0; maximum items 512. |
| rows[].id | Literal identifier used independently of display labels. | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 128. |
| rows[].values | Values | Required. Array of Text; maximum UTF-16 length 4096.; minimum items 0; maximum items 32. |
| rows[].cluster | Cluster | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 128. |
| count | Count | Required. Safe integer; minimum 0; maximum 128. |
| replacement | Replacement | Required. Boolean. |
| weighting | Draw cluster IDs uniformly or proportional to their supplied row counts; include every row per cluster occurrence. | Required. Text; one of "uniform-cluster", "proportional-size". |
| seed | Optional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed. | Optional. Safe integer. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| clusters | Clusters | Required. Array of Object; no unknown keys.; minimum items 0; maximum items 512. |
| clusters[].cluster | Cluster | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 128. |
| clusters[].populationRows | Population Rows | Required. Safe integer; minimum 0. |
| clusters[].weight | Weight | Required. Safe integer; minimum 0. |
| draws | Draws | Required. Array of Object; no unknown keys.; minimum items 0; maximum items 128. |
| draws[].draw | Draw | Required. Safe integer; minimum 0. |
| draws[].cluster | Cluster | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 128. |
| draws[].conditionalProbability | Conditional Probability | Required. Finite number; minimum 0; maximum 1. |
| draws[].rows | Rows | Required. Array of Object; no unknown keys.; minimum items 0; maximum items 512. |
| draws[].rows[].id | Literal identifier used independently of display labels. | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 128. |
| draws[].rows[].values | Values | Required. Array of Text; maximum UTF-16 length 4096.; minimum items 0; maximum items 32. |
| draws[].rows[].cluster | Cluster | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 128. |
| returnedRowCount | Returned Row Count | Required. Safe integer; minimum 0; maximum 8192. |
| randomness | Replay source and normalized 32-bit seed, or null seed for an advancing context source. | Required. Object; no unknown keys. |
| randomness.seed | Optional safe-integer replay seed; normalization and precedence are explained below. | Required. Safe integer. or Null. |
| randomness.source | Source | Required. Text; one of "context", "seed". |
An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.
{
"input": {
"rows": [
{
"id": "a",
"cluster": "west",
"values": [
"12"
]
},
{
"id": "b",
"cluster": "west",
"values": [
"19"
]
},
{
"id": "c",
"cluster": "east",
"values": [
"7"
]
}
],
"count": 2,
"replacement": false,
"weighting": "uniform-cluster",
"seed": 42
},
"output": {
"clusters": [
{
"cluster": "west",
"populationRows": 2,
"weight": 1
},
{
"cluster": "east",
"populationRows": 1,
"weight": 1
}
],
"draws": [
{
"draw": 0,
"cluster": "east",
"conditionalProbability": 0.5,
"rows": [
{
"id": "c",
"values": [
"7"
],
"cluster": "east"
}
]
},
{
"draw": 1,
"cluster": "west",
"conditionalProbability": 1,
"rows": [
{
"id": "a",
"values": [
"12"
],
"cluster": "west"
},
{
"id": "b",
"values": [
"19"
],
"cluster": "west"
}
]
}
],
"returnedRowCount": 3,
"randomness": {
"seed": 42,
"source": "seed"
}
}
} Limitations and assumptions
- Cluster sampling differs from independent row sampling. Replacement can return the same entire cluster several times, and size-weighted draw probability is not a marginal row-inclusion probability. Output expansion is bounded.
- A replay requires the same complete input and implementation. The stated sampling convention applies within its eligible space. A finite draw does not exhaust all possible outputs; repeats remain possible unless a distinct-selection rule is explicit.
- The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.
Alternative or Complementary methods
For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.
References
Similar or alternative tools
- Random Balanced Factorial Assignment Generator
Construct every supplied factor combination and randomly assign distinct units under exact equal replication quotas for caller-reviewed experiments.
- Random Derangement Assignment Generator
Construct a no-fixed-point assignment by exact completion-count unranking, uniformly over all derangements under independent uniform random words.