This module enables running measurements and interventions with randomization, such as A/B tests, multivariate tests, and randomized controlled trials.
- Source:
Methods
(static) selectCondition(conditionSet) → {string}
Selects a condition from a set of conditions. If a condition has previously been selected from the set, that same condition will be returned. If not, a condition will be randomly selected according to the provided weights.
Parameters:
Name | Type | Description |
---|---|---|
conditionSet |
ConditionSet | The set of conditions. |
- Source:
Returns:
- The name of the selected condition in the condition set.
- Type
- string
Example
// on first run, returns "red" with 0.5 probability and "blue" with 0.5 probability
// on subsequent runs, returns the same value as before
randomization.selectCondition({
name: "color",
conditions: [
{
name: "red",
weight: 1
},
{
name: "blue",
weight: 1
}
]
});
Type Definitions
Condition
A condition for a measurement or intervention that can be randomly selected.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
name |
string | A name that uniquely identifies the condition within the set of conditions. |
weight |
number | The positive weight to give this condition when randomly selecting a condition from a set. |
- Source:
ConditionSet
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
name |
string | A name that uniquely identifies the set of conditions. |
conditions |
Array.<Condition> | The conditions in the set. |
- Source: