ptolemy.actor.lib
Class LevinsonDurbin

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by ptolemy.actor.lib.LevinsonDurbin
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class LevinsonDurbin
extends TypedAtomicActor

This actor uses the Levinson-Durbin algorithm to compute the linear predictor coefficients of a random process, given its autocorrelation function as an input. These coefficients are produced both in tapped delay line form (on the linearPredictor output) and in lattice filter form (on the reflectionCoefficients output). The order of the predictor (the number of linearPredictor and coefficients reflectionCoefficients produced) is the number of lags of the supplied autocorrelation. The errorPower output is the power of the prediction error as a function of the predictor order. The inputs and outputs are all arrays of doubles.

The autocorrelation estimates provided as inputs can be generated by the Autocorrelation actor. It the Autocorrelation actor is set so that its biased parameter is true, then the combined effect of that actor and this one is called the autocorrelation method. The order of the predictor is the value of the numberOfLags parameter of the Autocorrelation actor. If the length of the autocorrelation input is odd, then it is assumed to be a symmetric autocorrelation function, and the order of the predictor calculated by this actor is (length + 1)/2. Otherwise, the order is 1 + (length/2), which assumes that discarding the last sample of the autocorrelation would make it symmetric.

Three output signals are generated by this actor. On the errorPower output port, an array of length order + 1 gives the prediction error power for each predictor order from zero to order. The first value in this array, which corresponds to the zeroth-order predictor, is simply the zero-th lag of the input autocorrelation, which is the power of the random process with that autocorrelation. Note that for signals without noise whose autocorrelations are estimated by the Autocorrelation actor, the errorPower output can get small. If it gets close to zero, or goes negative, this actor fixes it at zero. "Close to" is determined by the close() method of the ptolemy.math.SignalProcessing class.

The linearPredictor output gives the coefficients of an FIR filter that performs linear prediction for the random process. This set of coefficients is suitable for directly feeding a VariableFIR actor, which accepts outside coefficients. The number of coefficients produced is equal to the order. The predictor coefficients produced by this actor can be used to create a maximum-entropy spectral estimate of the input to the Autocorrelation actor. They can also be used for linear-predictive coding, and any number of other applications.

The reflectionCoefficients output is the reflection coefficients, suitable for feeding directly to a VariableLattice actor, which will then generate the forward and backward prediction error. The number of coefficients produced is equal to the order.

Note that the definition of reflection coefficients is not quite universal in the literature. The reflection coefficients in reference [2] is the negative of the ones generated by this actor, which correspond to the definition in most other texts, and to the definition of partial-correlation (PARCOR) coefficients in the statistics literature.

References

[1] J. Makhoul, "Linear Prediction: A Tutorial Review", Proc. IEEE, vol. 63, pp. 561-580, Apr. 1975.

[2] S. M. Kay, Modern Spectral Estimation: Theory & Application, Prentice-Hall, Englewood Cliffs, NJ, 1988.

Since:
Ptolemy II 1.0
Version:
$Id: LevinsonDurbin.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
See Also:
Autocorrelation, VariableFIR, VariableLattice, SignalProcessing, Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
 TypedIOPort autocorrelation
          The autocorrelation input, which is an array.
 TypedIOPort errorPower
          The output for the error power, as a function of the predictor order.
 TypedIOPort linearPredictor
          The output for linear predictor coefficients.
 TypedIOPort reflectionCoefficients
          The output for lattice filter coefficients for a prediction error filter.
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
LevinsonDurbin(CompositeEntity container, java.lang.String name)
          Construct an actor in the specified container with the specified name.
 
Method Summary
 void fire()
          Consume the autocorrelation input, and calculate the predictor coefficients, reflection coefficients, and prediction error power.
 boolean prefire()
          If there is no token on the autocorrelation input, return false.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, initialize, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, initialize, preinitialize, removeInitializable, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

autocorrelation

public TypedIOPort autocorrelation
The autocorrelation input, which is an array.


errorPower

public TypedIOPort errorPower
The output for the error power, as a function of the predictor order. This produces an array.


linearPredictor

public TypedIOPort linearPredictor
The output for linear predictor coefficients. This produces an array.


reflectionCoefficients

public TypedIOPort reflectionCoefficients
The output for lattice filter coefficients for a prediction error filter. This produces an array.

Constructor Detail

LevinsonDurbin

public LevinsonDurbin(CompositeEntity container,
                      java.lang.String name)
               throws IllegalActionException,
                      NameDuplicationException
Construct an actor in the specified container with the specified name.

Parameters:
container - The container.
name - The name.
Throws:
IllegalActionException - If the actor cannot be contained by the proposed container.
NameDuplicationException - If the name coincides with an actor already in the container.
Method Detail

fire

public void fire()
          throws IllegalActionException
Consume the autocorrelation input, and calculate the predictor coefficients, reflection coefficients, and prediction error power.

Specified by:
fire in interface Executable
Overrides:
fire in class AtomicActor
Throws:
IllegalActionException - If there is no director.

prefire

public boolean prefire()
                throws IllegalActionException
If there is no token on the autocorrelation input, return false. Otherwise, return whatever the base class returns.

Specified by:
prefire in interface Executable
Overrides:
prefire in class AtomicActor
Returns:
True if it is ok to continue.
Throws:
IllegalActionException - If the base class throws it.