Skip to main content
1 of 4
xzczd
  • 68.4k
  • 9
  • 174
  • 489

Here's a fully compiled version, principles applied in modifying the code has been mentioned in the links above:

ssamp2 = Compile[{{n, _Integer}, {nd, _Integer}}, 
  Function[xyzw, {{xyzw[[1]] + I xyzw[[2]], -xyzw[[3]] + I xyzw[[4]]}, {xyzw[[3]] + 
          I xyzw[[4]], xyzw[[1]] - I xyzw[[2]]}}]@#/Sqrt[Total[#^2]] & /@ 
   Flatten[Transpose@RandomVariate[NormalDistribution[0, 1], {n, nd, 4}], 1]]
xzczd
  • 68.4k
  • 9
  • 174
  • 489