|
SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
|
Represents a parametric probability distribution for uncertainty quantification. More...
#include <cmbdistribution.h>

Public Member Functions | |
| Distribution () | |
| Default constructor. | |
| Distribution (const Distribution &dist) | |
| Copy constructor. | |
| Distribution & | operator= (const Distribution &dist) |
| Assignment operator. | |
| double | Eval (const double &x) const |
| Evaluate probability density function at a given value. | |
| double | EvalLog (const double &x) |
| Evaluate natural logarithm of probability density. | |
| TimeSeries< double > | EvaluateAsTimeSeries (int numberofpoint=100, const double &stdcoeff=4) |
| Generate time series representation of the distribution for plotting. | |
| void | SetType (const distribution_type &typ) |
| Set the distribution type and resize parameters vector. | |
| double | Mean (parameter_mode param_mode=parameter_mode::based_on_fitted_distribution) |
| Calculate the mean (expected value) of the distribution. | |
| void | SetDataMean (const double &val) |
| Set the empirical mean from original data. | |
| void | SetDataSTDev (const double &val) |
| Set the empirical standard deviation from original data. | |
| double | DataMean () |
| Get the stored empirical mean. | |
| double | DataSTDev () |
| Get the stored empirical standard deviation. | |
| bool | operator== (const string &dist_type) |
| Compare distribution type with a string identifier. | |
Static Public Member Functions | |
| static double | Eval (const double &x, const vector< double > ¶meters, distribution_type distribution) |
| Static method to evaluate PDF with explicit parameters. | |
| static TimeSeries< double > | EvaluateAsTimeSeries (int numberofpoints, const double &stdcoeff, const vector< double > ¶meters, distribution_type &dist_type) |
| Static method to generate time series with explicit parameters. | |
Public Attributes | |
| vector< double > | parameters |
| Distribution parameters vector. | |
| distribution_type | distribution = distribution_type::none |
| The type of probability distribution. | |
Private Attributes | |
| double | mean_val = 0 |
| Empirical mean from original sample data. | |
| double | std_val = 0 |
| Empirical standard deviation from original sample data. | |
Static Private Attributes | |
| static double | pi = 4 * atan(1.0) |
| Mathematical constant π (pi). | |
Represents a parametric probability distribution for uncertainty quantification.
The Distribution class provides:
This class is central to:
Example usage:
Definition at line 98 of file cmbdistribution.h.
| Distribution::Distribution | ( | ) |
Default constructor.
Initializes a Distribution with:
Definition at line 11 of file cmbdistribution.cpp.
Referenced by Distribution(), and operator=().
| Distribution::Distribution | ( | const Distribution & | dist | ) |
Copy constructor.
| dist | The Distribution object to copy from |
Creates a deep copy including:
Definition at line 109 of file cmbdistribution.cpp.
References Distribution(), distribution, mean_val, parameters, pi, SetType(), and std_val.
|
inline |
Get the stored empirical mean.
Definition at line 339 of file cmbdistribution.h.
References mean_val.
Referenced by SourceSinkData::BuildSourceMeanMatrix(), and SourceSinkData::BuildSourceMeanMatrix_Isotopes().
|
inline |
Get the stored empirical standard deviation.
Definition at line 347 of file cmbdistribution.h.
References std_val.
| double Distribution::Eval | ( | const double & | x | ) | const |
Evaluate probability density function at a given value.
| x | The value at which to evaluate the PDF |
Computes the probability density function value. For continuous distributions, this is NOT a probability (which would require integration), but the density at point x.
Normal: p(x) = (1/(√(2π)σ)) × exp(-(x-μ)²/(2σ²))
Lognormal: p(x) = (1/(x√(2π)σ_log)) × exp(-(ln(x)-μ_log)²/(2σ_log²))
Uniform/Dirichlet: p(x) = 1 for x ∈ [0,1], else 1×10⁻³²
Definition at line 16 of file cmbdistribution.cpp.
References dirichlet, distribution, log, lognormal, normal, parameters, pi, uniform, and x.
Referenced by ConcentrationSet::CalculateLogLikelihood(), ConcentrationSet::CreateFittedDistribution(), EvaluateAsTimeSeries(), and EvaluateAsTimeSeries().
|
static |
Static method to evaluate PDF with explicit parameters.
| x | The value at which to evaluate |
| parameters | Distribution parameters [μ, σ] or [μ_log, σ_log] |
| distribution | The distribution type |
Utility function for evaluating PDFs without creating a Distribution object. Useful for one-off calculations or testing.
Example:
Definition at line 29 of file cmbdistribution.cpp.
References dirichlet, distribution, log, lognormal, normal, parameters, pi, uniform, and x.
| double Distribution::EvalLog | ( | const double & | x | ) |
Evaluate natural logarithm of probability density.
| x | The value at which to evaluate |
Computes the log-probability density, which is numerically more stable than Eval() for Bayesian inference. This prevents underflow when multiplying many small probabilities and is faster (avoids division and some exponentials).
Normal: ln(p(x)) = -ln(√(2π)σ) - (x-μ)²/(2σ²)
Lognormal: ln(p(x)) = -ln(√(2π)σ_log×x) - (ln(x)-μ_log)²/(2σ_log²)
Uniform/Dirichlet: ln(p(x)) = 0 for x ∈ [0,1], else -1×10⁶ (effectively -∞)
Log-posterior = log-likelihood + log-prior:
Definition at line 42 of file cmbdistribution.cpp.
References dirichlet, distribution, log, lognormal, normal, parameters, pi, uniform, and x.
Referenced by SourceSinkData::LogLikelihoodSourceElementalDistributions().
| TimeSeries< double > Distribution::EvaluateAsTimeSeries | ( | int | numberofpoint = 100, |
| const double & | stdcoeff = 4 ) |
Generate time series representation of the distribution for plotting.
| numberofpoint | Number of points to generate (default: 100) |
| stdcoeff | Number of standard deviations to span (default: 4, i.e., ±4σ) |
Creates a discrete representation of the PDF suitable for plotting in GUI. The x-values span from (μ - stdcoeff×σ) to (μ + stdcoeff×σ) for normal distributions, or the equivalent in log-space for lognormal distributions.
Example:
Definition at line 56 of file cmbdistribution.cpp.
References distribution, Eval(), lognormal, normal, parameters, and x.
|
static |
Static method to generate time series with explicit parameters.
| numberofpoints | Number of points to generate |
| stdcoeff | Number of standard deviations to span |
| parameters | Distribution parameters [μ, σ] or [μ_log, σ_log] |
| dist_type | The distribution type |
Static version of EvaluateAsTimeSeries() for generating curves without creating a Distribution object.
Definition at line 82 of file cmbdistribution.cpp.
References Eval(), lognormal, normal, parameters, and x.
| double Distribution::Mean | ( | parameter_mode | param_mode = parameter_mode::based_on_fitted_distribution | ) |
Calculate the mean (expected value) of the distribution.
| param_mode | Whether to use empirical data or distribution parameters |
Computes the expected value based on the selected mode:
direct mode: Returns the stored empirical mean (mean_val) from original data
based_on_fitted_distribution mode (default):
Definition at line 139 of file cmbdistribution.cpp.
References direct, distribution, lognormal, mean_val, normal, and parameters.
Referenced by SourceSinkData::BuildSourceMeanMatrix(), SourceSinkData::BuildSourceMeanMatrix_Isotopes(), and SourceSinkData::IsotopeBaseMean().
| Distribution & Distribution::operator= | ( | const Distribution & | dist | ) |
Assignment operator.
| dist | The Distribution object to copy from |
Copies all distribution data and reinitializes pi constant.
Definition at line 118 of file cmbdistribution.cpp.
References Distribution(), distribution, mean_val, parameters, pi, SetType(), and std_val.
| bool Distribution::operator== | ( | const string & | dist_type | ) |
Compare distribution type with a string identifier.
| dist_type | String name of distribution ("normal", "log-normal", "uniform", "dirichlet") |
Convenience method for string-based type checking, useful for configuration file parsing or user input validation.
Recognized strings:
Example:
Definition at line 152 of file cmbdistribution.cpp.
References dirichlet, distribution, lognormal, normal, and uniform.
|
inline |
Set the empirical mean from original data.
| val | The empirical mean value |
Stores the sample mean calculated directly from observed data, independent of the fitted distribution parameters.
Definition at line 320 of file cmbdistribution.h.
References mean_val.
|
inline |
Set the empirical standard deviation from original data.
| val | The empirical standard deviation |
Stores the sample standard deviation calculated directly from observed data, independent of the fitted distribution parameters.
Definition at line 331 of file cmbdistribution.h.
References std_val.
| void Distribution::SetType | ( | const distribution_type & | typ | ) |
Set the distribution type and resize parameters vector.
| typ | The distribution type to set |
Sets the distribution type and automatically resizes the parameters vector:
Definition at line 129 of file cmbdistribution.cpp.
References distribution, lognormal, normal, and parameters.
Referenced by Distribution(), SourceSinkData::InitializeParametersAndObservations(), and operator=().
| distribution_type Distribution::distribution = distribution_type::none |
The type of probability distribution.
Determines which PDF formula to use in Eval() and EvalLog(). Default is distribution_type::none (uninitialized).
Definition at line 278 of file cmbdistribution.h.
Referenced by Distribution(), SourceSinkData::AssignAllDistributions(), ConcentrationSet::CalculateLogLikelihood(), Eval(), Eval(), EvalLog(), EvaluateAsTimeSeries(), Mean(), operator=(), operator==(), and SetType().
|
private |
Empirical mean from original sample data.
Stores the sample mean calculated directly from observed tracer concentrations or other measured data. This is independent of any fitted distribution parameters and represents the actual data statistics.
Used when param_mode::direct is specified in Mean().
Definition at line 394 of file cmbdistribution.h.
Referenced by Distribution(), DataMean(), Mean(), operator=(), and SetDataMean().
| vector<double> Distribution::parameters |
Distribution parameters vector.
Storage for distribution-specific parameters:
Definition at line 270 of file cmbdistribution.h.
Referenced by Distribution(), SourceSinkData::AssignAllDistributions(), ConcentrationSet::CalculateLogLikelihood(), Eval(), Eval(), EvalLog(), EvaluateAsTimeSeries(), EvaluateAsTimeSeries(), SourceSinkData::InitializeParametersAndObservations(), Mean(), operator=(), and SetType().
|
staticprivate |
Mathematical constant π (pi).
Computed once as 4×arctan(1) ≈ 3.14159265359 Used in normal and lognormal PDF calculations.
Definition at line 383 of file cmbdistribution.h.
Referenced by Distribution(), Eval(), Eval(), EvalLog(), and operator=().
|
private |
Empirical standard deviation from original sample data.
Stores the sample standard deviation calculated directly from observations. Represents actual data variability independent of fitted distribution.
Definition at line 402 of file cmbdistribution.h.
Referenced by Distribution(), DataSTDev(), operator=(), and SetDataSTDev().