Consider the following code:
Compile[{{x,_Real}},Module[{x1=x,W},
W=RandomVariate[NormalDistribution[0, 10^-2], 2];
x1=x1+W[[1]]+W[[2]];
x1]]
It fails complaining that W[[1]],W[[2]]
is longer that the depth of the variable. How to correctly use a list inside Compile
?
RandomVariate
. The backend ofRandomVariate
should be compiled already. $\endgroup$