Skip to content

Instantly share code, notes, and snippets.

@awade
Created December 5, 2018 03:44
Show Gist options
  • Save awade/5c9de7836ba80021e3ed80d9e2801b14 to your computer and use it in GitHub Desktop.
Save awade/5c9de7836ba80021e3ed80d9e2801b14 to your computer and use it in GitHub Desktop.
Python function for computing rms integral from high frequency to low frequency
import numpy as np
'''
Find the rms value of y(x). Here y(f) could be a spectral density or y(t) could be a time series
usage:
rms_of_y = rms(X,Y);
'''
def rms(x, y):
diff = np.diff(np.squeeze(x))
dx = np.concatenate(([diff[0]], diff), axis=0)
# Return rms intergrated from high to low
rms = np.flipud(np.sqrt(np.cumsum(np.flipud(np.squeeze(y)**2 * dx))))
return rms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment