19 #include "Param/Distrib/Distributions.h"
20 #include "Param/Distrib/RangedDistributions.h"
25 m_numberOfSamples.init(
"Number of samples",
"", 5,
"", RealLimits::lowerLimited(1.0),
36 m_sigmaFactor.init(
"Sigma factor",
"", 2.0,
Unit::unitless,
"sigmaFactor");
47 return m_sigmaFactor.isInitialized();
70 const QString& meanLabel)
72 m_mean.init(meanLabel,
"", mean,
Unit::unitless, decimals, RealLimits::limitless(),
"mean");
89 m_mean.setDecimals(d);
128 m_minimum.init(
"Min",
"", 0.0,
Unit::unitless, 3, RealLimits::limitless(),
"min");
129 m_maximum.init(
"Max",
"", 1.0,
Unit::unitless, 3, RealLimits::limitless(),
"max");
137 m_minimum.setUnit(unit);
138 m_maximum.setUnit(unit);
143 return std::make_unique<DistributionGate>(scale * m_minimum, scale * m_maximum);
148 double sigma(0.1 * std::abs(value));
151 m_minimum.set(value - sigma);
152 m_maximum.set(value + sigma);
163 return {minimum(), maximum()};
180 m_hwhm.setUnit(unit);
185 return std::make_unique<DistributionLorentz>(scale * m_mean, scale * m_hwhm);
188 std::unique_ptr<IRangedDistribution>
191 return std::make_unique<RangedDistributionLorentz>(numberOfSamples(), sigmaFactor(),
197 return m_hwhm * scale;
202 double hw(0.1 * std::abs(value));
208 m_hwhm.setLimits(RealLimits::lowerLimited(0.0));
224 m_standardDeviation.init(
"StdDev",
"", 1.0,
Unit::unitless, 3, RealLimits::lowerLimited(0.0),
232 m_standardDeviation.setUnit(unit);
237 return std::make_unique<DistributionGaussian>(scale * m_mean, scale * m_standardDeviation);
240 std::unique_ptr<IRangedDistribution>
243 return std::make_unique<RangedDistributionGaussian>(numberOfSamples(), sigmaFactor(),
249 return standardDeviation() * scale;
254 double stddev(0.1 * std::abs(value));
259 setStandardDeviation(stddev);
275 m_scaleParameter.init(
"ScaleParameter",
"", 1.0,
Unit::unitless, 3,
276 RealLimits::lowerLimited(0.0),
"scalePar");
284 m_median.setUnit(unit);
289 return std::make_unique<DistributionLogNormal>(scale * median(), scaleParameter());
294 double scale(0.1 * std::abs(value));
299 setScaleParameter(scale);
304 return {median(), scaleParameter(), sigmaFactor()};
313 m_sigma.init(
"Sigma",
"", 1.0,
Unit::unitless, 3, RealLimits::lowerLimited(0.0),
"sigma");
320 m_sigma.setUnit(unit);
325 return std::make_unique<DistributionCosine>(scale * m_mean, scale * sigma());
328 std::unique_ptr<IRangedDistribution>
331 return std::make_unique<RangedDistributionCosine>(numberOfSamples(), sigmaFactor(),
337 return sigma() * scale;
342 double sigma(0.1 * std::abs(value));
361 m_center.init(
"Center",
"", 1.0,
Unit::unitless, 3, RealLimits::limitless(),
"center");
363 m_middleWidth.init(
"MiddleWidth",
"", 1.0,
Unit::unitless,
"middle");
364 m_rightWidth.init(
"RightWidth",
"", 1.0,
Unit::unitless,
"right");
374 m_center.setUnit(unit);
375 m_leftWidth.setUnit(unit);
376 m_middleWidth.setUnit(unit);
377 m_rightWidth.setUnit(unit);
382 return std::make_unique<DistributionTrapezoid>(scale * center(), scale * leftWidth(),
383 scale * middleWidth(), scale * rightWidth());
388 double width(0.1 * std::abs(value));
393 setMiddleWidth(width);
394 setRightWidth(width);
399 return withMean ?
DoubleDescriptors{center(), leftWidth(), middleWidth(), rightWidth()}
Defines class DistributionItem and several subclasses.
Defines class DoubleDescriptor.
QList< DoubleDescriptor > DoubleDescriptors
void setUnit(const variant< QString, Unit > &unit) override
Set the unit of the distributed value.
double deviation(double scale) const override
std::unique_ptr< IRangedDistribution > createIRangedDistribution(double scale) const override
DoubleDescriptors distributionValues(bool withMean=true) const override
void initDistribution(double value) override
std::unique_ptr< IDistribution1D > createDistribution(double scale=1.0) const override
DoubleDescriptors distributionValues(bool withMean=true) const override
void setRange(double min, double max)
std::unique_ptr< IDistribution1D > createDistribution(double scale=1.0) const override
void setUnit(const variant< QString, Unit > &unit) override
Set the unit of the distributed value.
void initDistribution(double value) override
std::unique_ptr< IDistribution1D > createDistribution(double scale=1.0) const override
void initDistribution(double value) override
DistributionGaussianItem()
double deviation(double scale) const override
std::unique_ptr< IRangedDistribution > createIRangedDistribution(double scale) const override
void setUnit(const variant< QString, Unit > &unit) override
Set the unit of the distributed value.
DoubleDescriptors distributionValues(bool withMean=true) const override
void serialize(Streamer &s)
Serialization of contents.
RealLimits limits() const
void addToSerialization(DoubleProperty *d)
bool hasSigmaFactor() const
virtual void setLimits(const RealLimits &limits)
QVector< DoubleProperty * > m_serializationProperties
void initDistribution(double value) override
DoubleDescriptors distributionValues(bool withMean=true) const override
std::unique_ptr< IDistribution1D > createDistribution(double scale=1.0) const override
DistributionLogNormalItem()
void setUnit(const variant< QString, Unit > &unit) override
Set the unit of the distributed value.
void initDistribution(double value) override
double deviation(double scale) const override
DoubleDescriptors distributionValues(bool withMean=true) const override
std::unique_ptr< IDistribution1D > createDistribution(double scale=1.0) const override
std::unique_ptr< IRangedDistribution > createIRangedDistribution(double scale) const override
void setUnit(const variant< QString, Unit > &unit) override
Set the unit of the distributed value.
DistributionLorentzItem()
std::unique_ptr< IDistribution1D > createDistribution(double scale=1.0) const override
DoubleDescriptors distributionValues(bool withMean=true) const override
double deviation(double scale) const override
void initDistribution(double value) override
std::unique_ptr< IRangedDistribution > createIRangedDistribution(double scale) const override
void setUnit(const variant< QString, Unit > &unit) override
Set the unit of the distributed value.
DistributionTrapezoidItem()
std::unique_ptr< IDistribution1D > createDistribution(double scale=1.0) const override
void initDistribution(double value) override
DoubleDescriptors distributionValues(bool withMean=true) const override
Class for representing a double value, its attributes and its accessors.
Supports serialization to or deserialization from QXmlStream.
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
void setLimits(const RealLimits &limits) override
void setUnit(const variant< QString, Unit > &unit) override
Set the unit of the distributed value.
SymmetricResolutionItem(double mean, int decimals=3, const QString &meanLabel="Mean")
void setMeanDecimals(uint d)
void rwProperty(Streamer &s, DoubleProperty &d)