Algorithm 2. IAD Calculation. |
1: function IADCalc(indexVals[[], windowStart) |
2: for j between 30 and (indexVals.size-60) do |
3: maxAbsDiff = 0 |
4: left = 0 |
5: right = 0 |
6: avgLeft = average value of all Index values before j |
7: avgRight = average value of all Index values after j+30 |
8: diff = ABS(avgRight–avgLeft) |
9: if diff ≥ maxAbsDiff then |
10: maxAbsDiff 0 diff |
11: left = avgLeft |
12: right = avgRight |
13: windowStart = j |
14: end if |
15: end for |
16: lowestVal = getLowestVal(indexVals) |
17: movedZero = lowestVal–0.01*lowestVal |
18: absDiff = ABS(right–left)/MIN(left–movedZero, right–movedZero) |
19: if absDiff ≥ 5.0 then invAbsDiff = 1/absDiff |
20: else if absDiff ≥ 1.0 then invAbsDiff = 10/absDiff |
21: else if absDiff ≥ 0.5 then invAbsDiff = 100/absDiff |
22: else invAbsDiff = 1000 |
23: end if |
24: return invAbsDiff |
25: end function |