class Parameters: def __init__(self, config, ys, n): self.config = config self.d = config['h_states'] ones = [1 for i in xrange(self.d)] self.y = ys self.n = n self.minYk = min(ys) self.maxYk = max(ys) self.epsilon = (self.minYk + self.maxYk) / 2.0 self.r = self.maxYk - self.minYk self.k = 1.0 / self.r**2 self.alpha = 2.0 self.g = 0.2 self.h = 10.0 / self.r**2 self.init_priors = Dirichlet(ones) self.init_beta = Gamma(self.g, self.h) self.init_root_sigma = Gamma(self.alpha, self.init_beta.sample()) self.init_means = Normal(self.epsilon, self.k**-1) self.init_trans = [Dirichlet(ones) for i in xrange(self.d)] self.x = [choice(xrange(config['h_states'])) for i in xrange(self.n)] def set_initial_params(self): self.priors = self.init_priors.sample() self.beta = self.init_beta.sample() self.sigma = self.init_root_sigma.sample() ** (-1.0/2) # print "starting stds = " + str(self.sigma) self.means = [self.init_means.sample() for i in xrange(self.d)] self.trans = [self.init_trans[i].sample() for i in xrange(self.d)]
def __init__(self, config, ys, n): self.config = config self.d = config['h_states'] ones = [1 for i in xrange(self.d)] self.y = ys self.n = n self.minYk = min(ys) self.maxYk = max(ys) self.epsilon = (self.minYk + self.maxYk) / 2.0 self.r = self.maxYk - self.minYk self.k = 1.0 / self.r**2 self.alpha = 2.0 self.g = 0.2 self.h = 10.0 / self.r**2 self.init_priors = Dirichlet(ones) self.init_beta = Gamma(self.g, self.h) self.init_root_sigma = Gamma(self.alpha, self.init_beta.sample()) self.init_means = Normal(self.epsilon, self.k**-1) self.init_trans = [Dirichlet(ones) for i in xrange(self.d)] self.x = [choice(xrange(config['h_states'])) for i in xrange(self.n)]