classifiers/hand_movement_classifier.py
def compute_rolling_mean(x, window_length):
    '''
    Method to compute rolling mean.
    :param x: 1D numpy array
    :param window_length: Length of window for computing rolling mean. Must be an odd number.
    :return: Numpy array with rolling mean values calculated over given window length.
    '''
    if window_length % 2 == 0:
        print "Window length should be an odd number."
        return

    y = np.zeros(len(x))
    for i in range(len(x)):
        if i < window_length/2:
            y[i] = np.mean(x[0:i + window_length / 2])
        elif len(x) - i < window_length / 2:
            y[i] = np.mean(x[i - window_length / 2:])
        else:
            y[i] = np.mean(x[i - window_length / 2: i + window_length / 2])

    return y

    Method to compute rolling mean.
    :param x: 1D numpy array
    :param window_length: Length of window for computing rolling mean. Must be an odd number.
    :return: Numpy array with rolling mean values calculated over given window length.
    
Method to compute rolling mean.
Method to compute rolling mean .
def compute_rolling_mean(x, window_length):
    if window_length % 2 == 0:
        print "Window length should be an odd number."
        return
    y = np.zeros(len(x))
    for i in range(len(x)):
        if i < window_length/2:
            y[i] = np.mean(x[0:i + window_length / 2])
        elif len(x) - i < window_length / 2:
            y[i] = np.mean(x[i - window_length / 2:])
        else:
            y[i] = np.mean(x[i - window_length / 2: i + window_length / 2])
    return y
def compute_rolling_mean ( x , window_length ) : if window_length % 2 == 0 : print "Window length should be an odd number." return y = np . zeros ( len ( x ) ) for i in range ( len ( x ) ) : if i < window_length / 2 : y [ i ] = np . mean ( x [ 0 : i + window_length / 2 ] ) elif len ( x ) - i < window_length / 2 : y [ i ] = np . mean ( x [ i - window_length / 2 : ] ) else : y [ i ] = np . mean ( x [ i - window_length / 2 : i + window_length / 2 ] ) return y
Method to compute rolling mean.
Method to compute rolling mean .
'''
    Method to compute rolling mean.
    :param x: 1D numpy array
    :param window_length: Length of window for computing rolling mean. Must be an odd number.
    :return: Numpy array with rolling mean values calculated over given window length.
    '''
Numpy array with rolling mean values calculated over given window length.
Numpy array with rolling mean values calculated over given window length .
x
1D numpy array
1D numpy array
window_length
Length of window for computing rolling mean. Must be an odd number.
Length of window for computing rolling mean . Must be an odd number .