How to calculate the weighted mean?

2 views (last 30 days)
Max Blanck
Max Blanck on 31 Mar 2016
Hello
I have problems calculating a weighted mean. Let me introduce the background first. I'm implementing a missing value imputation method in the machine learning domain. As a reference I'm using the knnimpute method from Matlab. In the documentation it is written:
knnimpute(Data, k) replaces NaNs in Data with a weighted mean of the k nearest-neighbor columns. The weights are inversely proportional to the distances from the neighboring columns.
Let's say I have a data point x and I'm calculating the nearest neighbours:
[IDX,D] = knnsearch(x,Y,'K',5);
x is 1xD and Y is NxD.
How can I now calculate the weighted mean with weights proportional to the distances?
  1 Comment
Muhammad Usman Saleem
Muhammad Usman Saleem on 1 Apr 2016
Tell me what kind of data set you are using ? Geographicb or other? Also tell me what is the dimension of your data whether it is in 1,2, dimension and nan values are in sequence or random?

Sign in to comment.

Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!