def tauchen(rho, sigma_u, m=3, n=7):
 std_y = np.sqrt(((sigma_u ** 2) / (1 - (rho ** 2))))
 x_max = (m * std_y)
 x_min = (- x_max)
 x = np.linspace(x_min, x_max, n)
 step = ((x_max - x_min) / (n - 1))
 half_step = (0.5 * step)
 P = np.empty((n, n))
 _fill_tauchen(x, P, n, rho, sigma_u, half_step)
 mc = MarkovChain(P, state_values=x)
 return mc

def tauchen ( rho , sigma_u , m = 3 , n = 7 ) : std_y = np . sqrt ( ( ( sigma_u ** 2 ) / ( 1 - ( rho ** 2 ) ) ) ) x_max = ( m * std_y ) x_min = ( - x_max ) x = np . linspace ( x_min , x_max , n ) step = ( ( x_max - x_min ) / ( n - 1 ) ) half_step = ( 0.5 * step ) P = np . empty ( ( n , n ) ) _fill_tauchen ( x , P , n , rho , sigma_u , half_step ) mc = MarkovChain ( P , state_values = x ) return mc
computes a markov chain associated with a discretized version of the linear gaussian ar(1) process y_{t+1} = rho * y_t + u_{t+1} using tauchens method .