# from weighted average to single values

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.

-
i think this is impossible given just weighted average and each weight –  Aang Aug 16 '12 at 10:29

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..
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.