Skip to content

jmviz/random-debruijn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

random-debruijn

Python code for generating random de Bruijn sequences.

Command line usage

Generate a random de Bruijn sequence of order 4 on an alphabet of size 2:

python debruijn.py 2 4

Example output:

0010100110111100

Generate a 2-fold random de Bruijn sequence of order 2 on an alphabet of size 4:

python debruijn.py 4 2 -f 2

Example output:

22131320301010311233300020232112

Generating trial sequences for experiments

Say you have an experiment where each trial has 2 factors, each with 2 levels, making a total of 2 × 2 = 4 trial types. To generate a de Bruijn block of trials where each length-2 subsequence of trial types occurs exactly once:

import debruijn
probe = [True, False]
orientation = ["left", "right"]
sequencer = debruijn.Sequencer(2, probe, orientation)
block = sequencer.block()
print(block)

Example output:

[(True, 'right'), (False, 'right'), (False, 'right'), (False, 'left'), (True, 'right'), (True, 'left'), (True, 'left'), (False, 'right'), (True, 'left'), (False, 'left'), (False, 'left'), (True, 'left'), (True, 'right'), (True, 'right'), (False, 'left'), (False, 'right')]

See comments in code for more details and options.

About

random de Bruijn sequences

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages