Class PDFSegmentPowerlaw
Defined in File PDFSegmentPowerlaw.hpp
Inheritance Relationships
Base Type
public pdfs::PDFSegment(Class PDFSegment)
Class Documentation
-
class PDFSegmentPowerlaw : public pdfs::PDFSegment
Class representing a power-law segment of a PDF.
This class implements the PDFSegment interface for a power-law distribution, defined by a power-law index. It provides methods to evaluate the PDF at a given point and to sample a random value from the PDF segment according to the power-law distribution.
Public Functions
-
inline PDFSegmentPowerlaw(double sMin, double sMax, double alpha)
Constructor for PDFSegmentPowerlaw.
- Parameters:
sMin – The lower limit of the segment.
sMax – The upper limit of the segment.
alpha – The power-law index of the distribution.
-
PDFSegmentPowerlaw(std::ifstream &file, FileFormats fmt, double &sMin, double &sMax, double &wgt)
Construct PDFSegmentPowerlaw 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
-
PDFSegmentPowerlaw(toml::node_view<const toml::node> node, FileFormats fmt, double &sMin, double &sMax, double &wgt)
Construct PDFSegmentPowerlaw 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
-
PDFSegmentPowerlaw(const PDFSegmentPowerlaw&) = default
-
auto operator=(const PDFSegmentPowerlaw&) -> PDFSegmentPowerlaw& = default
-
PDFSegmentPowerlaw(PDFSegmentPowerlaw&&) = default
-
auto operator=(PDFSegmentPowerlaw&&) -> PDFSegmentPowerlaw& = default
-
~PDFSegmentPowerlaw() override = default
-
inline virtual auto operator()(double x) const -> double override
Evaluate the PDF segment at a 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.
- Parameters:
tbl – The table to write into
-
inline PDFSegmentPowerlaw(double sMin, double sMax, double alpha)