Reverse calculation for weighted average

75 views (last 30 days)
I need to generate an array of five elements, e.g., [a,b,c,d,e]. The weightage of each of the elements are known, e.g., [5,4,3,2,1]. The weighted average value of that array is known, say 3.09. Also, it is said that the sum of the array elements is 100, i.e., a +b+ c+ d+ e =100.
Is there any way to find out possible values of the array elements a, b, c, d, e ?

Accepted Answer

DGM
DGM on 6 Jun 2021
Edited: DGM on 6 Jun 2021
Let's say we're trying to back calculate x= [a b c d e] that were used to generate the mean and sum. Is there a way to solve for that specific original vector? No. It's an underdetermined linear system; there's not enough information.
For a geometric explanation, consider the number of elements in the array. Say n = 2; x = [a b]. In this case, a unique solution can be found. Each equation defines a locus of possible solutions in a plane. The solution to the problem exists at the point where the two lines intersect.
For n=3; x = [a b c], each equation again describes a locus of possible solutions. This time we have two planes in 3D space. The intersection between two planes is a line. Your original vector is lost in an infinite haystack of vectors that also satisfy the same equations. You'd need more information to reduce it to anything more specific than that.
Someone who remembers their linear algebra can come along and give a more appropriate explanation, but the lazy geometric visualization is what I'm rolling with.
Are there ways to find one of those infinitely many solutions? Sure.
wm = [5 4 3 2 1];
ws = [1 1 1 1 1];
m = 3.09;
s = 100;
A = [wm; ws];
b = [m; s];
x = A\b
% does x satisfy the given equations?
A*x-b
I imagine there are other ways if other constraints exist.

More Answers (0)

Categories

Find more on Programming 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!