I tried to make a random vector of 0's and 1's like the code below:
But I'd like to give it a condition to avoid the existence of 1 more than one time. Also, I want the index to be selected randomly.
For example, this:
is not accepted, but this:
either of them will be accepted.
So any help please? Thanks!