expyriment.design.randomize

The expyriment randomize module.

This module contains various functions for randomizing data

Functions

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

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

Parameters:
head_biasnumeric, optional

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

Returns:
rndbool
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

xtimesint

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

Parameters:
list_list
Returns:
elema random element from the list
expyriment.design.randomize.rand_int(a, b)

Return random integer in given range.

Parameters:
aint

first element of range

bint

last element of range

Returns:
rndint
expyriment.design.randomize.rand_int_sequence(first_elem, last_elem)

Return a randomised sequence of integers in given range.

Parameters:
first_elemint

first element of the range

last_elemint

last element of the range

Returns:
rnd_seqlist

randomised sequence of integers in given range

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

Normally distributed random number in given range.

Parameters:
anumeric

lowest number in range

bnumeric

highest number in range

munumeric, optional

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

sigmanumeric, optional

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

Returns:
rndnumeric
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_repetitionsint, 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_segmentsint, 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:
successbool

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

Notes

When shuffling lists of trials or blocks, IDs and added stimuli will be ignored to determine repetitions, because trial or block comparisons are based on the compare`method (see documentation of `Trial or Block).