def walsh_iob_curve(t, insulin_action_duration):
    """Returns the fraction of a single insulin dosage remaining at the specified number of minutes
    after delivery; also known as Insulin On Board (IOB).

    This is a Walsh IOB curve, and is based on an algorithm that first appeared in GlucoDyn

    See: https://github.com/kenstack/GlucoDyn

    :param t: time in minutes since the dose began
    :type t: float
    :param insulin_action_duration: The duration of insulin action (DIA) of the patient, in minutes
    :type insulin_action_duration: int
    :return: The fraction of a insulin dosage remaining at the specified time
    :rtype: float
    """
    iob = 0
    if t >= insulin_action_duration:
        iob = 0.0
    elif t <= 0:
        iob = 1.0
    elif insulin_action_duration == 180:
        iob = (-3.203e-09 * t ** 4 + 1.354e-06 * t ** 3 - 0.0001759 * t ** 
            2 + 0.0009255 * t + 0.99951)
    elif insulin_action_duration == 240:
        iob = (-3.31e-10 * t ** 4 + 2.53e-07 * t ** 3 - 5.51e-05 * t ** 2 -
            0.0009086 * t + 0.9995)
    elif insulin_action_duration == 300:
        iob = (-2.95e-10 * t ** 4 + 2.32e-07 * t ** 3 - 5.55e-05 * t ** 2 +
            0.000449 * t + 0.993)
    elif insulin_action_duration == 360:
        iob = (-1.493e-10 * t ** 4 + 1.413e-07 * t ** 3 - 4.095e-05 * t ** 
            2 + 0.0006365 * t + 0.997)
    return iob
