See discrete-time-and-state-Markov.pdf for notes and background information. See the missing data version here

Simulation:

True color switch probability =
# samples per button click:
Simulate:        
Simulated data (n = 0):

Inferential stats:

n - 1 = 0 # observed transitions
nd = 0 number of color changes
ns = 0 # adjacent samples with same color
ŝ = ? estimate of the switch probability

Ln Likelihood