Simplify and remove magic numbers from the i/2 bit by treating time since last change of state as another timeslice. Also return a float between 0 and 1, not a string between "0" and "100".