From: "t3ch.dude" Date: 2009-03-18T03:12:29+09:00 Subject: Re: upping numerical precision On Mar 16, 10:56 pm, Roy Pardee wrote: > > Thanks for the response!  I think the issue may be that I'm not doing > any division--just multiplication.  Check it out: > >   irb(main):001:0> require 'mathn' >   => true >   irb(main):002:0> x = 0.5 >   => 0.5 >   irb(main):003:0> 1000.times do >   irb(main):004:1* x *= x >   irb(main):005:1> end >   => 1000 >   irb(main):006:0> x >   => 0.0 >   irb(main):007:0> x.class >   => Float >   irb(main):008:0> > > But the more I think about it, the more I think I'm fussing over > nothing (ha ha!).  I think if my p var goes to zero, I should just set > it = Float::MIN & break out of that loop.  My calc_prob method will > only ever return values <= 1, so there's no sense in letting it > continue to spin down the value of p (if you can tell what I'm trying > to say). > > Thanks! > > -Roy Roy, It all depends on how much range of data you want. If you need more granularity at the tiny end, you can always re-normalize... just initialize p to be 1e6 or something, rather than 1. Then after the log you can just subtract the constant exponent to get back to your original range. -t3ch.dude