-1

I have a plot in Matlab where the data points (15 of them) are located with different distances between each other. I have an interval (5 data points, nr 6 to 10) almost in the middle where the data points are a bit closer to each other and where I would like to calculate the weighted average of these.

I have,

y = [1.008;0.989;0.991;0.982;0.992;0.997;0.994;0.998;0.995;1.002;0.998;0.997;1.002;0.994;0.989]
x = [5.2;10.2;15.5;20.7;25.1;25.6;30.6;36.4;39.6;43.7;47.8;52.0;57.6;63.8;68.4]

where I want the interval of data pt 6-10 to be weighted. Is the weight vector for the whole span or just my interval?

Edit; I want to calculate what weight each of these 5 data points (nr 6-10) have.

nilz
  • 1
  • 1
  • 3
    "tips" are too broad, give us a numerical example of your input and the desired output, then we might be able to give you a concrete example of efficient code to achieve it. – Wolfie May 29 '18 at 15:25
  • 3
    Welcome to SO, I would suggest you add what have you done so far to achieve the desired result, that way community will be able to help you. – Vikram Palakurthi May 29 '18 at 15:27
  • How do you want these weighted? "The weighted average" doesn't specify what those weights need to be. This is all up to you and your goal. – Cris Luengo May 29 '18 at 16:30
  • I want to calculate what weight each of these 5 data points (nr 6-10) have. – nilz May 29 '18 at 17:43
  • They can get the weight you want them to have. Do you have a particular application in mind? What is the purpose of the averaging? What is the meaning of the data? There are many things that come into play when deciding on weights. As I said, "this is all up to you and your goal". There is no pre-defined value for weights. – Cris Luengo May 29 '18 at 19:53
  • I want to see the weight of these five points compared to the whole span (15 pts). So I kinda want to measure half the distance between the two points next to each of the five points. Since these 5 points are closer to eachother, a normal average of these cant be compared to the average of the whole span. – nilz May 30 '18 at 07:05
  • **Define the weights**. Give us an actual numerical vector which shows how you want to weight each point. i.e. if you want point 4 to be weighted 5 times 'heavier' than the other points then do `[1 1 1 5 1 1 ....]`. We can't really help with specifics when you "kinda" want to do something. If the weights depend on the values in another vector then define clearly a mathematical relation between the values and the corresponding weights. – Wolfie May 30 '18 at 07:37

1 Answers1

-1

Define a weight vector W such that sum(W) = 1, where W is n-by-1. The weighted mean of the random variable X (which is n-by-1) is equal to dot(W,X)