The QuantEcon libraries already have the tauchen and rouwenhorst methods for discretizing AR(1) processes, reducing them to finite Markov chains. Here’s a more general approach, that could be used for discretizing other state processes.