G
George George
i have some perl code
while ($high - $low > 0.001) { # precision
# calculate the sum of all normalized scores
my $sum = Pn * Pn * exp($lambda * $match) * 4
+ Pn * Pn * exp($lambda * $mismatch) * 12;
# refine guess at lambda
if ($sum > 1) {
$high = $lambda;
$lambda = ($lambda + $low)/2;
}
else {
$low = $lambda;
$lambda = ($lambda + $high)/2;
}
}
trying to rewrite this in ruby
while (high - low > 0.001)
#calculate the sum of all normalized scores
sum = Pn * Pn **(lambda * match) * 4 + Pn * Pn **(lambda * mismatch) *
12
#refine guess at lambda
if sum > 1
high = lambda
lambda = (lambda + low)/2
else
low = lambda
lambda = (lambda+high)/2
end
end
Is this the right way?
i seem to get different results when i execute the ruby version.
any ideas?
while ($high - $low > 0.001) { # precision
# calculate the sum of all normalized scores
my $sum = Pn * Pn * exp($lambda * $match) * 4
+ Pn * Pn * exp($lambda * $mismatch) * 12;
# refine guess at lambda
if ($sum > 1) {
$high = $lambda;
$lambda = ($lambda + $low)/2;
}
else {
$low = $lambda;
$lambda = ($lambda + $high)/2;
}
}
trying to rewrite this in ruby
while (high - low > 0.001)
#calculate the sum of all normalized scores
sum = Pn * Pn **(lambda * match) * 4 + Pn * Pn **(lambda * mismatch) *
12
#refine guess at lambda
if sum > 1
high = lambda
lambda = (lambda + low)/2
else
low = lambda
lambda = (lambda+high)/2
end
end
Is this the right way?
i seem to get different results when i execute the ruby version.
any ideas?