--[[ ======================================== SMOOTH SIGNAL (Average Filter) ======================================== PURPOSE: Reduces noise by averaging values. LOGIC: Each output = average of all previous values EXAMPLE: Input: [10, 20, 30] Output: [10, 15, 20] USER ACTION: No mandatory changes required. Optional: Modify averaging logic inside loop if needed. ======================================== ]] function SmoothSignal(input) if input == nil then return {} end local output = {} for tag = 1, 10 do local key = tostring(tag) local inVec = input[key] if type(inVec) == "table" then local outVec = {} local sum = 0 for i, v in ipairs(inVec) do sum = sum + (v.value or 0) -- Optional user modification area local avg = sum / i table.insert(outVec, { value = avg, quality = v.quality or 0, timestamp = v.timestamp or 0 }) end output[key] = outVec end end return output end