restricting number of zeros in a vector

58 Views Asked by At

I need to make an M dimensional vector and restrict it to have R entries as zeros. Is there any expression or condition in vector form that can ensure this ?

1

There are 1 best solutions below

3
On

Divide the unit interval in M subintervals $I_k (1\leq k \leq M)$ of equal length. Take a random number $X_1$ with uniform distribution over the unit interval. For the index $k_1$ of the interval where $X_1$ lies, make the $k_1$-th component of the vector equal to zero. Now divide the unit interval in $M-1$ subintervals, numerate them now $I_1,\ldots, I_{k_1-1},I_{k_1+1},\ldots, I_M$ take again a random number $X_2$, for the index $k_2$ make the component $k_2$ equal to zero. Repeat till you have $R$ indices, always taking out the indices you had already. Maybe there is a better way, but I have had not yet breakfast and think veeeery slowly.

Hope it helps.