Closed josoriom closed 11 months ago
@lpatiny I found a function (xSampling) in this package that performs down-sampling
I would like you add the following test case (and I'm not convinced about the current result). Not sure what you expect the algorithm to do.
xSampling([0], { length: 2 }); xSampling([1, 2], { length: 3 }); xSampling([1, 2], { length: 5 }); xSampling([1, 2, 3], { length: 5 }); xSampling([1, 2, 4], { length: 5 }); xSampling([1, 2, 4], { length: 7 }); xSampling([1, 2, 3], { length: 4 }); xSampling([1, 2, 4], { length: 4 }); xSampling([1, 2, 1], { length: 4 }); xSampling([1, 2, -1], { length: 5 });
Do you have a reference link to the current implementation because the results seems difficult to justify.
Defining the step size was where I made the mistake. The source from wikipedia Linear interpolation
$$ y = y_0 \cdot \left(1 - \frac{x - x_0}{x_1 - x_0}\right) + y_1 \cdot \frac{x - x_0}{x_1 - x_0} $$
result[i] = array[floor] * (1 - diff) + array[ceil] * diff;
where
let diff = currentIndex - floor;
and
ceil - floor = 1
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Additional details and impacted files
```diff @@ Coverage Diff @@ ## main #200 +/- ## ========================================== + Coverage 91.69% 91.70% +0.01% ========================================== Files 168 168 Lines 3286 3305 +19 Branches 824 824 ========================================== + Hits 3013 3031 +18 - Misses 266 267 +1 Partials 7 7 ```:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.