Find the RMS from a PSD

I think this was a bug in the PSD function in matplotlib 0.98.1 (Debian lenny). This was making me crazy.

I took newer source code of this function from the project and all is going well.

So to get the RMS power from PSD :

y, x = pylab.psd(data, NFFT = nfft, Fs = samplerate)

freqbandwith = x[1]

y = y*freqbandwith

rms = scipy.sqrt(y.sum())

It should be the same as :

rms = data**2

rms = scipy.sqrt(rms.sum()/len(data))