示例#1
0
    def simulate_with_residuals(self, residuals, ndisc = 100):
        """Simulate a time series using this model using the supplied residuals
           in residuals (ndarray).  This function is NOT deterministic and employs
           a spin-up phase to init the model state using random noise."""
           
        A = self.A
        w = self.w
        
        m, p = self.dimension(), self.order()
        N = residuals.shape[0]
        ts = np.zeros((N, m))

        # predictors always start with zeros
        u = np.zeros((m*p,), dtype=np.float64)
        
        # initialize system using noise with correct covariance matrix if required
        if ndisc > 0:
            eps_noise = np.dot(np.random.normal(size=(ndisc, m)), self.U)
            
            # spin-up to random state, which is captured by vector u
            var_model_acc.execute_Aupw(A, w, u, eps_noise, eps_noise)
        
        # start feeding in residuals and store result in ts, start with vector u as VAR(p) state
        var_model_acc.execute_Aupw(A, w, u, residuals, ts)
        
        return ts
示例#2
0
    def simulate_with_residuals(self, residuals, ndisc=100):
        """Simulate a time series using this model using the supplied residuals
           in residuals (ndarray).  This function is NOT deterministic and employs
           a spin-up phase to init the model state using random noise."""

        A = self.A
        w = self.w

        m, p = self.dimension(), self.order()
        N = residuals.shape[0]
        ts = np.zeros((N, m))

        # predictors always start with zeros
        u = np.zeros((m * p, ), dtype=np.float64)

        # initialize system using noise with correct covariance matrix if required
        if ndisc > 0:
            eps_noise = np.dot(np.random.normal(size=(ndisc, m)), self.U)

            # spin-up to random state, which is captured by vector u
            var_model_acc.execute_Aupw(A, w, u, eps_noise, eps_noise)

        # start feeding in residuals and store result in ts, start with vector u as VAR(p) state
        var_model_acc.execute_Aupw(A, w, u, residuals, ts)

        return ts
示例#3
0
 def simulate(self, N, ndisc = 100):
     """Simulate process described by the model.  Obtain N samples and spin up the model for 100 steps."""
     
     A = self.A
     w = self.w
     
     m, p = A.shape[0], A.shape[1] / A.shape[0]
     ts = np.zeros((N, m))
     
     u = np.zeros((m*p,))
     
     # construct noise with covariance matrix L * L^T
     eps_noise = np.dot(np.random.normal(size=(N + ndisc, m)), self.U)
    
     # spin up the model by running it for ndisc samples
     var_model_acc.execute_Aupw(A, w, u, eps_noise[:ndisc, :], eps_noise[:ndisc, :])
     
     # generate requested number of points
     var_model_acc.execute_Aupw(A, w, u, eps_noise[ndisc:, :], ts)
         
     return ts
示例#4
0
 def simulate(self, N, ndisc = 100):
     """Simulate process described by the model.  Obtain N samples and spin up the model for 100 steps."""
     
     A = self.A
     w = self.w
     
     m, p = A.shape[0], A.shape[1] / A.shape[0]
     ts = np.zeros((N, m))
     
     u = np.zeros((m*p,))
     
     # construct noise with covariance matrix L * L^T
     eps_noise = np.dot(np.random.normal(size=(N + ndisc, m)), self.U)
    
     # spin up the model by running it for ndisc samples
     var_model_acc.execute_Aupw(A, w, u, eps_noise[:ndisc, :], eps_noise[:ndisc, :])
     
     # generate requested number of points
     var_model_acc.execute_Aupw(A, w, u, eps_noise[ndisc:, :], ts)
         
     return ts