4#ifndef ELEMENTAL_PROFILE_SET_H
5#define ELEMENTAL_PROFILE_SET_H
15#include <gsl/gsl_vector.h>
16#include <gsl/gsl_matrix.h>
51 map<string, element_information>* elementinfo =
nullptr
61 map<string, element_information>* elementinfo
135 const map<string, element_information>* elementinfo,
148 bool exclude_samples,
149 bool exclude_elements,
151 const vector<double>& om_size,
152 const map<string, element_information>* elementinfo =
nullptr
159 bool applyomsizecorrection,
160 const vector<double>& om_size,
161 map<string, element_information>* elementinfo =
nullptr
168 const vector<string>& samples_to_eliminate,
169 map<string, element_information>* elementinfo
260 const double& p_value_threshold = 0.05
267 const string& element,
271 const double& p_value_threshold = 0.05
281 const double& p_value_threshold = 0.05
303 const vector<double>& om_size,
304 map<string, element_information>* elementinfo =
nullptr
393 QTableWidget*
ToTable()
override;
404 bool Read(
const QStringList& strlist)
override;
Matrix class with labeled rows and columns for Chemical Mass Balance analysis.
Vector class with string labels for Chemical Mass Balance analysis.
Manages a collection of concentration measurements with statistical analysis.
Represents a parametric probability distribution for uncertainty quantification.
gsl_matrix * CopyToGSLMatrix() const
Convert to GSL matrix for statistical functions.
double GetEstimatedMu(const string &element) const
Get estimated mu parameter for an element.
CMBMatrix ToMatrix() const
Convert to matrix format (samples × elements).
distribution_type GetAssignedDistribution(const string &element_name) const
Get assigned distribution type for an element.
ConcentrationSet * GetElementDistribution(const string &element_name)
Get distribution for a specific element (mutable).
bool writetofile(QFile *file) override
Write object data to a file.
Elemental_Profile_Set CreateCorrectedSet(bool exclude_samples, bool exclude_elements, bool omnsizecorrect, const vector< double > &om_size, const map< string, element_information > *elementinfo=nullptr) const
Create corrected and filtered subset.
vector< string > GetSampleNames() const
Get all sample names in the set.
Elemental_Profile * AppendProfile(const string &name, const Elemental_Profile &profile=Elemental_Profile(), map< string, element_information > *elementinfo=nullptr)
Add a new sample profile to the set.
Distribution * GetEstimatedDistribution(const string &element_name)
Get estimated distribution for an element (for MCMC optimization).
CMBVector CalculateKolmogorovSmirnovStatistics(distribution_type dist_type)
Calculate Kolmogorov-Smirnov statistics for all elements.
vector< double > GetAllConcentrationsFor(const string &element_name)
Get all concentration values for a specific element across samples.
bool OutlierAnalysisDone() const
Check if outlier analysis has been performed.
ResultItem GetRegressionsAsResult()
Get regressions wrapped in ResultItem for display.
Elemental_Profile SelectTopElementsAggregate(int n) const
Select top N elements across all samples (aggregate minimum).
void UpdateElementDistributions()
Rebuild element distributions from all profiles.
Elemental_Profile_Set & operator=(const Elemental_Profile_Set &other)
vector< string > GetElementNames() const
Get all element names (from first profile).
bool SetContributionSoftmax(const double &value)
Set softmax-transformed contribution.
MultipleLinearRegressionSet * GetRegressionModels()
Get internal regression model set.
double GetMinimum() const
Get minimum concentration across all elements and samples.
vector< double > GetConcentrationsForSample(const string &sample_name) const
Get all element concentrations for a specific sample.
CMBVector CalculateDotProduct(const CVector &v) const
Calculate dot product of each profile with weight vector.
double GetEstimatedSigma(const string &element) const
Get estimated sigma parameter for an element.
Elemental_Profile * GetProfile(const string &name)
Get profile by sample name (mutable).
bool ReadFromJsonObject(const QJsonObject &jsonobject) override
Deserialize object from JSON format.
bool Read(const QStringList &strlist) override
Parse object data from a string list.
MultipleLinearRegression BuildRegressionModel(const string &element, const string &om, const string &d, regression_form form=regression_form::linear, const double &p_value_threshold=0.05)
Build MLR model for single element vs OM and particle size.
bool SetEstimatedMu(const string &element, const double &value)
Set estimated mu parameter for an element.
CMBMatrix CalculateCovarianceMatrix()
Calculate covariance matrix across elements.
bool SetContribution(const double &value)
Set contribution value for this source.
double GetMaximum() const
Get maximum concentration across all elements and samples.
Elemental_Profile_Set ExtractElements(const vector< string > &element_list) const
Create subset with only specified elements.
Elemental_Profile_Set CopyIncludedInAnalysis(bool applyomsizecorrection, const vector< double > &om_size, map< string, element_information > *elementinfo=nullptr)
Copy only samples marked for inclusion in analysis.
bool ContainsElement(const string &element_name) const
Check if an element exists in ALL profiles.
double GetContribution() const
Get contribution value.
MultipleLinearRegressionSet mlr_vs_om_size_
MLR models for OM/size corrections.
QJsonObject toJsonObject() const override
Serialize object to JSON format.
string ToString() const override
Convert object to string representation.
CMBVector CalculateBoxCoxParameters()
Calculate optimal Box-Cox lambda for each element.
double contribution_softmax_
Softmax-transformed contribution.
QTableWidget * ToTable() override
Create a Qt table widget representation of the data.
vector< string > ElementsNotBoxCoxTransformable() const
Elements with a zero or negative value, which Box-Cox leaves untransformed.
CVector CalculateElementMeans(const vector< string > &element_order=vector< string >()) const
Calculate mean concentration for each element.
Distribution * GetFittedDistribution(const string &element_name)
Get fitted distribution for an element (from data, for likelihood).
Elemental_Profile_Set ApplyOrganicMatterAndSizeCorrections(const vector< double > &om_size, map< string, element_information > *elementinfo=nullptr)
Apply OM and particle size corrections to all profiles.
CMBMatrix CalculateCorrelationMatrix()
Calculate correlation matrix across elements.
map< string, ConcentrationSet > element_distributions_
Concentration distributions for each element.
CMBMatrix DetectOutliers(const double &lowerlimit=0, const double &upperlimit=0)
Detect outliers using Box-Cox transformation and standardization.
double GetContributionSoftmax() const
Get softmax-transformed contribution.
Elemental_Profile_Set EliminateSamples(const vector< string > &samples_to_eliminate, map< string, element_information > *elementinfo) const
Create subset excluding specified samples.
MultipleLinearRegressionSet BuildRegressionModels(const string &om, const string &d, regression_form form=regression_form::linear, const double &p_value_threshold=0.05)
Build MLR models for all elements vs OM and particle size.
void SetRegressionModels(const string &om, const string &d, regression_form form=regression_form::linear, const double &p_value_threshold=0.05)
Set regression models (build new).
bool outlierdone_
Flag indicating outlier analysis performed.
double contribution_
Source contribution (for CMB).
Elemental_Profile_Set ApplyBoxCoxTransform(CMBVector *lambda_vals=nullptr)
Apply Box-Cox transformation to all profiles.
vector< string > CheckForNegativeValues(const vector< string > &element_names) const
Check for elements with negative values.
bool SetEstimatedSigma(const string &element, const double &value)
Set estimated sigma parameter for an element.
void AppendProfiles(const Elemental_Profile_Set &profiles, map< string, element_information > *elementinfo)
Add multiple profiles from another set.
Elemental_Profile_Set ExtractChemicalElements(const map< string, element_information > *elementinfo, bool isotopes) const
Create subset with only chemical elements (and optionally isotopes).
Container for elemental concentration data of a single sediment sample.
Interface()
Default constructor.
distribution_type
Enumeration of probability distribution types supported in SedSat3.
Elemental concentration profile for sediment source fingerprinting.