country_percentile_linear_interp_cdf_database_querier.py
def linear_interpolate_cdf(base_cdf):
    """Linear interpolate regions of straight lines in the CDF.

    Parameters:
        base_cdf (list): n elements of non-decreasing order.

    Returns:
        list of length base_cdf where consecutive elements of straight lines
        are linearly interpolated between the left and right sides.

    """
    target_cdf = list(base_cdf)
    index = 0
    left_val = 0
    while index < len(base_cdf)-1:
        if base_cdf[index] == base_cdf[index+1]:
            # search for where it ends
            offset = index+1
            while (offset < len(base_cdf)-1 and
                   base_cdf[offset] == base_cdf[offset+1]):
                offset += 1
            # linearly interpolate between index and offset
            right_val = base_cdf[offset]
            interp_val = numpy.interp(
                list(range(index, offset+1, 1)),
                [index-1, offset],
                [float(left_val), float(right_val)])
            target_cdf[index:offset+1] = interp_val
            left_val = right_val
            index = offset+1
        else:
            left_val = base_cdf[index]
            index += 1
    return target_cdf
Linear interpolate regions of straight lines in the CDF.

    Parameters:
        base_cdf (list): n elements of non-decreasing order.

    Returns:
        list of length base_cdf where consecutive elements of straight lines
        are linearly interpolated between the left and right sides.

    
Linear interpolate regions of straight lines in the CDF.
Linear interpolate regions of straight lines in the CDF .
def linear_interpolate_cdf(base_cdf):
    target_cdf = list(base_cdf)
    index = 0
    left_val = 0
    while index < len(base_cdf)-1:
        if base_cdf[index] == base_cdf[index+1]:
            offset = index+1
            while (offset < len(base_cdf)-1 and
                   base_cdf[offset] == base_cdf[offset+1]):
                offset += 1
            right_val = base_cdf[offset]
            interp_val = numpy.interp(
                list(range(index, offset+1, 1)),
                [index-1, offset],
                [float(left_val), float(right_val)])
            target_cdf[index:offset+1] = interp_val
            left_val = right_val
            index = offset+1
        else:
            left_val = base_cdf[index]
            index += 1
    return target_cdf
def linear_interpolate_cdf ( base_cdf ) : target_cdf = list ( base_cdf ) index = 0 left_val = 0 while index < len ( base_cdf ) - 1 : if base_cdf [ index ] == base_cdf [ index + 1 ] : offset = index + 1 while ( offset < len ( base_cdf ) - 1 and base_cdf [ offset ] == base_cdf [ offset + 1 ] ) : offset += 1 right_val = base_cdf [ offset ] interp_val = numpy . interp ( list ( range ( index , offset + 1 , 1 ) ) , [ index - 1 , offset ] , [ float ( left_val ) , float ( right_val ) ] ) target_cdf [ index : offset + 1 ] = interp_val left_val = right_val index = offset + 1 else : left_val = base_cdf [ index ] index += 1 return target_cdf
Linear interpolate regions of straight lines in the CDF.
Linear interpolate regions of straight lines in the CDF .
"""Linear interpolate regions of straight lines in the CDF.

    Parameters:
        base_cdf (list): n elements of non-decreasing order.

    Returns:
        list of length base_cdf where consecutive elements of straight lines
        are linearly interpolated between the left and right sides.

    """ # search for where it ends # linearly interpolate between index and offset
list of length base_cdf where consecutive elements of straight lines
are linearly interpolated between the left and right sides.
list of length base_cdf where consecutive elements of straight lines are linearly interpolated between the left and right sides .
base_cdf
n elements of non-decreasing order.
n elements of non - decreasing order .