def calcUpdrsRating(amplitude, totalAmplitudeError):
    """
    Converts an amplitude measurement (in cm) into an MDS-UPDRS rating.
    """

    # n.b. the first value is 0.01, not 0, to account for floating-point error.
    # The error is subtracted from amplitude for the first classification,
    # otherwise a UPDRS rating of 0 would realistically never be returned:
    if (amplitude - totalAmplitudeError) <= 0.01:
        return 0
    elif amplitude < 1:
        return 1
    elif amplitude < 3:
        return 2
    elif amplitude < 10:
        return 3
    else:
        return 4