I am not sure where you get "replicatexy" as it is not listed in the script commands officially:
https://optics.ansys.com/hc/en-us/articles/360034923553-Lumerical-scripting-language-Alphabetical-list
Neither "randomint".
Please check where is it from.
"- line 15: matrices can not exceed 8 dimensions"
I do not know which line 15 but as the message says, a matrix cannot have more than 8 dimensions, if you defined it.
For randomness, please refer to the structure groups in the Object Library.