(group_membership: np.ndarray,
                         num_levels: int = 4)
return B_star
Return a single trajectory

    Return a single trajectory of size :math:`(g+1)`-by-:math:`k`
    where :math:`g` is the number of groups,
    and :math:`k` is the number of factors,
    both implied by the dimensions of `group_membership`

    Parameters
    ---------
    group_membership : np.ndarray
        a k-by-g matrix which notes factor membership of groups
    num_levels : int, default=4
        The number of levels in the grid

    Returns
    -------
    np.ndarray
Return a single trajectory
Return a single trajectory
def _generate_trajectory(group_membership: np.ndarray,
                         num_levels: int = 4) -> np.ndarray:
    """Return a single trajectory

    Return a single trajectory of size :math:`(g+1)`-by-:math:`k`
    where :math:`g` is the number of groups,
    and :math:`k` is the number of factors,
    both implied by the dimensions of `group_membership`

    Parameters
    ---------
    group_membership : np.ndarray
        a k-by-g matrix which notes factor membership of groups
    num_levels : int, default=4
        The number of levels in the grid

    Returns
    -------
    np.ndarray
    """

    delta = _compute_delta(num_levels)

    # Infer number of groups `g` and number of params `k` from
    # `group_membership` matrix
    num_params = group_membership.shape[0]
    num_groups = group_membership.shape[1]

    # Matrix B - size (g + 1) * g -  lower triangular matrix
    B = np.tril(np.ones([num_groups + 1, num_groups],
                        dtype=int), -1)

    P_star = _generate_p_star(num_groups)

    # Matrix J - a (g+1)-by-num_params matrix of ones
    J = np.ones((num_groups + 1, num_params))

    # Matrix D* - num_params-by-num_params matrix which decribes whether
    # factors move up or down
    D_star = np.diag(rd.choice([-1, 1], num_params))

    x_star = _generate_x_star(num_params, num_levels)

    # Matrix B* - size (num_groups + 1) * num_params
    B_star = _compute_b_star(J, x_star, delta, B,
                             group_membership, P_star, D_star)

    return B_star
def _generate_trajectory ( group_membership : np . ndarray , num_levels : int = 4 ) -> np . ndarray : delta = _compute_delta ( num_levels ) # Infer number of groups `g` and number of params `k` from # `group_membership` matrix num_params = group_membership . shape [ 0 ] num_groups = group_membership . shape [ 1 ] # Matrix B - size (g + 1) * g -  lower triangular matrix B = np . tril ( np . ones ( [ num_groups + 1 , num_groups ] , dtype = int ) , - 1 ) P_star = _generate_p_star ( num_groups ) # Matrix J - a (g+1)-by-num_params matrix of ones J = np . ones ( ( num_groups + 1 , num_params ) ) # Matrix D* - num_params-by-num_params matrix which decribes whether # factors move up or down D_star = np . diag ( rd . choice ( [ - 1 , 1 ] , num_params ) ) x_star = _generate_x_star ( num_params , num_levels ) # Matrix B* - size (num_groups + 1) * num_params B_star = _compute_b_star ( J , x_star , delta , B , group_membership , P_star , D_star ) return B_star