import collections


def group_probability(x):
    """Compute the probability of each group given an array x"""
    count = collections.Counter(x)
    num_samples = len(x)
    return {k: v / num_samples for k, v in count.items()}