def get_bulk_edge_values(counts, bins):
    """Separate the bulk from the edge values
       The bulk is defined according to the semicircle
       law: lambda in [-2, 2].

    Args:
        counts (np array, float32): eigenvalue density.
        bins (np array, float32): eigenvalues.       

    Returns:
        bulk_rho (np array, float32): bulk eigenvalue density.
        tails_tho (np array, float32): tails eigenvalue density.
        bulk_lambdas (np array, float32): bulk eigenvalues.
        tails_lambdas (np array, float32): tails eigenvalues.
    """
    # get the right edge position
    right = bins[:-1] <= 2.0
    # get the left edge position
    left = bins[:-1] >= -2.0

    # Get the bulk and tails mask
    bulk_mask = right * left
    tails_mask = ~bulk_mask

    # get the bulk and edge values

    bulk_rho = counts[bulk_mask]
    tails_rho = counts[tails_mask]

    bulk_lambdas = bins[:-1][bulk_mask]
    tails_lambdas = bins[:-1][tails_mask]

    return bulk_rho, bulk_lambdas, tails_rho, tails_lambdas