Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calculation of gap thresholds #408

Merged
merged 1 commit into from
Oct 10, 2024
Merged

Fix calculation of gap thresholds #408

merged 1 commit into from
Oct 10, 2024

Conversation

kaituo
Copy link
Collaborator

@kaituo kaituo commented Oct 9, 2024

Issue #, if available:

Description of changes:
In the calculation of gapLow[y] and gapHigh[y], the expressions for the ratio-based thresholds were incorrectly using Math.abs(a) where a = scale[y] * point[startPosition + y]. Since point[startPosition + y] is the normalized value (x - mean) / std, multiplying by scale[y] (which is std) gives (x - mean).

However, to accurately compute the thresholds based on the actual value x, we need to add back the mean (shiftBase). Therefore, (a + shiftBase) equals (x - mean) + mean = x.

The corrected code now uses Math.abs(a + shiftBase). Read changes in PredictorCorrector for details.

Testing done:

  1. added an IT.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kaituo kaituo requested a review from greaa-aws October 9, 2024 23:10
…ratio computations

In the calculation of `gapLow[y]` and `gapHigh[y]`, the expressions for the ratio-based thresholds were incorrectly using `Math.abs(a)` where `a = scale[y] * point[startPosition + y]`. Since `point[startPosition + y]` is the normalized value `(x - mean) / std`, multiplying by `scale[y]` (which is `std`) gives `(x - mean)`.

However, to accurately compute the thresholds based on the actual value `x`, we need to add back the mean (`shiftBase`). Therefore, `(a + shiftBase)` equals `(x - mean) + mean = x`.

The corrected code now uses `Math.abs(a + shiftBase)` in PredictorCorrector.

Testing done:
1. added a IT.

Signed-off-by: Kaituo Li <[email protected]>
@kaituo kaituo merged commit 35f4cf6 into aws:main Oct 10, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants