def mc_sample_path(P, init=0, sample_size=1000, random_state=None):
 random_state = check_random_state(random_state)
 if isinstance(init, numbers.Integral):
  X_0 = init
 else:
  cdf0 = np.cumsum(init)
  u_0 = random_state.random_sample()
  X_0 = searchsorted(cdf0, u_0)
 mc = MarkovChain(P)
 return mc.simulate(ts_length=sample_size, init=X_0, random_state=random_state)

def mc_sample_path ( P , init = 0 , sample_size = 1000 , random_state = None ) : random_state = check_random_state ( random_state ) if isinstance ( init , numbers . Integral ) : X_0 = init else : cdf0 = np . cumsum ( init ) u_0 = random_state . random_sample ( ) X_0 = searchsorted ( cdf0 , u_0 ) mc = MarkovChain ( P ) return mc . simulate ( ts_length = sample_size , init = X_0 , random_state = random_state )
generates one sample path from the markov chain represented by transition matrix p on state space s = {{0 .