Generating Vectors under Constraints on 1 and 2 norm

93 Views Asked by At

Update: I left out some important information in my previous description... I am actually dealing with a special problem, which is better described as follows:

Given user-specified parameters $\alpha$ and $\beta$ (where $0 \lt\alpha \lt 1/(n+1) $, $\beta \gt 0$), generate at least one $n$-vector $A=[a_1,a_2,....,a_n]$ such that: $(a_1)^2 + (a_2)^2 + \cdots + (a_n)^2 = (\beta - \alpha)\alpha $, where $\alpha = 1 - (a_1 + a_2 + .... + a_n) $, and each component of $A$ is restricted to lie in the interval $(\alpha,1)$.

*Note that I am using rounded parentheses to indicate that the interval does not include its boundary points.


While working on a broader problem in developing a computer program, I realized that I could save a lot of time if I could generate n-vectors (for fixed n), subject to the following constraints:

1) the 1-norm of each vector must be equal to some user-specified scalar lambda (note: lambda will always be between 0 and 1)

2) the square of the 2-norm of each vector must be equal to some user-specified scalar phi (note: phi will always be positive)

3) Each vector component must be between 0 and 1

Of course, there are also logical constraints on the choices of lambda and phi given the above constraints... but I suppose we can assume that these parameters are well chosen.

Ultimately, I am searching for a way to accomplish this (or come as close as possible to accomplishing this) via an automated process. I'm not sure how to 'get off the ground', however.

1

There are 1 best solutions below

4
On

Simple answer using geometry for $\mathbb{R}^2$ (also letting the 2-norm be $\phi$ for convenience):

Solving $x+y=\lambda$ and $r=\phi$ gives $$ x = r \cos\theta \\ x = r \sin \theta \\ \theta = 2\left(\tan^{-1}\left(\dfrac{1-\sqrt{2-\dfrac{\lambda^2}{\phi^2}}}{\dfrac{\lambda}{\phi}+1}\right)\right) $$

For the n-dimensional case, just make $x_1=x$, $x_2=y$, other $x_i=0$.

More complicated method(not completely tested!):

  • Define $x$ as $x_i = \frac{\lambda}{n} \forall i$.
  • Choose a nonzero, elementwise positive random vector $y$ by your method of choosing, that is also not a scalar multiple of $x$.
  • Choose a set of $n-1$ basis vectors $\left\{a_i\right\}$ for the hyperplane defined by $\sum x_i = \lambda$, and create the projection matrix $P_a = AA^T$, where $\left\{a_i\right\}$ are the columns of $A$.
  • Compute the vector $y_p = P_ay$, and subsequently scale the vector $y_p$ such that $||y_p'||_2^2 = \phi^2 - \frac{\lambda^2}{n}$
  • The vector $z = x + y_p'$ will now have the desired properties.

Explanation: Since $||x||_1 = \lambda$ and $y_p'$ is a scaled projection of $y$ onto the corresponding hyperplane of constant $\lambda$, $z$ will be on said hyperplane and have $||z||_1 = \lambda$.

Also, note that $x$ and $y_p'$ are orthogonal. Thus, $||z||^2_2 = ||x||^2_2 + ||y_p'||^2_2 = \frac{\lambda^2}{n} + \phi^2 - \frac{\lambda^2}{n} = \phi^2$.