'Transform unconstrained parameters used by the optimizer to constrained
parameters used in likelihood evaluation
Parameters
unconstrained : array_like
Array of unconstrained parameters used by the optimizer, to be
transformed.
Returns
constrained : array_like
Array of constrained parameters which may be used in likelihood
evalation.
Notes
In the base class, this only transforms the transition-probability-
related parameters.'

def transform_params(self, unconstrained):

    constrained = np.array(unconstrained, copy=True)
    constrained = constrained.astype(np.promote_types(np.float64, constrained.dtype))
    if self.tvtp:
        constrained[self.parameters['regime_transition']] = unconstrained[self.parameters['regime_transition']]
    else:
        for i in range(self.k_regimes):
            tmp1 = unconstrained[self.parameters[(i, 'regime_transition')]]
            tmp2 = np.r_[(0, tmp1)]
            constrained[self.parameters[(i, 'regime_transition')]] = np.exp((tmp1 - logsumexp(tmp2)))
    return constrained
