    def __apply_ar_model_to_cascades(self, j, state, params):
        """
        Apply the AR(p) model to the cascades for each ensemble member, including
        noise generation and normalization.
        """
        # Generate noise if enabled
        if params["noise_method"] is not None:
            eps = self.__generate_and_decompose_noise(j, state, params)
        else:
            eps = None

        # Iterate the AR(p) model for each cascade level
        for i in range(params["n_cascade_levels"]):
            if eps is not None:
                eps_ = eps["cascade_levels"][i]
                eps_ *= params["noise_std_coeffs"][i]
            else:
                eps_ = None

            # Apply the AR(p) model with or without perturbations
            if eps is not None or params["vel_pert_method"] is not None:
                state["precip_cascades"][j][i] = autoregression.iterate_ar_model(
                    state["precip_cascades"][j][i], params["phi"][i, :], eps=eps_
                )
            else:
                # use the deterministic AR(p) model computed above if
                # perturbations are disabled
                state["precip_cascades"][j][i] = state["precip_m"][i]

        eps = None
        eps_ = None
Apply the AR(p) model to the cascades for each ensemble member, including
noise generation and normalization.
pysteps/nowcasts/steps.py