Skip to main content
. 2026 Sep 9;26(18):5727. doi: 10.3390/s26185727
Algorithm 2 Adaptive Runtime Defense Monitor
  •   1:

    Input: query x, baseline distribution q, threshold τ, window size n

  •   2:

    State: query window W←∅, defense level L←0

  •   3:

    Add x to W

  •   4:

    if |W|≥n then

  •   5:

            Compute p(t) from W

  •   6:

            Compute Dt using Equation (5)

  •   7:

            if Dt>τ then

  •   8:

                    L←1

  •   9:

                    Apply output rounding and rate limit

  • 10:

            else

  • 11:

                    L←0

  • 12:

            end if

  • 13:

            Clear W

  • 14:

    end if

  • 15:

    return model output at defense level L