def stddev(w, axis=-1): """Calculate the standard deviation Returns the standard deviation over the highest dimension, a measure of the spread of a distribution. Example: >>> w1=Waveform([range(2), range(4)], array([[1,2,3,4],[1,1,1,1]])) >>> stddev(w1) Waveform(array([0, 1]), array([ 1.11803399, 0. ])) """ return reducedim(w, np.std(w._y, axis=w.getaxis(axis)), axis=w.getaxis(axis))
def average(w, axis=-1): """Calculate average Example: >>> w1=Waveform([range(2), range(2)],array([[1.0, 3.0], [0.0, 5.0]])) >>> average(w1) Waveform(array([0, 1]), array([ 2. , 2.5])) >>> w1=Waveform([range(2), range(2)],array([[1.0, 3.0], [0.0, 5.0]]), \ xlabels=['row','col']) >>> average(w1, axis='row') Waveform(array([0, 1]), array([ 0.5, 4. ])) """ return reducedim(w, np.mean(w._y, axis=w.getaxis(axis)), axis=w.getaxis(axis))
def rms(w, axis=-1): """Calculate root-mean-square""" return reducedim(w, sqrt(np.mean(w._y**2, axis=w.getaxis(axis))), axis=w.getaxis(axis))