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

2 ビュー (過去 30 日間)
Ferhat Buke
Ferhat Buke 2019 年 5 月 30 日
コメント済み: Luna 2019 年 5 月 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!!
Luna
Luna 2019 年 5 月 30 日
Your welcome :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by