def h(x, fx):
    """helper function as in the PLoS article, doi:10.1371/journal.pcbi.1005352.t003 pg 16/24"""
    fx = fx % 3
    x = x % 3
    if fx > x:
        return x + 1
    elif fx < x:
        return x - 1
    else:
        return x