from weighted average to single values

9.5k Views Asked by At

think about when you're computing a weighted average: you do something like

W = sum(amount*weight) / sum(weight)

Now I need to find every amount (amount0, amount1.....) starting from knowing the value of W and every single weight. Is this possible? I'm trying to find out an algorithm.

Thanks in advance

2

There are 2 best solutions below

2
On

It corresponds to $$w_1x+w_2y+...+w_Nz=W$$ with known coefficients $w_i$. Given W and $w_i$, clearly there is no unique solution for this system but multiple solutions..

0
On

As others have remarked, this is impossible. However if we are given a number of weighted averages, and the weights used to calculate each average, then we may be able to determine the original values. In general though we will need lots of weights to find the values, so it's really only an academic exercise.

So suppose there are $n$ values $a_1, ... , a_n$ that we want to find. We are given $m$ weighted averages: $$ w_{11} a_1 + ... + w_{1n} a_n = W_1 \\ w_{21} a_1 + ... + w_{2n} a_n = W_2 \\ ...\\ w_{m1} a_1 + ... + w_{mn} a_n = W_m $$ First we require $m$ to be at least as large as $n$. We can write this in matrix form: $$ \begin{pmatrix} w_{11} & w_{12} & ... &w_{1n} \\ w_{21} & w_{22} & ... &w_{2n} \\ .& .& ... & .\\ w_{m1} & w_{m2} & ... &w_{mn} \\ \end{pmatrix} \begin{pmatrix} a_1 \\ a_2 \\ . \\ a_n \end{pmatrix} = \begin{pmatrix} W_1 \\ W_2 \\ . \\ W_m \end{pmatrix} $$ Now we need to solve this equation to get the matrix/vector $$ A = \begin{pmatrix} a_1 \\ a_2 \\ . \\ a_n \end{pmatrix} $$ on its own. There is a criteria for solving this from linear algebra: if we can find $n$ linearly independent rows in the matrix of $w$'s then we will be able to solve for the $a$'s. If we can't find $n$ linearly independent rows then we won't be able to solve for the $a$'s.