def compute_mean_point(particles):
    """
    Compute the mean for all particles that have a reasonably good weight.
    This is not part of the particle filter algorithm but rather an
    addition to show the "best belief" for current position.
    """

    x, m_count = 0, 0
    for p in particles:
        m_count += p.w
        x += p.x * p.w
        # m_y += p.x_right * p.w

    if m_count == 0:
        print("m_count == 0")
        return 0, 1

    x /= m_count
    # m_y /= m_count

    # Now compute how good that mean is -- check how many particles
    # actually are in the immediate vicinity
    m_count = 0
    for p in particles:
        if abs(p.x - x) < 0.5:
            m_count += 1

    return x, (float(m_count) / len(particles))