Ceylan::Maths::Random::RandomGeneratorFromPDF Class Reference

Random generator created from a user-defined probability density function (PDF). More...

#include <CeylanRandomGeneratorFromPDF.h>

Inheritance diagram for Ceylan::Maths::Random::RandomGeneratorFromPDF:

Inheritance graph
[legend]
Collaboration diagram for Ceylan::Maths::Random::RandomGeneratorFromPDF:

Collaboration graph
[legend]

List of all members.

Public Types

enum  TextOutputFormat { rawText, html }
 Defines what text output formats for TextDisplayable instances are available. More...
enum  TextOutputFormat { rawText, html }
 Defines what text output formats for TextDisplayable instances are available. More...

Public Member Functions

 RandomGeneratorFromPDF (const ProbabilityFunction &pdf, Sample lowerLimit, Sample upperLimit, Seed aSeed=DefaultSeed)
 Creates a random generator which will produce values between specified lowerLimit, included, and specified upperLimit, excluded, with respect to the specified probability density function (PDF), described thanks to a ProbabilityFunction instance.
virtual ~RandomGeneratorFromPDF () throw ()
 Basic virtual destructor.
virtual RandomValue getNewValue ()
 Returns the next random value.
virtual void reset (Seed neeSeed)
 Resets the random generator with specified seed.
virtual const std::string displayProbabilities () const
 Returns a user-friendly description of the internal probability table.
virtual const std::string toString (VerbosityLevels level=high) const
 Returns a user-friendly description of the state of this object.
virtual const std::string getClassName () const
virtual bool isOfSameType (const Object &other) const
 Returns whether other is an instance of the same type as this object.
virtual void logState (Ceylan::VerbosityLevels level=Ceylan::high)
 Uses its dedicated log channel to display its state.
virtual void send (const std::string &message, Log::LevelOfDetail levelOfDetail=Log::DefaultLevelOfDetailForMessage)
 Sends message to the internal channel.
virtual void forgeIdentifier ()
 Forges this object's identifier.
IdentifiergetIdentifier () const
 Returns this IdentifierOwner's identifier.
void setIdentifier (Identifier &id)
 Sets this IdentifierOwner's identifier.
bool hasIdentifier () const
 Returns whether this IdentifierOwner has a stored identifier.
void deleteIdentifier ()
 Deletes this IdentifierOwner's identifier.
void setChannelName (const std::string &channelName)
 Sets this Logable channel name.
bool hasChannelName () const
 Returns whether this Log source has a registered channel name.
std::string getChannelName () const
 Returns this LogSource channel name.
void setLevelOfDetail (LevelOfDetail newLevel)
 Sets this LogSource level of detail of interest.
LevelOfDetail getLevelOfDetail () const
 Returns this LogSource channel name.
virtual void sendToChannel (const std::string &channel, const std::string &message, LevelOfDetail levelOfDetail=DefaultLevelOfDetailForMessage) const
 Sends message to the specified channel, through known LogTransport.
virtual void setTransport (LogTransport &newTransport)
 Sets a new Log transport for this LogSource.
virtual LogTransportgetTransport () const
 Returns this LogSource's Log transport.
virtual bool hasTransport () const
 Tells whether this LogSource has a registered Log transport.

Static Public Member Functions

static const std::string ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high)
 Returns a user-friendly description of this list of pointers to text displayable instances.
static const std::string ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high)
 Returns a user-friendly description of this list of pointers to text displayable instances.
static TextOutputFormat GetOutputFormat ()
 Returns the current overall text format to be used by TextDisplayable instances.
static TextOutputFormat GetOutputFormat ()
 Returns the current overall text format to be used by TextDisplayable instances.
static void SetOutputFormat (TextOutputFormat newOutputFormat)
 Sets the current overall text format to be used by TextDisplayable instances.
static void SetOutputFormat (TextOutputFormat newOutputFormat)
 Sets the current overall text format to be used by TextDisplayable instances.
static bool IsALoggableChannelName (const std::string &channelName)
 Returns whether the specified channel name is an object channel name, based on the possible presence of the protocol prefix and separators (typically, loggable://).
static const std::string GetEmbeddedChannelName (const std::string &fullChannelName)
 Returns the real channel name used by a Loggable by removing the protocol prefix and separators (typically, 'loggable://').

Static Public Attributes

static const Seed DefaultSeed = 1
 Default seed to be used.
static const std::string ProtocolName = "loggable"
static const LevelOfDetail DefaultLevelOfDetailForSource = 10
 The default level of detail of a Log source.

Protected Member Functions

virtual void preCompute ()
 Does the computation necessary to determine next new value.
void dropIdentifier ()
 Removes this Object's identifier, in order to avoid class name mangling.
virtual void directSend (const std::string &channel, const std::string &message, LevelOfDetail levelOfDetail=DefaultLevelOfDetailForMessage) const
 Internal method to send messages.
virtual void unlinkTransport ()
 Suppresses the link between this LogSource and its Log transport.

Protected Attributes

ProbabilityFunction const * _pdf
 Internal link to probability function.
WhiteNoiseGenerator_whiteNoiseGenerator
 Internal white noise random generator.
Probability_probabilitiesTable
 Where probabilities calculated thanks to the PDF are stored.
Sample_sampleRangesTable
 Tells how the uniform random space is split into sample areas.
Sample _lowerLimit
 The lower limit to output random values (this value is the first that can be drawn).
Sample _upperLimit
 The upper limit to output random values (this value is the first that is superior to _lowerLimit and that cannot be drawn).
Seed _seed
 The seed which was used to initialize the generator.
bool _trackInstance
 Tells whether this instance's lifecycle should be advertised in log system.
std::string _channelName
 Stores this LogSource channel name.
LevelOfDetail _level
 The current level of detail of interest for this Log source.
LogTransport * _transport
 The LogTransport to be used for sending messages.

Static Protected Attributes

static TextOutputFormat _OutputFormat = rawText
 The text format to be used currently by TextDisplayable instances.
static TextOutputFormat _OutputFormat = rawText
 The text format to be used currently by TextDisplayable instances.


Detailed Description

Random generator created from a user-defined probability density function (PDF).

Output random value will obey the specified law of probability.

Note:
For a continuous distribution, this probability function is defined as the derivative of the (cumulative) distribution function.

Definition at line 68 of file CeylanRandomGeneratorFromPDF.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

RandomGeneratorFromPDF::RandomGeneratorFromPDF ( const ProbabilityFunction pdf,
Sample  lowerLimit,
Sample  upperLimit,
Seed  aSeed = DefaultSeed 
)

Creates a random generator which will produce values between specified lowerLimit, included, and specified upperLimit, excluded, with respect to the specified probability density function (PDF), described thanks to a ProbabilityFunction instance.

The generator will be initialized by specified seed, if provided, otherwise will default to DefaultSeed.

Note:
The seed does not need to be in range [lowerLimit;upperLimit[

The random generator will use, but not own, the specified ProbabilityFunction object.

Exceptions:
MathsException if lowerLimit is not strictly inferior to upperLimit.

Definition at line 58 of file CeylanRandomGeneratorFromPDF.cc.

References preCompute().

RandomGeneratorFromPDF::~RandomGeneratorFromPDF (  )  throw () [virtual]

Basic virtual destructor.

Definition at line 75 of file CeylanRandomGeneratorFromPDF.cc.

References _probabilitiesTable, _sampleRangesTable, and _whiteNoiseGenerator.


Member Function Documentation

void IdentifierOwner::deleteIdentifier (  )  [inherited]

Deletes this IdentifierOwner's identifier.

Definition at line 128 of file CeylanIdentifierOwner.cc.

References Ceylan::IdentifierOwner::_id, and Ceylan::emergencyShutdown().

Referenced by Ceylan::Object::dropIdentifier(), and Ceylan::IdentifierOwner::~IdentifierOwner().

void LogSource::directSend ( const std::string &  channel,
const std::string &  message,
LevelOfDetail  levelOfDetail = DefaultLevelOfDetailForMessage 
) const [protected, virtual, inherited]

Internal method to send messages.

Filters them out if their level of detail is higher than the one of this log source.

Definition at line 164 of file CeylanLogSource.cc.

References Ceylan::Log::LogSource::_transport, and Ceylan::Log::LogTransport::propagate().

Referenced by Ceylan::Log::LogSource::send(), and Ceylan::Log::LogSource::sendToChannel().

const string RandomGeneratorFromPDF::displayProbabilities (  )  const [virtual]

Returns a user-friendly description of the internal probability table.

Exceptions:
MathsException if no probability table is available.

Definition at line 173 of file CeylanRandomGeneratorFromPDF.cc.

References Ceylan::Maths::Random::RandomGenerator::_lowerLimit, _probabilitiesTable, _sampleRangesTable, Ceylan::Maths::Random::RandomGenerator::_upperLimit, Ceylan::formatStringList(), dataUtils::l, toString(), and Ceylan::toString().

Referenced by getNewValue().

void Object::dropIdentifier (  )  [protected, inherited]

Removes this Object's identifier, in order to avoid class name mangling.

Note:
This method should be used at least after the last message sent from an Object's deepest constructor (the final child).

Definition at line 261 of file CeylanObject.cc.

References Ceylan::IdentifierOwner::deleteIdentifier().

Referenced by Ceylan::Object::forgeIdentifier(), and Ceylan::Object::Object().

void Object::forgeIdentifier (  )  [virtual, inherited]

std::string LogSource::getChannelName (  )  const [inherited]

Returns this LogSource channel name.

Definition at line 101 of file CeylanLogSource.cc.

References Ceylan::Log::LogSource::_channelName.

Referenced by Ceylan::Log::LogSource::toString().

const std::string Object::getClassName (  )  const [virtual, inherited]

Definition at line 102 of file CeylanObject.cc.

References CEYLAN_LOG.

Referenced by Ceylan::Object::isOfSameType().

const string Loggable::GetEmbeddedChannelName ( const std::string &  fullChannelName  )  [static, inherited]

Identifier & IdentifierOwner::getIdentifier (  )  const [inherited]

Returns this IdentifierOwner's identifier.

Exceptions:
IdentifierNotAvailableException if the operation failed.

Definition at line 83 of file CeylanIdentifierOwner.cc.

References Ceylan::IdentifierOwner::_id.

Referenced by Ceylan::Object::forgeIdentifier().

LevelOfDetail LogSource::getLevelOfDetail (  )  const [inherited]

Returns this LogSource channel name.

Definition at line 119 of file CeylanLogSource.cc.

References Ceylan::Log::LogSource::_level.

RandomValue RandomGeneratorFromPDF::getNewValue (  )  [virtual]

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]

LogTransport * LogSource::getTransport (  )  const [virtual, inherited]

Returns this LogSource's Log transport.

Definition at line 209 of file CeylanLogSource.cc.

References Ceylan::Log::LogSource::_transport.

bool LogSource::hasChannelName (  )  const [inherited]

Returns whether this Log source has a registered channel name.

Definition at line 83 of file CeylanLogSource.cc.

References Ceylan::Log::LogSource::_channelName.

Referenced by Ceylan::Log::LogSource::toString().

bool IdentifierOwner::hasIdentifier (  )  const [inherited]

Returns whether this IdentifierOwner has a stored identifier.

Definition at line 119 of file CeylanIdentifierOwner.cc.

References Ceylan::IdentifierOwner::_id.

Referenced by Ceylan::Object::forgeIdentifier(), and Ceylan::IdentifierOwner::~IdentifierOwner().

bool LogSource::hasTransport (  )  const [virtual, inherited]

Tells whether this LogSource has a registered Log transport.

Definition at line 218 of file CeylanLogSource.cc.

References Ceylan::Log::LogSource::_transport.

Referenced by Ceylan::Log::LogSource::setTransport().

bool Loggable::IsALoggableChannelName ( const std::string &  channelName  )  [static, inherited]

Returns whether the specified channel name is an object channel name, based on the possible presence of the protocol prefix and separators (typically, loggable://).

Definition at line 73 of file CeylanLoggable.cc.

References Ceylan::URI::getProtocolName(), Ceylan::Log::Loggable::ProtocolName, and Ceylan::URI::ProtocolSeparator.

Referenced by Ceylan::Log::LogAggregator::findChannel(), and Ceylan::Log::LogAggregator::store().

bool Object::isOfSameType ( const Object other  )  const [virtual, inherited]

Returns whether other is an instance of the same type as this object.

Parameters:
other the object whose type is to be compared with this object's type.
See also:
getClassName

Definition at line 140 of file CeylanObject.cc.

References Ceylan::Object::getClassName().

void Object::logState ( Ceylan::VerbosityLevels  level = Ceylan::high  )  [virtual, inherited]

Uses its dedicated log channel to display its state.

Note:
This is the very convenient combination of a Loggable and a TextDisplayable: it requests this Object to log its textual representation in its own channel.
Parameters:
level chooses the level of detail
Note:
This method cannot have the const qualifier since the send method might have to forge a new identifier.

Definition at line 149 of file CeylanObject.cc.

References Ceylan::Object::send(), and Ceylan::Object::toString().

void RandomGeneratorFromPDF::preCompute (  )  [protected, virtual]

void RandomGeneratorFromPDF::reset ( Seed  neeSeed  )  [virtual]

Resets the random generator with specified seed.

Implements Ceylan::Maths::Random::RandomGenerator.

Definition at line 160 of file CeylanRandomGeneratorFromPDF.cc.

References _whiteNoiseGenerator, and Ceylan::Maths::Random::WhiteNoiseGenerator::reset().

virtual void Ceylan::Object::send ( const std::string &  message,
Log::LevelOfDetail  levelOfDetail = Log::DefaultLevelOfDetailForMessage 
) [virtual, inherited]

Sends message to the internal channel.

Parameters:
message the log message to send. Please avoid characters '<' and '>' since they have a special meaning for HTML log output. These characters used to be filtered in HTML aggregators but it prevented messages to contain HTML tags on purpose, which proved to be convenient in the case only HTML aggregators are to be used.
levelOfDetail the level of detail of this message (level 5 by default).
Exceptions:
Log::LogException if the operation failed.
Note:
This method had to be overriden because when forging the identifier from the object constructor, the class name is mangled. So we delay the construction of the identifier until the first log message in internal channel is sent. This is an elegant solution too, since objects which will not send messages on their private channel will not have to construct their identifier.

There may be a small lag when the first send is called, due to the identifier construction.

This method cannot have the const qualifier since it might have to forge a new identifier.

Reimplemented from Ceylan::Log::LogSource.

Referenced by Ceylan::Object::logState(), Ceylan::Module::Module(), Ceylan::Object::Object(), Ceylan::Module::~Module(), and Ceylan::Object::~Object().

void LogSource::sendToChannel ( const std::string &  channel,
const std::string &  message,
LevelOfDetail  levelOfDetail = DefaultLevelOfDetailForMessage 
) const [virtual, inherited]

Sends message to the specified channel, through known LogTransport.

Note:
This method is to be used when a message is to be sent to a channel different from the LogSource's internal one.
Parameters:
channel the channel name which will identify the targeted Loglistener.
message the log message to send. Please avoid characters '<' and '>' since they have a special meaning for HTML log output. These characters used to be filtered in HTML aggregators but it prevented messages to contain HTML tags on purpose, which proved to be convenient.
levelOfDetail the level of detail of this message (level 1 by default).
See also:
send with implied internal channel

Definition at line 142 of file CeylanLogSource.cc.

References Ceylan::Log::LogSource::_level, CEYLAN_LOG, Ceylan::Log::LogSource::directSend(), and Ceylan::toString().

void Loggable::setChannelName ( const std::string &  channelName  )  [inherited]

Sets this Logable channel name.

Reimplemented from Ceylan::Log::LogSource.

Definition at line 63 of file CeylanLoggable.cc.

References Ceylan::Log::Loggable::ProtocolName, and Ceylan::URI::ProtocolSeparator.

Referenced by Ceylan::Log::Loggable::Loggable().

void IdentifierOwner::setIdentifier ( Identifier id  )  [inherited]

Sets this IdentifierOwner's identifier.

Exceptions:
IdentifierNotAvailableException if the operation failed.
Note:
This IdentifierOwner takes ownership of provided identifier.

Definition at line 101 of file CeylanIdentifierOwner.cc.

References Ceylan::IdentifierOwner::_id.

Referenced by Ceylan::Object::forgeIdentifier().

void LogSource::setLevelOfDetail ( LevelOfDetail  newLevel  )  [inherited]

Sets this LogSource level of detail of interest.

Definition at line 110 of file CeylanLogSource.cc.

References Ceylan::Log::LogSource::_level.

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

void LogSource::setTransport ( LogTransport newTransport  )  [virtual, inherited]

const std::string TextDisplayable::ToString ( std::list< TextDisplayable * >  displayables,
Ceylan::VerbosityLevels  level = Ceylan::high 
) [static, inherited]

Returns a user-friendly description of this list of pointers to text displayable instances.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

const std::string TextDisplayable::ToString ( std::list< TextDisplayable * >  displayables,
Ceylan::VerbosityLevels  level = Ceylan::high 
) [static, inherited]

Returns a user-friendly description of this list of pointers to text displayable instances.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

const string RandomGeneratorFromPDF::toString ( VerbosityLevels  level = high  )  const [virtual]

Returns a user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
TextDisplayable

Reimplemented from Ceylan::Maths::Random::RandomGenerator.

Definition at line 259 of file CeylanRandomGeneratorFromPDF.cc.

References _pdf, and Ceylan::Maths::Random::ProbabilityFunction::toString().

Referenced by displayProbabilities().

void LogSource::unlinkTransport (  )  [protected, virtual, inherited]

Suppresses the link between this LogSource and its Log transport.

Definition at line 243 of file CeylanLogSource.cc.

Referenced by Ceylan::Log::LogSource::setTransport(), and Ceylan::Log::LogSource::~LogSource().


Member Data Documentation

std::string Ceylan::Log::LogSource::_channelName [protected, inherited]

LevelOfDetail Ceylan::Log::LogSource::_level [protected, inherited]

TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().

TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().

Internal link to probability function.

Definition at line 162 of file CeylanRandomGeneratorFromPDF.h.

Referenced by preCompute(), and toString().

Where probabilities calculated thanks to the PDF are stored.

Definition at line 176 of file CeylanRandomGeneratorFromPDF.h.

Referenced by displayProbabilities(), preCompute(), and ~RandomGeneratorFromPDF().

Tells how the uniform random space is split into sample areas.

Definition at line 185 of file CeylanRandomGeneratorFromPDF.h.

Referenced by displayProbabilities(), getNewValue(), preCompute(), and ~RandomGeneratorFromPDF().

bool Ceylan::Object::_trackInstance [protected, inherited]

Tells whether this instance's lifecycle should be advertised in log system.

Definition at line 254 of file CeylanObject.h.

Referenced by Ceylan::Object::Object(), Ceylan::Object::toString(), and Ceylan::Object::~Object().

LogTransport* Ceylan::Log::LogSource::_transport [protected, inherited]

The upper limit to output random values (this value is the first that is superior to _lowerLimit and that cannot be drawn).

Definition at line 168 of file CeylanRandomGenerator.h.

Referenced by displayProbabilities(), Ceylan::Maths::Random::WhiteNoiseGenerator::getNewValue(), getNewValue(), preCompute(), Ceylan::Maths::Random::RandomGenerator::RandomGenerator(), and Ceylan::Maths::Random::RandomGenerator::toString().

Internal white noise random generator.

Definition at line 167 of file CeylanRandomGeneratorFromPDF.h.

Referenced by getNewValue(), preCompute(), reset(), and ~RandomGeneratorFromPDF().

const LevelOfDetail Ceylan::Log::LogSource::DefaultLevelOfDetailForSource = 10 [static, inherited]

The default level of detail of a Log source.

Definition at line 221 of file CeylanLogSource.h.

const Seed RandomGenerator::DefaultSeed = 1 [static, inherited]

Default seed to be used.

Default seed for random generators.

Definition at line 135 of file CeylanRandomGenerator.h.

const string Loggable::ProtocolName = "loggable" [static, inherited]


The documentation for this class was generated from the following files:

Generated on Thu Jun 4 20:40:34 2009 for Ceylan by  doxygen 1.5.8