Prioritized Experience Replay (PER) improves on uniform replay by sampling transitions proportional to their TD error magnitude. Transitions where the agent was most "surprised" (large TD error) are replayed more often, leading to faster learning. To correct for the bias introduced by non-uniform sampling, importance sampling weights are applied.
Given a list of priority values, an alpha parameter (controls how much prioritization is used), and a beta parameter (controls importance sampling correction), compute the sampling probabilities and normalized importance sampling weights.
Input:
priorities = [1, 2, 3], alpha = 1.0, beta = 1.0
Output:
[[0.1667, 0.3333, 0.5], [1.0, 0.5, 0.3333]]
With alpha = 1, probabilities are proportional to priorities. Weight for the least-likely sample (index 0) is largest and normalizes to 1.0. Higher probability samples get smaller weights to correct for oversampling.
Input:
priorities = [1, 1, 1], alpha = 1.0, beta = 1.0
Output:
[[0.3333, 0.3333, 0.3333], [1.0, 1.0, 1.0]]
Equal priorities produce uniform probabilities and all weights equal 1.0.
First compute powered = [p ** alpha for p in priorities]. Then total = sum(powered), probs = [x / total for x in powered]. Then raw_weights = [(n * pr) ** (-beta) for pr in probs] where n = len(priorities). Finally normalize by max(raw_weights).
When alpha = 0, all powered values equal 1, so probabilities become uniform regardless of the original priorities.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Prioritized Experience Replay (PER) improves on uniform replay by sampling transitions proportional to their TD error magnitude. Transitions where the agent was most "surprised" (large TD error) are replayed more often, leading to faster learning. To correct for the bias introduced by non-uniform sampling, importance sampling weights are applied.
Given a list of priority values, an alpha parameter (controls how much prioritization is used), and a beta parameter (controls importance sampling correction), compute the sampling probabilities and normalized importance sampling weights.
Input:
priorities = [1, 2, 3], alpha = 1.0, beta = 1.0
Output:
[[0.1667, 0.3333, 0.5], [1.0, 0.5, 0.3333]]
With alpha = 1, probabilities are proportional to priorities. Weight for the least-likely sample (index 0) is largest and normalizes to 1.0. Higher probability samples get smaller weights to correct for oversampling.
Input:
priorities = [1, 1, 1], alpha = 1.0, beta = 1.0
Output:
[[0.3333, 0.3333, 0.3333], [1.0, 1.0, 1.0]]
Equal priorities produce uniform probabilities and all weights equal 1.0.
First compute powered = [p ** alpha for p in priorities]. Then total = sum(powered), probs = [x / total for x in powered]. Then raw_weights = [(n * pr) ** (-beta) for pr in probs] where n = len(priorities). Finally normalize by max(raw_weights).
When alpha = 0, all powered values equal 1, so probabilities become uniform regardless of the original priorities.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number