# Customizing randomization

**URL:** <https://discourse.psychopy.org/t/customizing-randomization/46455>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [January 22, 2026, 11:57am UTC](https://discourse.psychopy.org/t/customizing-randomization/46455 "2026-01-22T11:57:59Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [January 22, 2026, 12:54pm UTC](https://discourse.psychopy.org/t/customizing-randomization/46455/2 "2026-01-22T12:54:52Z")

</div>

Have a look at my online demos **Complex Randomisation** and **Randomisation without repetition**. These are both based on the assumption that you want to control the total number of presentations of each syllable. When I want random without repetition for something I don’t mind being unequal I use the following code:

```auto
thisIndex = (thisIndex + 1 + randint(numberOfOptions - 1)) % numberOfOptions

```

For example, if there are 5 colours in an emotional Stroop task [‘red’, ‘blue’, ‘green’, ‘yellow’, ‘purple’] and the previous value of thisIndex was 2 (“green”) because counting starts from 0 for lists) then randint will generate a random integer from 0 to 3 and the new value of thisIndex will be between 3 (2 + 1 + 0 = 3; 3 % 5 = 3; ‘yellow’) and 6 (2 + 1 + 3 = 6; 6 % 5 = 1; ‘blue’).

> [@PsychoPy Online Demos](https://discourse.psychopy.org/t/psychopy-online-demos/22319):
>
> If you have routines or experiments that are likely to be useful to others, please create a post in this thread, editing your post to add new demos so there is one post per creator. Ideally set your demos so they can be tested without consuming a credit (if you don’t have a site license) by adding a final routine that can’t end, disabling save incomplete results and adding a small number of credits. Please do not discuss the demos in this thread or create more than one post unless you have a la…

---

_[View the full topic](https://discourse.psychopy.org/t/customizing-randomization/46455)._
