Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Group: Matrix Manipulation
Topic: Sorting and Counting
See also: mknn

Function: knn
Description: computes a running mean over (2k+1) consecutive values of a given vector. To have the same length at the beginning and at the end the first and last value are repeated k times.

Usage: m = knn (x, k)
x n vector of the obervations
k scalar range of the running mean
m n vector containing the smoothed values

knn(uniform(8), 2)

Contents of knn

[1,]  0.25989
[2,]  0.25989
[3,]  0.25989
[4,]  0.28321
[5,]  0.28438
[6,]  0.31511
[7,]  0.31511
[8,]  0.31511

(C) MD*TECH Method and Data Technologies, 05.02.2006