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

4 vues (au cours des 30 derniers jours)
Ferhat Buke
Ferhat Buke le 30 Mai 2019
Commenté : Luna le 30 Mai 2019
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.

Réponse acceptée

Luna
Luna le 30 Mai 2019
Modifié(e) : Luna le 30 Mai 2019
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 commentaires
Ferhat Buke
Ferhat Buke le 30 Mai 2019
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 le 30 Mai 2019
Your welcome :)

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by