def METHOD_NAME(x_data,y_data,moving_average = 2, plot_res = False):
    '''
    finds the initial values for a lorentzian dip or peak
    p[0] = x0
    p[1] = 2*HM dip height
    p[2] = dx width
    p[3] = y0 offset
    '''
    p=4*[0]
    diffy = mva.movingaverage(diff(y_data),moving_average)
    if plot_res:
        pl = plot(name='find_resonance')
        pl.clear()
        plot(diffy,title='moving_average of diff_y',name='find_resonance')
        plot(y_data,title='y_data',name='find_resonance')
    dymax = max(diffy)
    i_dymax = diffy.tolist().index(dymax)
    dymin = min(diffy)
    i_dymin = diffy.tolist().index(dymin)
    if i_dymin>i_dymax:
        '''
        means its a peak
        '''
        peak = 1
        y0 = min(y_data)
    else:
        '''
        means its a dip
        '''
        peak = -1
        y0 = max(y_data)
    dx = abs(x_data[i_dymin] - x_data[i_dymax])
    x0 = (x_data[i_dymin] + x_data[i_dymax])/2
    HM = peak*abs(y_data[i_dymax] - y_data[floor((i_dymin+i_dymax)/2)])
    p[0] = x0
    p[1] = 2*HM
    p[2] = dx
    p[3] = y0
    return p