def PC_AC1_calc(P, TOP, POP):
    """
    Calculate Percent chance agreement for Gwet's AC1.

    :param P: number of actual positives per class
    :type P: dict
    :param TOP: number of positives in predict vector per class
    :type TOP: dict
    :param POP: population or total number of samples per class
    :type POP:dict
    :return: percent chance agreement as float
    """
    try:
        result = 0
        classes = list(P.keys())
        for i in classes:
            pi = ((P[i] + TOP[i]) / (2 * POP[i]))
            result += pi * (1 - pi)
        result = result / (len(classes) - 1)
        return result
    except Exception:
        return "None"