# how to generate non-negative matrices whose product's values lie in a certain range?

So let's say I need two non-negative matrices $A\in\mathbb{R}^{m\times k},B\in\mathbb{R}^{k\times n}$ of rank $k$ s.t. $\forall i,j.0 \leq (AB)_{ij} \leq 255$ .

Without the non-negativity, I'd just generate a Matrix $X=USV^T$ of random values in range $[0,255]$ and use its SVD to assign $A = U \sqrt{S}, B = \sqrt{S}V^T$.

I have no idea, however, how to enforce the non-negativity.

How do I do that?

• "of rank" what? – Exodd Mar 30 '17 at 13:51
• @Exodd Whoops, thank you. Of rank $k$. Assume $k << m,n$. – User1291 Mar 30 '17 at 13:54

Take ANY $A,B$ with nonnegative elements and rank $k$ such that $AB\ne 0$. The matrix $AB$ has nonnegative elements, and if $c$ is the maximum element in $AB$, then $0\le 255*(AB)_{ij}/c\le 255$, so $255*A$ and $B/c$ are your wanted matrices.
• If I would like the values in $$AB$$ to be (approximately) uniformly distributed over the range $$[0,255]$$, will it suffice to generate $$A,B$$ with (approximately) uniformly distributed values? – User1291 Mar 30 '17 at 14:30
• Hmmm.. if $x$ and $y$ are unif. distr., then $x+y$ is not unif. distr., so it's really hard to obtain what you ask – Exodd Mar 30 '17 at 15:53