def update(self, psd_state, samples_array):
freq_array, pwr_array = simplespectral.welch(samples_array, self._sample_rate, nperseg=self._bins,<EOL>window=self._fft_window, noverlap=self._fft_overlap_bins,<EOL>detrend=self._detrend)<EOL>if self._remove_dc:<EOL><INDENT>pwr_array[<NUM_LIT:0>] = (pwr_array[<NUM_LIT:1>] + pwr_array[-<NUM_LIT:1>]) / <NUM_LIT:2><EOL><DEDENT>with psd_state['<STR_LIT>']:<EOL><INDENT>psd_state['<STR_LIT>'] += <NUM_LIT:1><EOL>if psd_state['<STR_LIT>'] is None:<EOL><INDENT>psd_state['<STR_LIT>'] = pwr_array<EOL><DEDENT>else:<EOL><INDENT>psd_state['<STR_LIT>'] += pwr_array<EOL><DEDENT><DEDENT>
Compute PSD from samples and update average for given center frequency