<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _forecast_mean(self,h,t_params,Y,shock_type=None,shock_index=0,shock_value=None,shock_dir='positive',irf_intervals=False):
 """ Function allows for mean prediction; also allows shock specification for simulations or impulse response effects Parameters h : int How many steps ahead to forecast t_params : np.array Transformed latent variables vector Y : np.array Data for series that is being forecast shock_type : None or str Type of shock; options include None, 'Cov' (simulate from covariance matrix), 'IRF' (impulse response shock) shock_index : int Which latent variable to apply the shock to if using an IRF. shock_value : None or float If specified, applies a custom-sized impulse response shock. shock_dir : str Direction of the IRF shock. One of 'positive' or 'negative'. irf_intervals : Boolean Whether to have intervals for the IRF plot or not Returns A vector of forecasted data """
         

        random = self._shock_create(h, shock_type, shock_index, shock_value, shock_dir,irf_intervals)
        exp = [Y[variable] for variable in range(0,self.ylen)]
        
        # Each forward projection
        for t in range(0,h):
            new_values = np.zeros(self.ylen)

            # Each variable
            for variable in range(0,self.ylen):
                index_ref = variable*(1+self.ylen*self.lags)
                new_values[variable] = t_params[index_ref] # constant

                # VAR(p) terms
                for lag in range(0,self.lags):
                    for lagged_var in range(0,self.ylen):
                        new_values[variable] += t_params[index_ref+lagged_var+(lag*self.ylen)+1]*exp[lagged_var][-1-lag]
                
                # Random shock
                new_values[variable] += random[t][variable]

            # Add new values
            for variable in range(0,self.ylen):
                exp[variable] = np.append(exp[variable],new_values[variable])

        return np.array(exp)