All problems
Squashed Gaussian Sample Seeded
Problem
Sample u ~ Normal(mu, sigma) with rng = random.Random(seed), then squash it with tanh. Return [u, tanh(u)] so callers can also use the pre-squash value in the log-probability.
Hint
SAC samples via reparameterization so the policy stays differentiable.
Test cases
case 1
in: [0,1,42]
expected: [-0.14409032957792836,-0.1431013398880218]
case 2
in: [1,0.5,0]
expected: [1.4708577023403322,0.8997409430816226]
case 3
in: [-1,2,7]
expected: [-1.5117605768952007,-0.907250987286807]
Starter codePython
import random, math
def squashed_gaussian_sample(mu, sigma, seed):
# Your code here
pass3 test cases · run your code against them in the editor