def percent_at_home(positions, user):
    """
    The percentage of interactions the user had while he was at home.

    .. note::
        The position of the home is computed using
        :meth:`User.recompute_home <bandicoot.core.User.recompute_home>`.
        If no home can be found, the percentage of interactions at home
        will be ``None``.
    """

    if not user.has_home:
        return None

    total_home = sum(1 for p in positions if p == user.home)
    return float(total_home) / len(positions) if len(positions) != 0 else 0
The percentage of interactions the user had while he was at home.

    .. note::
        The position of the home is computed using
        :meth:`User.recompute_home <bandicoot.core.User.recompute_home>`.
        If no home can be found, the percentage of interactions at home
        will be ``None``.