I asked a question in this category previously but my problem has changed.
On one hand, I have a large number of data files as .dat format, and on the other hand, I have a matrix A
which must be filled with these data. Each of rows of the A
must be devoted to each of the data files BUT NOT WITH THE SAME CHANCE. Actually, my desire is to put each of data files in each row (after importing them) but in a RANDOM WAY.
For example (just for example here, there are 5 data files): (the number of the row of A
is the same of the number of data files and the number of the column of that is fixed to 10). However, in the elements shown below, n has 11 because, as I will explain, I don't want to add the first element from a data file to the matrix.
m = {8, 1, 5, 3};
n = {6, 2, 7, 11, 3, 8, 10, 12, 14, 1, 4};
k = {10, 3, 6, 8, 2};
S = {7, 1, 9};
R = {9, 4, 6, 1, 5};
I mean, the k
is the most significant relative the other elements and must have the highest chance of getting the first row of the matrix;
For example with the weight 10 (just for example). After k
, R
(with the weight 9) must have the next highest chance to get the first row of the matrix. Then with decreasing chance: m
with weight 8. S
with weight 7, and so on. Every previously assigned weight of each data element is given in the first element of the element.
For instance, n
might be assigned to the second row even though n
has the less chance than R
to occupy the second row. As a matter of fact, the random generator, giving attention to the weights, will decide which data element to assign to which row.
RandomSample[]
supports weighted picks $\endgroup$RandomSample[Range[30]^4 -> Range[30], 30]
$\endgroup$