I want to generate random positive hermitian matrices, I start with such a code
rho11R = Table[RandomReal[], {i, 1, 4}];
rho10R = Table[RandomComplex[], {i, 1, 4}];
Do[If[rho11R[[i]] - rho11R[[i]]^2 -
rho10R[[i]]*Conjugate[rho10R[[i]]] >= 0,
Nothing, {rho10R[[i]] = RandomComplex[], --i}], {i, 1,
4}];
rhoR = Table[{{rho11R[[i]], rho10R[[i]]}, {Conjugate[rho10R[[i]]],
1 - rho11R[[i]]}}, {i, 1, 4}]
This does not work, as the matrices I get are in general not positive. The problem is my If function, which does not seem to change the iteration variable i to i-1, when the condition for positivity is not fulfilled (so that I can get new random variable for rho10R[[I]] and again check the condition for positivity). How can I reach this?
While[]
loop instead? $\endgroup$ – Somos Jul 19 '19 at 15:53