## filter (var* Data, int Length, var Kernel) : var*

Applies a 5-element convolution filter with the given Kernel to the Data array. Each Data element is added to its local neighbors, weighted by the Kernel, using this formula: Data[i] = Kernel*Data[i-2] + Kernel*Data[i-1] + Kernel*Data[i] + Kernel*Data[i+1] + Kernel*Data[i+2] + Kernel.  This function can be used for data smoothing, summing up, subtraction, sharpening, edge enhancement, or similar data array manipulation operations.

### Parameters:

 Data Array or series to be filtered. Length Number of elements to be filtered. Kernel Vector of 5 weights plus constant to be added.

Modified Data

## renorm (var* Data, int Length, var Sum) : var*

Modifies the Data array by multiplying all elements with a factor so that they sum up to Sum. This function can be used to normalize a list of weights to a certain total.

### Parameters:

 Data Array or series to be normalized. Length Number of elements to be normalized. Sum Resulting sum of elements.

Modified Data

### Remarks:

• Use the renorm function on the kernel when the weight sum must be 1.
• For boundary handling, Data and Data[Length-1] are extended.
• Some examples of filter kernels:

 Identity { 0, 0, 1, 0, 0, 0 } Sharpen { -1, -1, 4, -1, -1, 0 } Smooth { 0.2, 0.2, 0.2, 0.2, 0.2, 0 } Gaussian { 0.1, 0.2, 0.4, 0.2, 0.1, 0 } Shift to the right { 0, 1, 0, 0, 0, 0 } Mean subtraction { 0, 0, 1, 0, 0, -mean } Fill with constant { 0, 0, 0, 0, 0, constant }

### Example:

```var* Filter = { 1,2,3,2,1,0 };
filter(Data,Length,renorm(Filter,5,1));```