Hi Barbara,

```
import random
```

This line is not necessary. Builder imports several functions from the `numpy.random`

library for you at the start of every script, like this:

```
from numpy.random import random, randint, normal, shuffle
```

`numpy`

is a numerical library and we prefer to use that rather than the random functions built in to the standard Python library. `numpy`

provides a comprehensive suite of random functions and you can see documentation for them here:

https://docs.scipy.org/doc/numpy/reference/routines.random.html

So consulting that, you’ll see that the equivalent of the `randint()`

function isn’t what you are after: as the name suggests, it returns a random integer, whereas you want a floating point number between 2.5 and 4.0.

The usual way to do this is to use the `random()`

function which returns a float between 0.0 and 1.0, and then add and multiply that as necessary to get a number in the range you need, e.g.

```
jitter = random() * (4.0 - 2.5) + 2.5
```

But note that delay periods need to be some multiple of the screen refresh rate of your screen. e.g. if your display is running at 60 Hz, then any interval must be a multiple of 16.6667 ms. So 3.0 s is a valid interval, as it equals 18 * 16.6667, but say 3.05 would not be valid. A quick and dirty way is just to round your interval to 1 decimal place so that any interval is a multiple of 100 ms (as 100 ms = 6 * 16.6667 ms), i.e.

```
jitter = round(jitter, 1) # round to 1 decimal place
```

so your intervals would be constrained to be 2.0, 2.1, 2.2 s, etc

You probably want to record what the jitter was on a give trial, so make sure you do this:

```
thisExp.addData('jitter', jitter)
```

to add a column labelled `jitter`

to your data file.

Lastly, make sure your code component is above any component that will use the `jitter`

variable, as it needs to be calculated before it gets referred to.

It’s usually easiest to just split things across several routines. Have the first routine end when a key is pressed. This inter trial interval can then go on a second routine, which will start immediately upon the previous one ending. That way you only need to specify a duration for the stimulus: its onset time will simply be fixed at zero.