Randomize matrix in RA function