def get_denom_val(stat_date, denom_data):
    """ Gets the best denominator value for a given date

    Args:
        stat_date: date as a string
        denom_data: dict of date to value

    Returns:
        the value from denom_data that best matches the stat_date
    """
    denom_dates = denom_data.keys()
    if len(denom_dates) == 0:
        return None
    if stat_date in denom_dates:
        return denom_data[stat_date]
    encompassed_denom_dates = list(filter(lambda x: stat_date in x,
                                          denom_dates))
    if len(encompassed_denom_dates) > 0:
        return denom_data[encompassed_denom_dates[-1]]
    denom_date = list(denom_dates)[0]
    for date in denom_dates:
        if date < stat_date and date > denom_date:
            denom_date = date
    return denom_data[denom_date]