TensorTonic
Study Plans
Study Plan
Mix Dirichlet Noise into Root Priors
Reinforcement LearningProbability and Statistics
Easy

Mix root priors with a supplied Dirichlet noise sample. Priors and noise are nonnegative NumPy weight arrays, not necessarily normalized; legal_mask is a Boolean NumPy array. For each legal action aaa,

Pa′=(1−ε)P^a+εη^a.P'_a=(1-\varepsilon)\widehat{P}_a+\varepsilon\widehat{\eta}_a.Pa′​=(1−ε)Pa​+εη​a​.

Here Pa′P'_aPa′​ is the mixed prior, ε\varepsilonε is epsilon, and P^\widehat{P}P and η^\widehat{\eta}η​ are priors and noise normalized separately over legal actions. Illegal actions receive exactly zero. Use the supplied noise without sampling new values. Return a new NumPy float64 array with the same shape and action order as priors.

Loading visualization...

Examples

Input: priors = [2,1,0], noise = [0,3,4], legal_mask = [true,true,false], epsilon = 0.25

Output: [0.5,0.5,0]

Explanation: Priors and noise are normalized over the first two actions before the 75 to 25 mixture.

Input: priors = [1,3,5], noise = [4,0,96], legal_mask = [true,true,false], epsilon = 1

Output: [1,0,0]

Input: priors = [10,0,2], noise = [7,8,5], legal_mask = [false,false,true], epsilon = 0.6

Output: [0,0,1]

Hint 1

Boolean indexing isolates the legal weights before summing.

Hint 2

np.zeros can hold the full action array while legal entries are filled.

Requirements

  • Use NumPy and return float64 values.
  • Keep illegal probabilities at exact zero.
  • Leave priors, noise, and legal_mask unchanged.

Constraints

  • Priors, noise weights, and the legal mask are aligned, nonempty one-dimensional arrays.
  • Priors and noise weights are finite and nonnegative, with positive mass on legal actions.
  • The legal mask contains at least one legal action.
  • The noise fraction lies between 0 and 1.
Try Similar Problems
Sample a Recent Self-Play Replay BatchEasyTurn Root Visits into a Search PolicyMediumImplement the AlphaGo Policy-Value LossMediumFind a Go Group and Its LibertiesEasyInitialize Legal MCTS Edge StatisticsEasySelect an Action with PUCTEasyCompute the Policy and Value HeadsMediumApply an AlphaGo Residual BlockMediumSoftmax (Boltzmann) ExplorationEasyUCB1 for Multi-Armed BanditsEasyThompson Sampling (Beta-Bernoulli)MediumEpsilon-Greedy Action SelectionEasy

Accepts: array

Accepts: array

Accepts: array

Accepts: number

You must run your code first.

Mix Dirichlet Noise into Root Priors

Reinforcement LearningProbability and Statistics
Easy

Mix root priors with a supplied Dirichlet noise sample. Priors and noise are nonnegative NumPy weight arrays, not necessarily normalized; legal_mask is a Boolean NumPy array. For each legal action aaa,

Pa′=(1−ε)P^a+εη^a.P'_a=(1-\varepsilon)\widehat{P}_a+\varepsilon\widehat{\eta}_a.Pa′​=(1−ε)Pa​+εη​a​.

Here Pa′P'_aPa′​ is the mixed prior, ε\varepsilonε is epsilon, and P^\widehat{P}P and η^\widehat{\eta}η​ are priors and noise normalized separately over legal actions. Illegal actions receive exactly zero. Use the supplied noise without sampling new values. Return a new NumPy float64 array with the same shape and action order as priors.

Loading visualization...

Examples

Input: priors = [2,1,0], noise = [0,3,4], legal_mask = [true,true,false], epsilon = 0.25

Output: [0.5,0.5,0]

Explanation: Priors and noise are normalized over the first two actions before the 75 to 25 mixture.

Input: priors = [1,3,5], noise = [4,0,96], legal_mask = [true,true,false], epsilon = 1

Output: [1,0,0]

Input: priors = [10,0,2], noise = [7,8,5], legal_mask = [false,false,true], epsilon = 0.6

Output: [0,0,1]

Hint 1

Boolean indexing isolates the legal weights before summing.

Hint 2

np.zeros can hold the full action array while legal entries are filled.

Requirements

  • Use NumPy and return float64 values.
  • Keep illegal probabilities at exact zero.
  • Leave priors, noise, and legal_mask unchanged.

Constraints

  • Priors, noise weights, and the legal mask are aligned, nonempty one-dimensional arrays.
  • Priors and noise weights are finite and nonnegative, with positive mass on legal actions.
  • The legal mask contains at least one legal action.
  • The noise fraction lies between 0 and 1.
Try Similar Problems
Sample a Recent Self-Play Replay BatchEasyTurn Root Visits into a Search PolicyMediumImplement the AlphaGo Policy-Value LossMediumFind a Go Group and Its LibertiesEasyInitialize Legal MCTS Edge StatisticsEasySelect an Action with PUCTEasyCompute the Policy and Value HeadsMediumApply an AlphaGo Residual BlockMediumSoftmax (Boltzmann) ExplorationEasyUCB1 for Multi-Armed BanditsEasyThompson Sampling (Beta-Bernoulli)MediumEpsilon-Greedy Action SelectionEasy

Accepts: array

Accepts: array

Accepts: array

Accepts: number

You must run your code first.