From: Fritz Heinrichmeyer Date: 2009-04-08T22:25:17+09:00 Subject: Re: what is happening here in ruby lambda, high and low are integers and divide by two is also integer arithmetic. Perl uses float for scalars by default. Am Mittwoch, den 08.04.2009, 07:57 -0500 schrieb George George: > > It seems like you're using the ** operator wrong. You should use Ruby's > > Math.exp instead (which is the direct equivalent to Perl's exp). > > > > -Matthias > > Thank you Mat > i have changed that. here is the full script in ruby: > Pn = 0.25 #probabilty of any nuclotide > > match = 10 > mismatch = -10 > > expected_score = match * 0.25 + mismatch * 0.75 > if match <=0 or expected_score >= 0 > puts "illegal scores" > # quit > end > > #calculate lambda > #initial estimates > lambda = 1 > high = 2 > low = 0 > > > while (high - low > 0.001) do > #calculate the sum of all normalized scores > sum = Pn * Pn * Math.exp(lambda * match) * 4 + Pn * Pn * > Math.exp(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