Skip to content

Main content

Random Balanced Factorial Assignment Generator

Construct every supplied factor combination and randomly assign distinct units under exact equal replication quotas for caller-reviewed experiments.

Loading tool…

Description

Construct every supplied factor combination and randomly assign distinct units under exact equal replication quotas for caller-reviewed experiments.

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.

Construct every supplied factor combination and randomly assign distinct units under exact equal replication quotas for caller-reviewed experiments.

When to use this tool

Use this generator to create reproducible balanced factorial assignment 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

  1. Supply factors, unitIds, replication in the field shapes below. Set seed when you need an explicit replay.
  2. 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.
  3. Read factorNames, combinations, assignments. Use the conventions below. Keep answer-bearing fields separate when presenting an exercise.

Enumerate the Cartesian product of distinct factor levels, repeat every combination exactly replication times, shuffle those slots, and assign them to the supplied unit order. Return factor order, combination indexes, levels, and exact counts.1

Delegated operations used for this result: cartesian product. Their calculation or parsing conventions apply to the corresponding result fields.2

Input fieldMeaning and unitsAccepted input
factorsFactorsRequired. Array of Object; no unknown keys.; minimum items 1; maximum items 8.
factors[].nameNameRequired. Text; minimum UTF-16 length 1; maximum UTF-16 length 128.
factors[].levelsLevelsRequired. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 1; maximum items 16.
unitIdsUnit IdsRequired. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 1; maximum items 512.
replicationReplicationRequired. Safe integer; minimum 1; maximum 512.
seedOptional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed.Optional. Safe integer.
Output fieldInterpretationReturned shape
factorNamesFactor NamesRequired. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 1; maximum items 8.
combinationsCombinationsRequired. Array of Object; no unknown keys.; minimum items 1; maximum items 256.
combinations[].indexIndexRequired. Safe integer; minimum 0.
combinations[].levelsLevelsRequired. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 1; maximum items 8.
combinations[].countCountRequired. Safe integer; minimum 0.
assignmentsAssignmentsRequired. Array of Object; no unknown keys.; minimum items 1; maximum items 512.
assignments[].unitIdUnit IdRequired. Text; minimum UTF-16 length 1; maximum UTF-16 length 128.
assignments[].combinationIndexCombination IndexRequired. Safe integer; minimum 0.
assignments[].levelsLevelsRequired. Array of Text; minimum UTF-16 length 1; maximum UTF-16 length 128.; minimum items 1; maximum items 8.
randomnessReplay source and normalized 32-bit seed, or null seed for an advancing context source.Required. Object; no unknown keys.
randomness.seedOptional safe-integer replay seed; normalization and precedence are explained below.Required. Safe integer. or Null.
randomness.sourceSourceRequired. 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.

json
{
  "input": {
    "factors": [
      {
        "name": "temperature",
        "levels": [
          "low",
          "high"
        ]
      },
      {
        "name": "time",
        "levels": [
          "short",
          "long"
        ]
      }
    ],
    "unitIds": [
      "u1",
      "u2",
      "u3",
      "u4"
    ],
    "replication": 1,
    "seed": 42
  },
  "output": {
    "factorNames": [
      "temperature",
      "time"
    ],
    "combinations": [
      {
        "index": 0,
        "levels": [
          "low",
          "short"
        ],
        "count": 1
      },
      {
        "index": 1,
        "levels": [
          "low",
          "long"
        ],
        "count": 1
      },
      {
        "index": 2,
        "levels": [
          "high",
          "short"
        ],
        "count": 1
      },
      {
        "index": 3,
        "levels": [
          "high",
          "long"
        ],
        "count": 1
      }
    ],
    "assignments": [
      {
        "unitId": "u1",
        "combinationIndex": 2,
        "levels": [
          "high",
          "short"
        ]
      },
      {
        "unitId": "u2",
        "combinationIndex": 1,
        "levels": [
          "low",
          "long"
        ]
      },
      {
        "unitId": "u3",
        "combinationIndex": 3,
        "levels": [
          "high",
          "long"
        ]
      },
      {
        "unitId": "u4",
        "combinationIndex": 0,
        "levels": [
          "low",
          "short"
        ]
      }
    ],
    "randomness": {
      "seed": 42,
      "source": "seed"
    }
  }
}

Limitations and assumptions

  • Unit count must equal combination count times replication. Balance does not by itself provide blocking, concealment, causal identification, or a valid real experiment; factor meanings and units are supplied.
  • 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

  1. Tool behavior and example: Random Balanced Factorial Assignment Generator — tool.io

  2. Calculation or validation: list/cartesian-product — tool.io

Similar or alternative tools