def fit(self, x):
    'Fit a Markov model from data via MLE or MAP.\n\n        Attributes\n        ----------\n        x : ndarray[int]\n            Observed data\n\n        Returns\n        -------\n        %(_doc_default_callparams)s\n\n        '
    nstates = nunique(x.ravel())
    pi_pseudo_counts = np.ones(nstates)
    transmat_pseudo_counts = np.ones((nstates, nstates))
    n = x.shape[0]
    startprob = ((normalize(np.bincount(x[:, 0])) + pi_pseudo_counts) - 1)
    counts = np.zeros((nstates, nstates))
    for i in range(n):
        counts += accum(np.vstack([x[i, 0:(- 1)], x[i, 1:]]).T, 1, size=(nstates, nstates))
    transmat = normalize(((counts + transmat_pseudo_counts) - 1), 1)
    return (startprob, transmat)
Fit a Markov model from data via MLE or MAP.

Attributes
----------
x : ndarray[int]
    Observed data

Returns
-------
%(_doc_default_callparams)s
def fit(self, x):
    'Fit a Markov model from data via MLE or MAP.\n\n        Attributes\n        ----------\n        x : ndarray[int]\n            Observed data\n\n        Returns\n        -------\n        %(_doc_default_callparams)s\n\n        '
    nstates = nunique(x.ravel())
    pi_pseudo_counts = np.ones(nstates)
    transmat_pseudo_counts = np.ones((nstates, nstates))
    n = x.shape[0]
    startprob = ((normalize(np.bincount(x[:, 0])) + pi_pseudo_counts) - 1)
    counts = np.zeros((nstates, nstates))
    for i in range(n):
        counts += accum(np.vstack([x[i, 0:(- 1)], x[i, 1:]]).T, 1, size=(nstates, nstates))
    transmat = normalize(((counts + transmat_pseudo_counts) - 1), 1)
    return (startprob, transmat)