(sample_list, traj_distr, traj_info)
return mu_all, predicted_cost
This function gives the LQR estimate of the cost function given the noise
    experienced along each sample in sample_list.
    Args:
        sample_list: List of samples to extract noise from.
        traj_distr: LQR controller to roll forward.
        traj_info: Used to obtain dynamics estimate to simulate trajectories.
    Returns:
        mu_all: Trajectory means corresponding to each sample in sample_list.
        predicted_cost: LQR estimates of cost of each sample in sample_list.
This function gives the LQR estimate of the cost function given the noise
    experienced along each sample in sample_list.
    Args:
        sample_list: List of samples to extract noise from.
        traj_distr: LQR controller to roll forward.
        traj_info: Used to obtain dynamics estimate to simulate trajectories.
    Returns:
        mu_all: Trajectory means corresponding to each sample in sample_list.
        predicted_cost: LQR estimates of cost of each sample in sample_list.
This function gives the LQR estimate of the cost function given the noise experienced along each sample in sample_list . Args : sample_list : List of samples to extract noise from . traj_distr : LQR controller to roll forward . traj_info : Used to obtain dynamics estimate to simulate trajectories . Returns : mu_all : Trajectory means corresponding to each sample in sample_list . predicted_cost : LQR estimates of cost of each sample in sample_list .
def approximated_cost(sample_list, traj_distr, traj_info):
    """
    This function gives the LQR estimate of the cost function given the noise
    experienced along each sample in sample_list.
    Args:
        sample_list: List of samples to extract noise from.
        traj_distr: LQR controller to roll forward.
        traj_info: Used to obtain dynamics estimate to simulate trajectories.
    Returns:
        mu_all: Trajectory means corresponding to each sample in sample_list.
        predicted_cost: LQR estimates of cost of each sample in sample_list.
    """
    T = traj_distr.T
    N = len(sample_list)
    dU = traj_distr.dU
    dX = traj_distr.dX
    noise = sample_list.get_noise()

    # Constants.
    idx_x = slice(dX)
    mu_all = np.zeros((N, T, dX+dU))

    # Pull out dynamics.
    Fm = traj_info.dynamics.Fm
    fv = traj_info.dynamics.fv
    dyn_covar = traj_info.dynamics.dyn_covar

    for i in range(N):
        mu = np.zeros((T, dX+dU))
        mu[0, idx_x] = traj_info.x0mu
        for t in range(T):
            mu[t, :] = np.hstack([
                mu[t, idx_x],
                (traj_distr.K[t, :, :].dot(mu[t, idx_x]) + traj_distr.k[t, :]
                 + traj_distr.chol_pol_covar[t].T.dot(noise[i, t]))
            ])
            if t < T - 1:
                mu[t+1, idx_x] = Fm[t, :, :].dot(mu[t, :]) + fv[t, :]
        mu_all[i, :, :] = mu

    # Compute cost.
    predicted_cost = np.zeros((N, T))

    for i in range(N):
        for t in range(T):
            predicted_cost[i, t] = traj_info.cc[t] + \
                    0.5 * mu_all[i,t,:].T.dot(traj_info.Cm[t, :, :]).dot(mu_all[i,t,:]) + \
                    mu_all[i,t,:].T.dot(traj_info.cv[t, :])

    return mu_all, predicted_cost
def approximated_cost ( sample_list , traj_distr , traj_info ) : T = traj_distr . T N = len ( sample_list ) dU = traj_distr . dU dX = traj_distr . dX noise = sample_list . get_noise ( ) # Constants. idx_x = slice ( dX ) mu_all = np . zeros ( ( N , T , dX + dU ) ) # Pull out dynamics. Fm = traj_info . dynamics . Fm fv = traj_info . dynamics . fv dyn_covar = traj_info . dynamics . dyn_covar for i in range ( N ) : mu = np . zeros ( ( T , dX + dU ) ) mu [ 0 , idx_x ] = traj_info . x0mu for t in range ( T ) : mu [ t , : ] = np . hstack ( [ mu [ t , idx_x ] , ( traj_distr . K [ t , : , : ] . dot ( mu [ t , idx_x ] ) + traj_distr . k [ t , : ] + traj_distr . chol_pol_covar [ t ] . T . dot ( noise [ i , t ] ) ) ] ) if t < T - 1 : mu [ t + 1 , idx_x ] = Fm [ t , : , : ] . dot ( mu [ t , : ] ) + fv [ t , : ] mu_all [ i , : , : ] = mu # Compute cost. predicted_cost = np . zeros ( ( N , T ) ) for i in range ( N ) : for t in range ( T ) : predicted_cost [ i , t ] = traj_info . cc [ t ] + 0.5 * mu_all [ i , t , : ] . T . dot ( traj_info . Cm [ t , : , : ] ) . dot ( mu_all [ i , t , : ] ) + mu_all [ i , t , : ] . T . dot ( traj_info . cv [ t , : ] ) return mu_all , predicted_cost