All problems
Replay Buffer Sample
Problem
Sample batch indices from a replay buffer of the given size, with replacement.
Use random.Random(seed) and call rng.randrange(buffer_size) once per sample so the output is reproducible. Return the list of integer indices.
Hint
randrange(n) returns an index in [0, n), which is exactly uniform sampling from the buffer.
Test cases
case 1
in: [10,5,42]
expected: [1,0,4,3,3]
case 2
in: [5,3,0]
expected: [3,3,0]
case 3
in: [1,4,7]
expected: [0,0,0,0]
case 4
in: [100,6,123]
expected: [6,34,11,98,52,34]
Starter codePython
import random
def replay_sample_indices(buffer_size, batch_size, seed):
# Your code here
pass4 test cases · run your code against them in the editor