expyriment.design.randomize

The expyriment randomize module.

This module contains various functions for randomizing data

Attributes

Modules

Classes

Functions

expyriment.design.randomize.coin_flip(head_bias=0.5)

Return randomly True (head) or False (tail).

Parameters:

head_bias : numeric, optional

bias in favor of head (default=0.5, fair coin)

Returns:

rnd : bool

expyriment.design.randomize.make_multiplied_shuffled_list(list_, xtimes)

Return the multiplied and shuffled (sectionwise) list.

The function manifolds the list ‘x times’ and shuffles each and concatenates to the return new lists.

Parameters:

list_ : list

list to be shuffled

xtimes : int

how often the list will be multiplied. If xtimes==0, an empty list will be returned.

expyriment.design.randomize.rand_element(list_)

Return a random element from a list

expyriment.design.randomize.rand_int(a, b)

Return random integer in given range.

Parameters:

a : int

first element of range

b : int

last element of range

expyriment.design.randomize.rand_int_sequence(first_elem, last_elem)

Return a randomised sequence of integers in given range.

Parameters:

first_elem : int

first element of the range

last_elem : int

last element of the range

expyriment.design.randomize.rand_norm(a, b, mu=None, sigma=None)

Normally distributed random number in given range.

Parameters:

a : numeric

lowest number in range

b : numeric

highest number in range

mu : numeric, optional

distribution mean, default: mid point of the interval [a, b]

sigma : numeric, optional

distribution standard deviation, default: (b-a)/6.0

Returns:

rnd : numeric

expyriment.design.randomize.shuffle_list(list_, max_repetitions=-1, n_segments=0)

Shuffle any list of objects. In place randomization of the list.

Parameters:

list_ : list

the list to shuffle; if not a list, TypeError is raised

max_repetitions : int, optional

maximum number of allowed repetitions of one identical items; if no solution can be found (i.e., Python’s recursion limit is reached), the function returns False and the list will be randomized without constrains (see Notes); default = -1

n_segments : int, optional

randomize list per segment, i.e., list will be divided into n equal sized segments and the order of elements within each segment will be randomized; if n_segments is < 2, this parameter has no effect; default = 0

Returns:

success : bool

returns if randomization was successful and fulfilled the specified constrains (see max_repetitions)