srand(1234);
x = zeros(2);
y = zeros(2);
A = 3.5;
y.=x.+ A * randn.()
srand(1234);
x = zeros(2);
y = zeros(2);
B = 3.5;
y.=x.+ A .* randn.()
The first piece produces
2-element Array{Float64,1}:
3.03572
3.03572
while the second produces:
2-element Array{Float64,1}:
3.03572
-3.1561
It is this latter version that I exepcted. While I can appreciate why this is happening, it’s quite easy to forget a ., which could result in some very bad behavior with stochastic problems.