def combineStat(stat_info):
    """Combine statistical info for the segments or stripes.

    The input is a list of dictionaries.  The output is one dictionary
    with the same keys and with values that are the averages of the input.

    Parameters
    ----------
    stat_info: list of dictionaries
        One dictionary for each segment (FUV) or stripe (NUV).

    Returns
    -------
    dictionary (same keys as an element of input list)
        Contains values for ngoodpix, sci_goodmax, sci_goodmean,
        err_goodmax, err_goodmean; these values are the averages of
        the values in the input.
    """
    if len(stat_info) == 1:
        return stat_info[0]
    sum_n = 0
    sci_max = 0.0
    sci_sum = 0.0
    err_max = 0.0
    err_sum = 0.0
    for stat in stat_info:
        n = stat['ngoodpix']
        if n > 0:
            sum_n += n
            sci_max = max(sci_max, stat['sci_goodmax'])
            sci_sum += n * stat['sci_goodmean']
            if 'err_goodmax' in stat:
                err_max = max(err_max, stat['err_goodmax'])
                err_sum += n * stat['err_goodmean']
    if sum_n > 0:
        sci_sum /= float(sum_n)
        err_sum /= float(sum_n)
    return {'ngoodpix': sum_n, 'sci_goodmax': sci_max, 'sci_goodmean':
        sci_sum, 'err_goodmax': err_max, 'err_goodmean': err_sum}
