Suppose you have 4 arrays of different number of rows, but same number of columns.
I need a way to generate a list of 0s and 1, which I can do with the following
lq= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Table[ReplacePart[lq, RandomInteger[{1, 10}] -> 1], {i, 10}]
Now let's say you have a different list where you have to replace 3 random choices of 0s with 1s. And they have to be all different elements, meaning I need 3 0s replaced
how do I accomplish that?
lw={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
The following didn't work.
Table[RandomInteger[{1, 49}] /; %[[1]] != %[[2]] != %[[3]], {10}]
{13 /; %[[1]] != %[[2]] != %[[3]], 49 /; %[[1]] != %[[2]] != %[[3]],
25 /; %[[1]] != %[[2]] != %[[3]], 6 /; %[[1]] != %[[2]] != %[[3]],
39 /; %[[1]] != %[[2]] != %[[3]], 27 /; %[[1]] != %[[2]] != %[[3]],
48 /; %[[1]] != %[[2]] != %[[3]], 21 /; %[[1]] != %[[2]] != %[[3]],
20 /; %[[1]] != %[[2]] != %[[3]], 23 /; %[[1]] != %[[2]] != %[[3]]}
Thanks you any help
edit. The first list was supposed to be 10 elements long. Not 23 like I posted. ut that doesn't really matter.