def sample(transition_matrix, means, covs, start_state, n_samples, random_state):
    (n_states, n_features, _) = covs.shape
    states = np.zeros(n_samples, dtype='int')
    emissions = np.zeros((n_samples, n_features))
    for i in range(n_samples):
        if (i == 0):
            prev_state = start_state
        else:
            prev_state = states[(i - 1)]
        state = random_state.choice(n_states, p=transition_matrix[:, prev_state])
        emissions[i] = random_state.multivariate_normal(means[state], covs[state])
        states[i] = state
    return (emissions, states)
def sample(transition_matrix, means, covs, start_state, n_samples, random_state):
    (n_states, n_features, _) = covs.shape
    states = np.zeros(n_samples, dtype='int')
    emissions = np.zeros((n_samples, n_features))
    for i in range(n_samples):
        if (i == 0):
            prev_state = start_state
        else:
            prev_state = states[(i - 1)]
        state = random_state.choice(n_states, p=transition_matrix[:, prev_state])
        emissions[i] = random_state.multivariate_normal(means[state], covs[state])
        states[i] = state
    return (emissions, states)