Dividing a Number with a Vector Results in a new Vector with wrong mean

2 次查看(过去 30 天)
Hey All,
I have an interesting problem;
I have a vector (VectorInitial). I want to calculate another vector (VectorTarget) with the same size such that the elements in VectorTarget(i)=60/VectorInitial(i).
I have tried several ways;
VectorTarget = rdivide(60,VecInitial)
VectorTarget = 60./VectorInitial
Writing a for loop to go through all the elements and divide 60 by each element 1 by 1 and write it into a new vector.
All of these methods create the same VectorTarget as expectedly. However there is a huge problem.
In my case the mean(VectorInitial) = 25.0192
60/25.0192 = 2.3982
One would expect mean(VectorTarget) to be 2.3982
However mean(VectorTarget) = 2.4863
I am really baffled as to why this is happening. Any suggestions would be highly appreciated.

采纳的回答

Luna
Luna 2019-5-30
编辑:Luna 2019-5-30
Because they are not equal mathematically.
Suppose that:
VectorInit = [a,b,c]
meanVectorInit = (a+b+c)/3
VectorTarget = [60/a,60/b,60/c]
meanVectorTarget = (60/a+60/b+60/c)/3 = 20/a + 20/b + 20/c
Then check;
60/meanVectorInit = 60/( (a+b+c)/3 ) = 180/(a+b+c)
So;
20/a + 20/b + 20/c ~= 180/(a+b+c) -> they are not always equal. Depends on what a,b,c is.
meanVectorTarget ~= 60/meanVectorInit
I recommend you to do the symbolic math operations on a paper with your hand, you will see they are not equal.
  2 个评论
Ferhat Buke
Ferhat Buke 2019-5-30
You are right and I feel kind of stupid.
I am working with a large dataset where it would make a lot of sense for the value to be closer to 2.4 than it would be to 2.5.
I see now that for this to work, the spread around the average cannot be a normal distribution. You need a distribution heavier on one side with a longer tail on the other side.
Thanks a lot!!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by