def add_cp(results, nodes, probabilities):
    """
    Add the F-N cumulative frequency.

    See equation (1) from Oughton et al. 2019.

    Parameters
    ----------
    results : list of dicts
        All iterations generated in the simulation function.
    nodes : int
        Number of substations for the scenario.
    probabilities : list
        Contains the cumulative probabilities we wish to use.

    Returns
    -------
    output : list of dicts
        Contains all generated results.

    """
    output = []

    results = sorted(
        results,
        reverse=True,
        key=lambda k: k['population']
    )

    rank = 1

    for item in results:

        if not item['nodes'] == nodes:
            continue

        item['rank'] = rank
        item['cum_probability'] = round(rank / (len(results) / len(probabilities) + 1), 3)

        output.append(item)

        rank += 1

    return output