I cant figure out why x=x-z
gives me the values it does.
x
is supposed to decrease its value by z
every 6th loop, for 1000 loops, making it less probable that mrnd
(math random) is greater than poa
(probability of acceptance).
int i = 0;
double y = 0.9;
double x = 1.0;
double z = 0.1;
for (int o = 0; o < 1000; o++) {
for (i = 0; i < 6; i++) {
Double random = Math.random();
Double mrnd = Math.floor(random*100)/100;
double poa = (x*y);
System.out.println("randomkalk " + mrnd);
System.out.println("probability" + poa);
if (poa < mrnd ) {
System.out.println("accept change");
};
if (poa > mrnd ) {
System.out.println("deny change");
}
}
System.out.println(x-z); // This gives the right output if x=x-z is not present
System.out.println(" nr 6 \n \n ");
x = x-z; // Gives wrong output
}