Skip to content

Commit

Permalink
Merge pull request #182 from Frawak/master
Browse files Browse the repository at this point in the history
Fix OrnsteinUhlenbeck reset
  • Loading branch information
RaphaelMeudec committed Jul 13, 2018
2 parents 171667d + c2794ff commit fd06a98
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions rl/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ def sample(self):

# Based on http://math.stackexchange.com/questions/1287634/implementing-ornstein-uhlenbeck-in-matlab
class OrnsteinUhlenbeckProcess(AnnealedGaussianProcess):
def __init__(self, theta, mu=0., sigma=1., dt=1e-2, x0=None, size=1, sigma_min=None, n_steps_annealing=1000):
def __init__(self, theta, mu=0., sigma=1., dt=1e-2, size=1, sigma_min=None, n_steps_annealing=1000):
super(OrnsteinUhlenbeckProcess, self).__init__(mu=mu, sigma=sigma, sigma_min=sigma_min, n_steps_annealing=n_steps_annealing)
self.theta = theta
self.mu = mu
self.dt = dt
self.x0 = x0
self.size = size
self.reset_states()

Expand All @@ -56,4 +55,4 @@ def sample(self):
return x

def reset_states(self):
self.x_prev = self.x0 if self.x0 is not None else np.zeros(self.size)
self.x_prev = np.random.normal(self.mu,self.current_sigma,self.size)

0 comments on commit fd06a98

Please sign in to comment.