a(n+1) = p * a(n) + (1-p) * (1 - a(n)) / (q - 1)