1#ifndef ELEMENTAL_PROFILE_SET_H
2#define ELEMENTAL_PROFILE_SET_H
12#include <gsl/gsl_vector.h>
13#include <gsl/gsl_matrix.h>
48 map<string, element_information>* elementinfo =
nullptr
58 map<string, element_information>* elementinfo
132 const map<string, element_information>* elementinfo,
145 bool exclude_samples,
146 bool exclude_elements,
148 const vector<double>& om_size,
149 const map<string, element_information>* elementinfo =
nullptr
156 bool applyomsizecorrection,
157 const vector<double>& om_size,
158 map<string, element_information>* elementinfo =
nullptr
165 vector<string> samples_to_eliminate,
166 map<string, element_information>* elementinfo
257 const double& p_value_threshold = 0.05
264 const string& element,
268 const double& p_value_threshold = 0.05
278 const double& p_value_threshold = 0.05
300 const vector<double>& om_size,
301 map<string, element_information>* elementinfo =
nullptr
383 QTableWidget*
ToTable()
override;
387 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.
Manages a collection of elemental profiles (samples) for source fingerprinting analysis.
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.
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.
Elemental_Profile_Set EliminateSamples(vector< string > samples_to_eliminate, map< string, element_information > *elementinfo) const
Create subset excluding specified samples.
double GetContributionSoftmax() const
Get softmax-transformed contribution.
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.
Abstract base class providing common serialization and visualization interface.
distribution_type
Enumeration of probability distribution types supported in SedSat3.
Elemental concentration profile for sediment source fingerprinting.