Esempio n. 1
0
 def log_likelihood(self, x):
     if isinstance(x, np.ndarray):
         x0 = x[:self.nb_lags]
         log_lik = np.zeros((x0.shape[0], self.nb_states))
         for k in range(self.nb_states):
             log_lik[:, k] = lg_mvn(x0, self.mean(k), self.sigma[k])
         return log_lik
     else:
         return list(map(self.log_likelihood, x))
Esempio n. 2
0
    def log_likelihood(self, x, u=None):
        if isinstance(x, np.ndarray) and isinstance(u, np.ndarray):
            log_lik = np.zeros((x.shape[0], self.nb_states))
            for k in range(self.nb_states):
                log_lik[:, k] = lg_mvn(x, self.mean(k), self.sigma[k])
            return log_lik
        else:

            def inner(x, u):
                return self.log_likelihood.__wrapped__(self, x, u)

            return list(map(inner, x, u))
Esempio n. 3
0
    def log_likelihood(self, x, u):
        if isinstance(x, np.ndarray) and isinstance(u, np.ndarray):
            xr = arstack(x, self.nb_lags + 1)
            ur = u[self.nb_lags:]

            log_lik = np.zeros((ur.shape[0], self.nb_states))
            for k in range(self.nb_states):
                log_lik[:, k] = lg_mvn(ur, self.mean(k, xr), self.sigma[k])
            return log_lik
        else:

            def inner(x, u):
                return self.log_likelihood.__wrapped__(self, x, u)

            return list(map(inner, x, u))
Esempio n. 4
0
    def log_likelihood(self, x, u):
        if isinstance(x, np.ndarray) and isinstance(u, np.ndarray):
            xr = arstack(x, self.nb_lags)[:-1]
            ur = u[self.nb_lags - 1:-1]
            xn = x[self.nb_lags:]

            log_lik = np.zeros((xr.shape[0], self.nb_states))
            for k in range(self.nb_states):
                mu = self.mean(k, xr, ur)
                log_lik[:, k] = lg_mvn(xn, mu, self.sigma[k])
            return log_lik
        else:

            def inner(x, u):
                return self.log_likelihood.__wrapped__(self, x, u)

            return list(map(inner, x, u))