There is a matrix, e.g., M*N, which consists of 0 and 1 values. The distribution of 0 and 1 is random. To perform an experiment, I need to randomly sample x entries from this matrix, these x entries are all of 1. The output should be the position of these x entries. Are there any algorithms that can perform this functionality?
randomly sample a list of entries with given value from a random matrix
0
$\begingroup$
combinatorics
algorithms
data-analysis
sampling
random-matrices
-
0are you looking for an algorithm or something? – 2017-01-27
1 Answers
0
Sure: randomly pick $1 \le i \le M$, $i \le j \le M$, and look at entry $(i, j)$. If it's a 1, return $(i, j)$; otherwise try again. This is known as "rejection sampling", and it's pretty slow if the probability that an entry is 1 happens to be small, and very fast if that probability is large. But it always works. :)