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

Thomas Down thomas at derkholm.net
Sun May 11 17:36:24 EDT 2003


Once upon a time, on a computer far far away, David Huen wrote:
> 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.

Yes, there's definitely something odd going on there.  Your
fix looks correct to me.

    Thomas.


PS.  When you check this in, could you either put it on
     release-1_3-branch, or e-mail me so I can make sure
     it's on my list of stuff which needs merging?


More information about the biojava-dev mailing list