Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I downloaded and installed Statistics::Burst.pm, and I have a test script that reads exactly like the code in the documentation. However, I am getting an error:
Can't take log of 0 at blib\lib\Statistics\Burst.pm (autosplit into blib\lib\auto\Statistics\Burst\transistion.al) line 22 +8.
Does anybody have ant clue as to what is happening here..?!? Thanks!

Replies are listed 'Best First'.
Re: Problem with Statistics::Burst
by rhesa (Vicar) on Feb 26, 2007 at 12:13 UTC
    The sample in the synopsis of Statistics::Burst looks like this:
    use Statistics::Burst; my $burstObj=Burst::new(); $burstObj->generateStates(3,.111,2); $burstObj->gamma(.5); $burstObj->setData(\@gap_space); $burstObj->process(); $statesUsed=$burstObj->getStatesUsed();
    Did you supply an array of data in @gap_space? I can easily imagine process() taking the log of 0 when it doesn't have any data (which indicates a lack of robustness in the code, IMHO).
      Yes, I did. My entire listing is this (and the error by the way occurs when processing):
      use strict; use Statistics::Burst; my $burstObj=Statistics::Burst::new(); $burstObj->generateStates(3,.111,2); $burstObj->gamma(.5); my @gap_space = (5,5,10); $burstObj->setData(\@gap_space); $burstObj->process(); my $statesUsed=$burstObj->getStatesUsed();
        Warning: I'm not a user of Statistics::Burst, nor an expert on the algorithm.

        From what I can tell by reading the source, it barfs because it passes 0 (or undef) to $obj->transistion() (sic). The reason for that, I think, is that it kicks off the calculation with $self->calcCost(11);. That hard-coded 11 is used to index into your @gap_space, so if you don't have at least 12 data points, it will fail.

        There isn't a lot of code in that module, so I suggest you patch it up and create an RT ticket. It can use some attention.

        update: I tried it with some random input, and because of that hard-coded 11, $obj->getStatesUsed(); will only ever return 12 states. IMHO you'd be better off just re-implementing the algorithm yourself.

Re: Problem with Statistics::Burst
by MacTommy (Initiate) on Feb 26, 2007 at 12:00 UTC
    Oh, and I'm not an Anonymous Monk.
    Yet, I am a novice at this forum, and somehow managed to log out without having noticed...