The definition in the header declares that the guard_cells param is "the number of guard cells on each side of the cell under test," however the current implementation includes one fewer guard cell on each side than that, which also propagates as an incorrect scaling factor: with the off-by-one indexing, the number of cells actually chosen is reference_cells+1. This change makes it match.
The definition in the header declares that the guard_cells param is "the number of guard cells on each side of the cell under test," however the current implementation includes one fewer guard cell on each side than that, which also propagates as an incorrect scaling factor: with the off-by-one indexing, the number of cells actually chosen is reference_cells+1. This change makes it match.