def metric_delta_g(entity, schedule):
    """
    Compute the factor ∆g for the current schedule and the reference schedule.

    Parameters
    ----------
    entity : ElectricalEntity
        The Entity to calculate the delta g metric for.
    schedule : str
       Referenced Schedule

       - 'default' : Normal schedule
       - 'ref' : Reference schedule

    Returns
    -------
    float :
        Factor ∆g.

    Notes
    -----
    - Implementation as given in the lecture "Elektrizitaetswirtschaft"
      by Prof. Dr.-Ing. Christian Rehtanz from TU Dortmund, Germany.
    """
    p_el_min_dsm = min(entity.p_el_schedule)
    p_el_max_dsm = max(entity.p_el_schedule)
    p_el_min_ref = min(entity.schedules[schedule]["p_el"])
    p_el_max_ref = max(entity.schedules[schedule]["p_el"])
    g = 1.0 - (abs(p_el_max_dsm - p_el_min_dsm) / abs(p_el_max_ref - p_el_min_ref))
    return g