Synthesis of spectral densities using finite automata