Description
Draw labeled samples from supplied univariate Gaussian components using the weighted-item and Box–Muller cores, with scaled weights and the normal core's epsilon-clipped zero-draw convention; no model fitting.
A Gaussian mixture combines component distributions with nonnegative weights normalized into selection probabilities. Each generated observation has a sampled component label, while the marginal distribution blends those components. Sampling from known parameters differs from fitting parameters to data.
Draw labeled samples from supplied univariate Gaussian components using the weighted-item and Box–Muller cores, with scaled weights and the normal core's epsilon-clipped zero-draw convention; no model fitting.
When to use this tool
Use this generator to create reproducible gaussian mixture sampler 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 count, components 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 samples, componentIndices, componentProbabilities. Use the conventions below. Keep answer-bearing fields separate when presenting an exercise.
Scale nonnegative mixture weights by their maximum before normalization. For every sample, select a component through the weighted-item core, draw a Box-Muller normal, and return mean plus standardDeviation times that variate with its zero-based component index.1
Delegated operations used for this result: normal box muller sampler; weighted item. Their calculation or parsing conventions apply to the corresponding result fields.2, 3
| Input field | Meaning and units | Accepted input |
|---|---|---|
| count | Count | Required. Safe integer; minimum 1; maximum 4096. |
| components | Mixture components; weights, means, and standard deviations describe a common scalar variable. | Required. Array of Object; no unknown keys.; minimum items 1; maximum items 16. |
| components[].weight | Nonnegative relative selection weight, normalized over all components. | Required. Finite number; minimum 0. |
| components[].mean | Component location in sample units. | Required. Finite number. |
| components[].standardDeviation | Nonnegative component spread in sample units; zero gives its exact mean. | Required. Finite number; minimum 0. |
| 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 |
|---|---|---|
| samples | Samples | Required. Array of Finite number.; minimum items 1; maximum items 4096. |
| componentIndices | Zero-based source component for each aligned sample. | Required. Array of Safe integer; minimum 0; maximum 15.; minimum items 1; maximum items 4096. |
| componentProbabilities | Normalized component weights, including zeros. | Required. Array of Finite number; minimum 0; maximum 1.; minimum items 1; maximum items 16. |
| 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": {
"count": 4,
"components": [
{
"weight": 2,
"mean": 0,
"standardDeviation": 1
},
{
"weight": 1,
"mean": 10,
"standardDeviation": 0.5
}
],
"seed": 42
},
"output": {
"samples": [
0.7603579045861287,
9.079186407608201,
0.6436137875717839,
1.2285906730631042
],
"componentIndices": [
0,
1,
0,
0
],
"componentProbabilities": [
0.6666666666666666,
0.3333333333333333
],
"randomness": {
"seed": 42,
"source": "seed"
}
}
} Limitations and assumptions
- At least one weight must be positive. Zero deviation gives a point mass and finite samples need not match exact component proportions. The normal core clips a zero draw to epsilon; this is sampling, not mixture fitting or cryptographic randomness.
- 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
- Mixture distribution experiment
Generate labeled observations from explicitly weighted normal/exponential components via multinomial counts, separate visible component sampler seeds, and a seeded shuffle; preserve normal sampler 10-significant-digit rounding and inherited endpoint clipping, without fitting or classifying real data.
- Random Correlated Point Dataset Generator
Generate bivariate Box–Muller coordinates under a supplied population correlation, preserving the normal core's epsilon clipping and the normalized Pearson core's 15-significant-digit diagnostic; constant coordinates produce null and sample correlation is not forced to the target.