def mean_metal_z(z):
    """
    Mean (mass-weighted) metallicity as a function of redshift
    From Madau & Fragos 2017, courtesy of Mike Zevin

    Parameters
    ----------
    z : `float or numpy.array`
        redshift

    Returns
    -------
    Z : `float or numpy.array`
        mean metallicity
    """
    Zsun = 0.017

    log_Z_Zsun = 0.153 - 0.074 * z ** 1.34
    Z = 10 ** log_Z_Zsun * Zsun
    return Z