I'm trying to figure out how to create a For
loop for a symmetric matrix. I have a 5 $ \times $ 5 symmetric matrix consisting of 1's and 0's and I'm trying to perform the following:
I want to create a For
loop that will randomly pick an [[i, j]]
point in the matrix and randomly change that corresponding value at that position to either a 0 or 1. For example, let's say position [[1, 3]]
in my matrix is randomly picked. If the value there was originally 0, and then randomly the system replaces that value with 0, then the number won't change. If the system randomly picked 1 instead, then the original 0 is changed to 1. All the while, the corresponding [[j, i]]
value is undergoing the same process due to the symmetry of the matrix. Lastly, the changes from each iteration need to be consistent throughout. For example, in the above example, if [[1, 3]]
was changed from 0 $ \rightarrow $ 1 then when the process is performed again, the new matrix is used not the original one.
There is no "end point" so to say in regards to the random chance. I just wish to simulate the changing matrix an infinite number of times and after each step looking to see how the matrix has changed.
For
loop not a necessity. $\endgroup$