34 std::vector<float>
TimeSeriesUtils::Resample(
const std::vector<float>& timestamps,
const std::vector<float>&
data,
const std::vector<float>& newTimestamps)
38 std::vector<float> result;
39 result.reserve(
data.size());
47 result.push_back(
data.at(0));
54 while (j <
data.size())
56 while (newTimestamps.at(j) > timestamps.at(i + 1) && i <
data.size() - 2)
70 std::vector<float> result;
71 size_t start = filter.size() / 2;
72 for (
size_t i = start; i <
data.size() + start; i++)
76 for (
size_t j = 0; j < filter.size(); j++)
78 int k = (int)i - (
int)j;
83 if (k >= (
int)
data.size())
87 y +=
data.at(k) * filter.at(j);
90 result.push_back(w == 0 ? 0 : y / w);
104 std::vector<float> filter;
105 int range = (int)(truncate * sigma / sampleTime);
106 for (
int i = -range; i <= range; i++)
108 float x = i * sampleTime;
109 filter.push_back(exp(-x * x / (2 * sigma * sigma) / (sigma *
sqrt(2 *
M_PI))));
116 std::vector<float> result;
117 for (
size_t i = 0; i < count; i++)
119 result.push_back(
MathUtils::Lerp(start, end, (
float)i / (
float)(count - 1)));