ptolemy.domains.continuous.lib
Class BandlimitedNoise

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.Source
                              extended by ptolemy.actor.lib.RandomSource
                                  extended by ptolemy.actor.lib.Gaussian
                                      extended by ptolemy.domains.continuous.lib.BandlimitedNoise
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 BandlimitedNoise
extends Gaussian

This actor generates continuous-time noise with a Gaussian distribution and controlled bandwidth. The power spectrum of the noise produced is given by

  S(f) = T s^2 sinc^4(pi f T)
where f is frequency, s is the standard deviation, and the sinc function is given by
  sinc(a) = sin(a)/a
Here, T = 1/b, where b is the value of the bandwidth parameter. Notice that the power declines as the fourth power of one over the frequency. The bandwidth parameter specifies the frequency (in Hertz) at which the first zero occurs, or, equivalently, roughly the width of the main lobe.

This actor may affect the step size taken by the solver. Specifically, it ensures that the solver provides executions at least as frequently as twice the specified bandwidth. This is nominally the Nyquist frequency of an ideally bandlimited noise frequency, but since this noise process is not ideally bandlimited, the solver samples will typically have aliasing distortion. If you need to control that aliasing distortion, then you can set the maxStepSize parameter to something smaller than 1/2b, where c is the bandwidth.

For some uses, the effect that this actor has on the step size may be undesirable because it increases the cost of simulation. If a less rigorous form of noise is desired (for rough models or simple demonstrations), you can use the Noise actor.

Since:
Ptolemy II 8.0
Version:
$Id: BandlimitedNoise.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Edward A. Lee
See Also:
Serialized Form
Accepted Rating:
Red (eal)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
private  Time _timeOfValueAtEnd
          Time associated with the second random number of the current interval.
private  Time _timeOfValueAtStart
          Time associated with the first random number of the current interval.
private  double _valueAtEnd
          The random number at the end of the end of the current interval.
private  double _valueAtStart
          The random number at the start of the current interval.
 Parameter bandwidth
          The bandwidth of the noise random process in Hertz.
 
Fields inherited from class ptolemy.actor.lib.Gaussian
_current, mean, standardDeviation
 
Fields inherited from class ptolemy.actor.lib.RandomSource
_generatorSeed, _needNew, _needNewGenerator, _random, resetOnEachRun, seed
 
Fields inherited from class ptolemy.actor.lib.Source
output, trigger
 
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
BandlimitedNoise(CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
protected  double _generateGaussian()
          Generate a new random number.
protected  void _generateRandomNumber()
          Generate a new random number.
 void fire()
          Produce a number that is linearly interpolated within the current integration step, if linearlyInterpolate is true, or the random number for the beginning of the integration step otherwise.
 void initialize()
          Initialize the random number generator with the seed, if it has been given.
 boolean postfire()
          If we are at the end of the current interval, then generate a new random number for the new interval, and request a refiring at the end of that interval.
 
Methods inherited from class ptolemy.actor.lib.RandomSource
_createGenerator, attributeChanged, clone
 
Methods inherited from class ptolemy.actor.lib.Source
prefire
 
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, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, 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, 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, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, 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

bandwidth

public Parameter bandwidth
The bandwidth of the noise random process in Hertz. The bandwidth is the frequency where the power spectral density first hits zero. This is a double that defaults to 10.0 Hertz.


_timeOfValueAtEnd

private Time _timeOfValueAtEnd
Time associated with the second random number of the current interval.


_timeOfValueAtStart

private Time _timeOfValueAtStart
Time associated with the first random number of the current interval.


_valueAtStart

private double _valueAtStart
The random number at the start of the current interval.


_valueAtEnd

private double _valueAtEnd
The random number at the end of the end of the current interval.

Constructor Detail

BandlimitedNoise

public BandlimitedNoise(CompositeEntity container,
                        java.lang.String name)
                 throws NameDuplicationException,
                        IllegalActionException
Construct an actor with the given container and name.

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

fire

public void fire()
          throws IllegalActionException
Produce a number that is linearly interpolated within the current integration step, if linearlyInterpolate is true, or the random number for the beginning of the integration step otherwise.

Specified by:
fire in interface Executable
Overrides:
fire in class Gaussian
Throws:
IllegalActionException - If the superclass throws it.

initialize

public void initialize()
                throws IllegalActionException
Initialize the random number generator with the seed, if it has been given. A seed of zero is interpreted to mean that no seed is specified. In such cases, a seed based on the current time and this instance of a RandomSource is used to be fairly sure that two identical sequences will not be returned.

Specified by:
initialize in interface Initializable
Overrides:
initialize in class RandomSource
Throws:
IllegalActionException - If the parent class throws it.

postfire

public boolean postfire()
                 throws IllegalActionException
If we are at the end of the current interval, then generate a new random number for the new interval, and request a refiring at the end of that interval.

Specified by:
postfire in interface Executable
Overrides:
postfire in class RandomSource
Returns:
True if it is OK to continue.
Throws:
IllegalActionException - If the base class throws it.

_generateGaussian

protected double _generateGaussian()
                            throws IllegalActionException
Generate a new random number.

Returns:
A random number.
Throws:
IllegalActionException - If parameter values are incorrect.

_generateRandomNumber

protected void _generateRandomNumber()
                              throws IllegalActionException
Generate a new random number. This gets called in initialize() and in the first fire() method of an iteration. It produces a number that is to be the random number at the end of the current iteration.

Overrides:
_generateRandomNumber in class Gaussian
Throws:
IllegalActionException - If parameter values are incorrect.