Random sampling a symmetric matrix - MathOverflow most recent 30 from http://mathoverflow.net 2013-05-21T06:34:05Z http://mathoverflow.net/feeds/question/72761 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://mathoverflow.net/questions/72761/random-sampling-a-symmetric-matrix Random sampling a symmetric matrix WhitAngl 2011-08-12T11:42:19Z 2011-08-12T15:52:32Z <p>I'd like to sample the elements of a symmetric square matrix uniformly. For example, for a $N\times N$ matrix, I'd like to only keep $\alpha$% of the matrix elements to build a sparse matrix, while keeping the symmetry property.</p> <p>A simple method would be to scan the upper right part of the matrix, generating a random number uniformly between 0 and 1 and compare to $\alpha/2$ to accept or reject the element, and symmetrize the matrix at the end.</p> <p>However, in my case, sampling a row is costly while sampling a column is not : I'd like to minimize the number of rows that I will visit. For example, in the strategy above, every row is visited while the last row will only have a single element checked: this is thus not optimal since I'll need to access the last row (which is very costly) to decide for a single element. I'd rather discard as many rows as possible if the symmetry property ensures that they will be covered anyway.</p> <p>Hence, a solution could be to randomly choose $\sqrt{\alpha} N$ rows and sample each element of this row with a probability $\sqrt\alpha$, and symmetrize afterwards. However, I am not sure this would produce a uniform random sampling, similar to the one I would obtain with the first strategy.</p> <p>What would be the best strategy while maintaining the uniform sampling property ?</p> <p>Please, don't hesitate to tell me whether the question is not clear enough, or should be rather asked on StackOverflow. Thanks!</p> http://mathoverflow.net/questions/72761/random-sampling-a-symmetric-matrix/72763#72763 Answer by Carlo Beenakker for Random sampling a symmetric matrix Carlo Beenakker 2011-08-12T12:13:11Z 2011-08-12T15:52:32Z <p>write down the $N^2$ pairs of integers $(n,m)$ with both $n$ and $m$ ranging from $1$ to $N$ ; randomly select a% of them; these are the nonzero elements $M_{nm}$ of your sparse matrix; then evaluate the row with the largest number of nonzero elements, reflect in the diagonal to get the corresponding column, continue with the row that now has the largest number of nonzero elements, reflect in the diagonal, and so on until you have evaluated all nonzero elements.</p> <p>note that diagonal elements appear with one half the probability of the offdiagonal elements, which may or may not be what you want; if it is not, just give the pairs $n=m$ double the weight when selecting the nonzero elements.</p>