I have a code that starts by producing a random vector x0, then does something to it and arrives at a number, y. How exactly the code goes from x0 to y is probably not important. The problem is this:
I generated 100 random x0 and ploted the resulting 100 values of y. They were all concentrated around 3. Then I simply run the code again, without changing anything. It generated another 100 random x0 and ploted the resulting 100 values of y. This time they were all concentrated around 0.
(I tried including a picture with the results, but got "An error occured when uploading the image")
This is very suspicious. Why should two different runs of the same code give such different results? In the first run ALL values of y were between 2 and 4, while in the second run ALL values of y were between -1 and 1.
It must be related to the random number generation. This is something I am not very familiar with.
The code starts like this:
clear
clc
n=2;
c=0.01/(n-1);
conec=c+0.03*rand(n,n);
for samp=1:100
x0=rand(1,2*n);
etc.
(it involves integrating a differential equation, and then some linear algebra, but the details should not matter, I think)
Aucun commentaire:
Enregistrer un commentaire