Random Categorical Dataset Generator
Generate seeded categorical counts from supplied weights, then reproducibly shuffle the labeled observations and report actual counts.
Description
Categorical data consists of observations drawn from discrete labels.
Categorical data consists of observations drawn from discrete labels. Relative weights define probabilities, while a count vector describes how often each category occurs.
The tool returns observations (observations); counts (actual counts). These are generated fixtures or selected identifiers; the result does not replace the caller’s choice of repertoire, dataset or intended use.
When to use Random Categorical Dataset Generator
Use Random Categorical Dataset Generator when you already have labels, weights, observationCount, seed and want observations, counts. Use the stated ranges and distribution for a synthetic fixture, then keep the generating parameters with the result.
How to use Random Categorical Dataset Generator and understand its results
- Enter labels, weights, observationCount, seed using the field table below. Match the units, ordering and data boundaries described in the calculation.
- Run the tool after checking the stated bounds and matching paired observations or categories. A malformed request gives a tool error rather than a usable measurement.
- Read observations, counts. Use the calculation and interpretation below to distinguish amounts, ratios, signs and decision flags where applicable.
- Run again for another fixture. Preserve caller-supplied dataset metadata or separate exercise answers from prompts where present.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| labels | Labels | list of string | Required |
| weights | Weights | list of number | Required |
| observationCount | Observation count | integer; minimum 1; maximum 100000 | Required |
| seed | Seed | string | Required |
Pass distinct nonblank labels, nonnegative matching weights with positive total, count 1–100000 and a nonempty seed to the multinomial sampler. Expand sampled counts into labels, then Fisher–Yates shuffle with context randomness and compute actual frequencies.
category probability[i] = weight[i]/Σweights; total counts = observationCount The symbols refer to the supplied quantities or generated values described above; unit conversions and comparison boundaries follow the stated implementation.
{
"input": {
"labels": [
"A",
"B",
"C"
],
"weights": [
1,
2,
1
],
"observationCount": 20,
"seed": "tool.io"
},
"randomDraw": 0.25,
"output": {
"counts": {
"B": 10,
"A": 5,
"C": 5
},
"observations": [
"B",
"B",
"A",
"C",
"C",
"B",
"A",
"B",
"B",
"B",
"A",
"B",
"B",
"B",
"A",
"C",
"C",
"C",
"A",
"B"
]
}
} Limitations and assumptions
The seed controls category counts, but does not seed the shuffle. Full output order is reproducible only when the shuffle random source is also controlled. Absent labels may be omitted from the frequency object.
The shuffle uses context.random, falling back to Math.random; its random draws are not derived from the seed input.
Alternative or Complementary methods
Multinomial Distribution Sampler: Draw category-count vectors for a fixed number of independent trials from caller-supplied nonnegative weights, normalized to probabilities. List Frequency Counter: Count occurrences of strings in a list.
Methodological background: Multinomial distribution.1
References
-
Multinomial distribution — SciPy developers
Similar or alternative tools
- Multinomial Distribution Sampler
Draw category-count vectors for a fixed number of independent trials from caller-supplied nonnegative weights, normalized to probabilities.
- List Frequency Counter
Count occurrences of strings in a list.