Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Zuguang,
I made two commits. Please have a look at the explanations below. If I missed something why this is not the case please let me know!
The first one:
Correct me when I got it wrong, but as far as I understand currently the formula will calculate a weight of zero for the last window of the target (and also slightly too low for the upper half of the target. The error is small for a large number of target windows, but increases with a smaller number of target windows.
The second one (on top):
In the current version, the if-statements don't seem to fit for me.
First, I think instead of checking the target section n2, it looks like n3 should be checked when I look at what is calculated in each case.
Second, checking the length of n, which is calculated above as the length of x doesn't make sense since this will always give an integer > 0 and therefore will always be true.
In fact, since x1, x2 and x3 are set to an empty matrix anyway in the normalizeToMatrix function you can also instead of correcting the points above just always calculate the whole formula and if up/downstream or target vector is empty it will be zero in the sum and thus not change the result.