Skip to main content
. 2021 Oct 19;21(20):6932. doi: 10.3390/s21206932
Algorithm 3. Oscillation Calculation.
1: function OscillationCalc(indexVals[[], windowStart, winSize)
2:  lowestVal = getLowestVal(indexVals)
3:   movedZero = lowestVal–0.01*lowestVal
4:   oscillation = 0
5:   for i between 1 and windowStart–1 do
6:    absDiff = ABS((indexVals[i]-indexVals[i-1])/(indexVals[i-1] -movedZero))
7:    if absDiff ≥ 5.0 then oscillation += 1000
8:    else if absDiff ≥ 1.0 then oscillation += 100
9:    else if absDiff ≥ 0.5 then oscillation += 10
10:    else if absDiff ≥ 0.25 then oscillation += 1
11:    end if
12:   end for
13:   for i between windowStart+winSize and indexVals.size()-1 do
14:    absDiff = ABS((indexVals[i]-indexVals[i-1])/(indexVals[i-1] -movedZero))
15:    if absDiff ≥ 5.0 then oscillation += 1000
16:     else if absDiff ≥ 1.0 then oscillation += 100
17:     else if absDiff ≥ 0.5 then oscillation += 10
18:    else if absDiff ≥ 0.25 then oscillation += 1
19:    end if
20:   end for
21:   return oscillation
22: end function