Code found in DSP Guide book in Python