Hi everyone,
I have the following piece of code:
my @set_S;
my @nset_S;
my @epsilons;
my $r=0;
for $r (0..99){
$set_S[$r] = [$r];
}
$q = 2;
$sigma_square = 0.1 * $q;
for my $err (0..$#set_S){
$epsilons[$err] = rand($sigma_square + 1);
}
my $t=0;
for my $s (0..$#set_S){
print "@{$set_S[$s]}\t$epsilons[$s]\t";
@{$set_S[$s]} = @{$set_S[$s]} + $epsilons[$s];
print @{$set_S[$s]}, "\n";
$t++;
}
The output looks like:
0 0.16702880859375 1.16702880859375
1 0.54862060546875 1.54862060546875
2 0.75128173828125 1.75128173828125
3 0.67547607421875 1.67547607421875
4 0.58304443359375 1.58304443359375
5 0.98953857421875 1.98953857421875
6 0.07342529296875 1.07342529296875
7 0.43919677734375 1.43919677734375
8 0.70689697265625 1.70689697265625
Apparently, my question is :Why is the addition wrong?? Why is perl turning the first columns to 1's when adding them to the second column??
How do i solve this?
I appreciate your prompt response.
Thanks