Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

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

2 Answers 2

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

share|improve this answer
    
What I'm trying to do here is to find an average weighted margin. Each amount for me is a final sell price, so from W I can calculate sum(amounts) or I can take some hints from purchase prices..I know there's no a unique solution, but in addition I have some max min limit for each product price.. –  user1400495 Aug 16 '12 at 10:49
    
Yes I see. There is no unique solution but if you have a set of equations then you have a solution based on some "nice" criterion even if you have more equations than unknowns. en.wikipedia.org/wiki/Overdetermined_system Moreover I can suggest to have a look compressive sensing. en.wikipedia.org/wiki/Corollary I think they will help at any case –  Seyhmus Güngören Aug 16 '12 at 11:01

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.