Class PDFSegmentLognormal

Inheritance Relationships

Base Type

Class Documentation

class PDFSegmentLognormal : public pdfs::PDFSegment

Class representing a lognormal segment of a PDF.

This class implements the PDFSegment interface for a lognormal distribution, defined by the mean and standard deviation of the underlying normal distribution. It provides methods to evaluate the PDF at a given point and to sample a random value from the PDF segment according to the lognormal distribution.

Public Functions

inline PDFSegmentLognormal(double sMin, double sMax, double mean, double stddev)

Constructor for PDFSegmentLognormal.

This class represents a distribution that is normal in log(x), but note that, for convenience, the value given by mean is the mean of x, not the mean of log(x). On the other hand, stddev is the standard deviation of log(x). Unlike the descriptor-based constructors below, which take the dispersion in dex and keep that value for toToml() to write back, this one derives it as stddev / ln(10), so a segment built here may round-trip through toToml() with stddev off by one ulp.

Parameters:
  • sMin – The lower limit of the segment.

  • sMax – The upper limit of the segment.

  • mean – The mean of the x (NOT the mean of log(x)).

  • stddev – The standard deviation of the normal distribution (i.e., stddev of log(x)).

PDFSegmentLognormal(std::ifstream &file, FileFormats fmt, double &sMin, double &sMax, double &wgt)

Construct PDFSegmentLognormal from a PDF file contents.

How the arguments are interpreted depends on fmt; if fmt is basic, then sMin and sMax are inputs, and wgt is ignored, while if fmt is advanced, then sMin and sMax are ignored and wgt is an output.

Parameters:
  • file – File stream from which to construct

  • fmt – Format of the file being read

  • sMin – The lower limit of the segment

  • sMax – The upper limit of the segment

  • wgt – The weight of the segment

PDFSegmentLognormal(toml::node_view<const toml::node> node, FileFormats fmt, double &sMin, double &sMax, double &wgt)

Construct PDFSegmentLognormal from a toml-format PDF descriptor.

A toml-based counterpart to the ifstream-based constructor above, interpreting its arguments identically: how they are interpreted depends on fmt; if fmt is basic, then sMin and sMax are inputs, and wgt is ignored, while if fmt is advanced, then sMin and sMax are ignored and wgt is an output.

Parameters:
  • node – A toml node view onto this segment’s own segmentN table (see parsePDFToml)

  • fmt – Format of the descriptor being read

  • sMin – The lower limit of the segment

  • sMax – The upper limit of the segment

  • wgt – The weight of the segment

PDFSegmentLognormal(const PDFSegmentLognormal&) = default
auto operator=(const PDFSegmentLognormal&) -> PDFSegmentLognormal& = default
PDFSegmentLognormal(PDFSegmentLognormal&&) = default
auto operator=(PDFSegmentLognormal&&) -> PDFSegmentLognormal& = default
~PDFSegmentLognormal() override = default
inline virtual auto operator()(double x) const -> double override

Evaluate the PDF segment at a given point.

Parameters:

x – The point at which to evaluate the PDF segment.

Returns:

The value of the PDF segment at the given point.

inline virtual auto expectationValue(const double a, const double b) const -> double override

Calculate the expectation value of the PDF segment.

Parameters:
  • a – The lower limit of the range for expectation value calculation; if set to a value <= sMin, will be set to sMin_.

  • b – The upper limit of the range for expectation value calculation; if set to a value >= sMax, will be set to sMax_.

Returns:

The expectation value of the PDF segment.

inline virtual auto expectationValue() const -> double override

Calculate the expectation value of the PDF segment over its entire range.

Returns:

The expectation value of the PDF segment.

inline virtual auto integral(const double a, const double b) const -> double override

Calculate the integral of the PDF segment over a specified range.

Parameters:
  • a – The lower limit of the range for integral calculation; if set to a value <= sMin, will be set to sMin_.

  • b – The upper limit of the range for integral calculation; if set to a value >= sMax, will be set to sMax_.

Returns:

The integral of the PDF segment over the specified range.

inline virtual auto draw(const double a, const double b) const -> double override

Sample a random value from the PDF segment within a specified range.

Parameters:
  • a – The lower limit of the sampling range (should be >= sMin_).

  • b – The upper limit of the sampling range (should be <= sMax_).

Returns:

A random value drawn from the PDF segment within the specified range.

inline virtual auto draw() const -> double override

Sample a random value from the PDF segment.

Returns:

A random value drawn from the PDF segment.

virtual void toToml(toml::table &tbl) const override

Write this segment’s parameters into a toml table.

See PDFSegment::toToml()

Parameters:

tbl – The table to write into