def getHull(x_data, y_data):
    """
    Get Hull from histogram
    :param x_data: x values of the histogram (list)
    :param y_data: y values of the histogram (list)
    :return: x and y values of hull (list)
    """
    xhull = []
    yhull = []
    if len(x_data) == 0 or len(y_data) == 0:
        return xhull, yhull
    xhull.append(x_data[0])
    yhull.append(y_data[0])
    lasthullindex = 0
    points = len(y_data)
    while lasthullindex < points - 1:
        slope = (y_data[lasthullindex + 1] - y_data[lasthullindex]) / (x_data
            [lasthullindex + 1] - x_data[lasthullindex])
        currenthullindex = lasthullindex + 1
        currenthully = y_data[lasthullindex]
        for i in range(currenthullindex + 1, points):
            extrapolation = currenthully + slope * (x_data[i] - x_data[
                lasthullindex])
            if y_data[i] < extrapolation:
                slope = (y_data[i] - y_data[lasthullindex]) / (x_data[i] -
                    x_data[lasthullindex])
                currenthullindex = i
        xhull.append(x_data[currenthullindex])
        yhull.append(y_data[currenthullindex])
        lasthullindex = currenthullindex
    return xhull, yhull
