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?

  • $\begingroup$ "of rank" what? $\endgroup$ – Exodd Mar 30 '17 at 13:51
  • $\begingroup$ @Exodd Whoops, thank you. Of rank $k$. Assume $k << m,n$. $\endgroup$ – 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.

  • $\begingroup$ Nice and simple. Like it. Does this skew distribution of the values in the product? $\endgroup$ – User1291 Mar 30 '17 at 14:10
  • $\begingroup$ I don't understand what "skewing the distribution" is in this case, sorry $\endgroup$ – Exodd Mar 30 '17 at 14:22
  • $\begingroup$ 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? $\endgroup$ – User1291 Mar 30 '17 at 14:30
  • 1
    $\begingroup$ 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 $\endgroup$ – Exodd Mar 30 '17 at 15:53

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.