def calc_cpi(base_cpi, mix, miss_rates, penalties):
    """
    Compute the CPI using the miss_rates and penalties.
    """
    penalty_per_memaccess = penalties[0]
    for mp, mr in zip(penalties[1:], miss_rates):
        penalty_per_memaccess += mp * mr
    return base_cpi + mix * penalty_per_memaccess
