Skip to content

Conversation

@rasmi
Copy link
Contributor

@rasmi rasmi commented Dec 4, 2025

Adds a new BALANCED_ASSIGNMENT variable config type that allows experimenters to randomly assign participants to different experimental conditions (e.g., policies, treatments) with balanced distribution.

Changes

New Feature - Balanced Assignment Variables

  • New BalancedAssignmentVariableConfig type with three balance strategies:
    • ROUND_ROBIN - Cycles through values based on participant count (deterministic, perfectly balanced)
    • LEAST_USED - Assigns to the value used by fewest participants (handles dropouts)
    • RANDOM - Seeded random selection without balancing
  • Balance scope options: EXPERIMENT-wide or per-COHORT
  • Full UI support in the variable editor
  • Example usage in policy template (getPolicyBalancedExperimentTemplate)

Refactor - Moved generateVariablesForScope to functions

  • Moved from utils/ to functions/ since balanced assignment requires Firestore queries (e.g. querying active participant count for ROUND_ROBIN strategy, variable count for LEAST_USED strategy)
  • Now async to support database-dependent variable generation
  • Helper functions (generateStaticVariables, generateRandomPermutationVariables) remain in utils and are exported

Testing

  • Added integration tests for generateVariablesForScope in functions/ using Firestore emulator
  • Updated unit tests in utils/ to test helper functions directly

@rasmi rasmi force-pushed the balanced-strategy branch from ddf6997 to 13ba655 Compare December 4, 2025 18:21
@rasmi rasmi force-pushed the balanced-strategy branch 2 times, most recently from d3aad4a to 56c7ebe Compare December 4, 2025 21:47
@rasmi rasmi force-pushed the balanced-strategy branch from ecc5e0a to 98d433f Compare December 4, 2025 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant