[Biojava-dev] Bug in DP.generate()?

David Huen david.huen at ntlworld.com
Sun May 11 13:18:37 EDT 2003


Hi,
Around line 466, the generate() method samples a state from the magicalState 
and looks up the weight of that transition to add it to the score.

    oldState = (State)model.getWeights(model.magicalState()).sampleSymbol();
    Distribution oldDist = model.getWeights(oldState);
    try {
      symScore += oldDist.getWeight(oldState);
    } catch (IllegalSymbolException ite) {
      throw new BioError(ite,
        "Transition returned from sampleTransition is invalid");
    }


It looks as if it is picking up the score from the wrong transition 
distribution, i.e. from the transition distribution of the destination 
state rather than from that of the magicalState.  At any rate, the current 
code fubars immediately when the first state doesn't have a reflexive 
transition.

I think the distribution line should be replaced by:-
    Distribution oldDist = model.getWeights(model.magicalState());

Under these circumstances, I don't think we could ever get an 
IllegalSymbolException (since the sampleSymbol() will have drawn that very 
same distribution.) so the try clause may be unnecessary too.

Have I read it right?  If so, I will commit my changes to CVS.

Regards,
David Huen



More information about the biojava-dev mailing list