in reply to Problem with Statistics::Burst

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).

Replies are listed 'Best First'.
Re^2: Problem with Statistics::Burst
by MacTommy (Initiate) on Feb 26, 2007 at 12:56 UTC
    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.