I have a feeling this should be very simple, but I somehow got stuck thinking about it.

I have $\it X$, which is a 15 x 18 matrix containing non-negative real values. I smoothed this matrix using a moving window smoother, which resulted in a matrix $\it Y$ of the same dimensions, but unfortunately the total sum for this new matrix changed.

My question is, how do I create a 15 x 18 matrix $\it W$ containing adjustment weights, such that the marginals sums of $\mathit{Y \cdot W}$ after smoothing agree with the corresponding row and column sums of $\it X$ prior to smoothing?

Thanks very much for your help!


1 Answer 1


Could it be quadratic programming problem of sort?

min z(t)Iz

subject to


where y* is adjusted vector, c is an vector for marginal values and z = y - y*, meaning discrepancy vector. A would be restriction matrix with 1, 0 and 1/n elements depending on your problem.

  • $\begingroup$ Thank you for your reply! Yes, it certainly looks like an optimization problem. I am, however, still unsure how to implement it. What is it exactly that I am minimizing here? I need the row and column marginal sums in my smoothed matrix to be the same as in the original matrix, while the values in each cell can differ. I think this is what you meant by z = y - y*, if I consider one vector (row or column from my matrix) at a time. So, is it possible to optimize cell values in rows while keeping in the respective column sums in check? $\endgroup$
    – Denys D.
    Jun 15, 2018 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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