Skip to main content

sample

Function sample 

Source
pub fn sample<R: Rng>(
    buffer: &ReplayBuffer,
    batch_size: usize,
    rng: &mut R,
) -> ReplayBatch
Expand description

Sample batch_size transitions uniformly with replacement from the filled portion of buffer.

Uniform with-replacement matches the canonical DQN recipe and is what makes the sampler O(1) per draw. For small batches relative to buffer size the difference vs without-replacement is negligible.

ยงPanics

Panics if buffer.is_empty() or batch_size == 0.