def PCM_decode(x_bits,N_bits):
N_samples = len(x_bits)//N_bits<EOL>xrs_bits = x_bits.copy()<EOL>xrs_bits = np.reshape(xrs_bits,(N_bits,N_samples),'<STR_LIT:F>')<EOL>xq = np.zeros(N_samples)<EOL>w = <NUM_LIT:2>**np.arange(N_bits-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>) <EOL>for k in range(N_samples):<EOL><INDENT>xq[k] = np.dot(xrs_bits[:,k],w) - xrs_bits[<NUM_LIT:0>,k]*<NUM_LIT:2>**N_bits<EOL><DEDENT>return xq/<NUM_LIT:2>**(N_bits-<NUM_LIT:1>)<EOL>
Parameters
----------
x_bits : serial bit stream of 0/1 values. The length of
         x_bits must be a multiple of N_bits
N_bits : bit precision of PCM samples

Returns
-------
  xhat : decoded PCM signal samples

Mark Wickert, March 2015