ListRandomizer.balanced()#

classmethod ListRandomizer.balanced(*conditions, n: int, **kwargs)[source]#

Alternative constructor, creates a ListRandomizer where all conditions have the same size.

Parameters
  • *conditions (str) – A variable number of strings, giving the condition names.

  • n (int) – The number of participants per condition.

  • **kwargs – Keyword arguments, passed on the normal intialization of ListRandomizer.

Notes

This alternative constructor offers a more concise syntax for simple balanced setups. All conditions receive the same sample size.

Examples

import alfred3 as al
exp = al.Experiment()

@exp.setup
def setup(exp):
    randomizer = al.ListRandomizer.balanced("cond1", "cond2", n=10, exp=exp)
    exp.condition = randomizer.get_condition()

@exp.member
class DemoPage(al.Page):

    def on_exp_access(self):

        if self.exp.condition == "cond1":
            lab = "label in condition 1"

        elif self.exp.condition == "cond2":
            lab = "label in condition 2"

        self += al.TextEntry(leftlab=lab, name="t1")