ptolemy.actor.lib
Class Bernoulli
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Source
ptolemy.actor.lib.RandomSource
ptolemy.actor.lib.Bernoulli
- All Implemented Interfaces:
- Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TypedActor
- public class Bernoulli
- extends RandomSource
Produce a random sequence of booleans. The output is of type BooleanToken.
The values that are generated are independent and identically distributed,
where the probability of true is given by the parameter
trueProbability.
The seed can be specified as a parameter to control the sequence that is
generated.
This actor uses the class java.util.Random to generate random numbers.
- Since:
- Ptolemy II 0.3
- Version:
- $Id: Bernoulli.java,v 1.33 2004/04/13 03:02:19 cxh Exp $
- Author:
- Edward A. Lee
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
Constructor Summary |
Bernoulli(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name. |
|
Method Summary |
void |
fire()
Send a random boolean to the output.
|
boolean |
prefire()
Calculate the next random boolean for this iteration. |
| Methods inherited from class ptolemy.actor.AtomicActor |
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, postfire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate, wrapup |
| Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables |
| Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
trueProbability
public Parameter trueProbability
- The probability of true.
This parameter contains a DoubleToken, initially with value 0.5.
Bernoulli
public Bernoulli(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.
fire
public void fire()
throws IllegalActionException
- Send a random boolean to the output.
This number is only changed in the prefire() method, so it will
remain constant throughout an iteration.
- Specified by:
fire in interface Executable- Overrides:
fire in class Source
- Throws:
IllegalActionException - If calling send() or super.fire()
throws it.
prefire
public boolean prefire()
throws IllegalActionException
- Calculate the next random boolean for this iteration.
- 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.