Esempio n. 1
0
def true_nll_gaussian(x, mu, sigma):
    x = convert_to_container(x, container=tuple)
    mu = convert_to_container(mu, container=tuple)
    sigma = convert_to_container(sigma, container=tuple)
    constraint = z.constant(0.0)
    if not len(x) == len(mu) == len(sigma):
        raise ValueError("params, mu and sigma have to have the same length.")
    for x_, mean, sig in zip(x, mu, sigma):
        constraint += z.reduce_sum(z.square(x_ - mean) / (2.0 * z.square(sig)))

    return constraint
Esempio n. 2
0
 def indefinite_integral(limits):
     max_degree = model.degree + 1
     polys = do_recurrence(x=limits,
                           polys=chebyshev_polys,
                           degree=max_degree,
                           recurrence=chebyshev_recurrence)
     one_limit_integrals = []
     for degree in range(2, max_degree):
         coeff = model.params[f"c_{degree}"]
         n_float = z.convert_to_tensor(degree)
         integral = (n_float * polys[degree + 1] /
                     (z.square(n_float) - 1) - limits * polys[degree] /
                     (n_float - 1))
         one_limit_integrals.append(coeff * integral)
     return z.reduce_sum(one_limit_integrals, axis=0)
Esempio n. 3
0
 def _unnormalized_pdf(self, x):
     mu = self.params['mu']
     sigma = self.params['sigma']
     x = z.unstack_x(x)
     return z.exp(-z.square((x - mu) / sigma))
Esempio n. 4
0
 def _func(self, x):
     mu = self.params['mu']
     sigma = self.params['sigma']
     x = z.unstack_x(x)
     return z.exp(-z.square((x - mu) / sigma))
Esempio n. 5
0
 def _func(self, x):
     mu = self.params["mu"]
     sigma = self.params["sigma"]
     x = z.unstack_x(x)
     return z.exp(-z.square((x - mu) / sigma))