|
SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
|
#include <sourcesinkdata.h>


Public Member Functions | |
| SourceSinkData () | |
| Default constructor. | |
| SourceSinkData (const SourceSinkData &other) | |
| Copy constructor. | |
| SourceSinkData & | operator= (const SourceSinkData &other) |
| Assignment operator. | |
| void | Clear () |
| Clear all data from the object. | |
| Elemental_Profile_Set * | AppendSampleSet (const string &name, const Elemental_Profile_Set &elemental_profile_set=Elemental_Profile_Set()) |
| Add a new sample set (source or target group) to the dataset. | |
| vector< string > | SourceGroupNames () const |
| Retrieves the names of all source groups (excluding target). | |
| bool | SetSelectedTargetSample (const string &sample_name) |
| Sets the currently selected target sample for analysis. | |
| Elemental_Profile_Set * | GetSampleSet (const string &name) |
| Get a sample set (source or target group) by name. | |
| bool | SetTargetGroup (const string &targroup) |
| Sets the target/sink group designation. | |
| string | GetTargetGroup () const |
| Retrieves the name of the target group. | |
| SourceSinkData | CreateCorrectedDataset (const string &target, bool omnsizecorrect, map< string, element_information > *elementinfo) |
| Create a corrected copy of the dataset for a specific target sample. | |
| SourceSinkData | CreateCorrectedAndFilteredDataset (bool exclude_samples, bool exclude_elements, bool omnsizecorrect, const string &target="") const |
| Create a corrected and filtered copy of the dataset. | |
| SourceSinkData | CreateTracerDataset (bool exclude_samples, bool exclude_elements, bool omnsizecorrect, const string &target="") const |
| As CreateCorrectedAndFilteredDataset, keeping only the tracers. | |
| SourceSinkData | ExtractChemicalElements (bool isotopes) const |
| Extract only chemical elements (and optionally isotopes). | |
| SourceSinkData | BoxCoxTransformed (bool calculate_optimal_lambda=false) |
| Applies Box-Cox transformation to all source groups for normalization. | |
| map< string, element_information > * | GetElementInformation () |
| Retrieves pointer to the element information map. | |
| void | IncludeExcludeElementsBasedOn (const vector< string > &elements) |
| Sets element inclusion based on a specified list. | |
| Distribution * | GetFittedDistribution (const string &element_name) |
| Get the fitted distribution for a specific element at dataset level. | |
| bool | PerformRegressionVsOMAndSize (const string &om, const string &particle_size, regression_form form, const double &p_value_threshold=0.05) |
| Performs multiple linear regression of elements vs OM and particle size. | |
| vector< string > | OMandSizeConstituents () |
| Retrieves the names of OM and particle size constituents. | |
| vector< ResultItem > | GetMLRResults () |
| Retrieves multiple linear regression results for all sample groups. | |
| string | FirstOMConstituent () |
| Retrieves the name of the first organic matter constituent. | |
| string | FirstSizeConstituent () |
| Retrieves the name of the first particle size constituent. | |
| void | SetOMandSizeConstituents (const string &_omconstituent, const string &_sizeconstituent) |
| Sets the names of OM and particle size constituents. | |
| void | SetOMandSizeConstituents (const vector< string > &_omsizeconstituents) |
| Sets the names of OM and particle size constituents from a vector. | |
| void | OutlierAnalysisForAll (const double &lower_threshold=-3, const double &upper_threshold=3) |
| Performs outlier detection on all source groups. | |
| vector< string > | NegativeValueCheck () |
| Checks for zero or negative concentration values across all sources. | |
| vector< string > | NegativeContributionCheck () |
| Checks the solved source contributions for negative values. | |
| CMBVector | BracketTest (const string &target_sample, bool correct_based_on_om_n_size, double tolerance=0) |
| Performs bracket test to check if target concentrations fall within source ranges. | |
| CMBMatrix | BracketTest (bool correct_based_on_om_n_size, bool exclude_elements, bool exclude_samples, double tolerance=0) |
| Performs bracket test on all target samples. | |
| DFA_result | DiscriminantFunctionAnalysis () |
| Performs discriminant function analysis for all source groups. | |
| DFA_result | DiscriminantFunctionAnalysis (const string &source1, const string &source2) |
| Performs discriminant function analysis between two specific sources. | |
| DFA_result | DiscriminantFunctionAnalysis (const string &source1) |
| Performs discriminant function analysis for one source vs all others. | |
| vector< CMBVector > | StepwiseDiscriminantFunctionAnalysis (const string &source1, const string &source2) |
| Performs stepwise discriminant analysis between two specific sources. | |
| vector< CMBVector > | StepwiseDiscriminantFunctionAnalysis () |
| Performs stepwise discriminant analysis across all source groups. | |
| vector< CMBVector > | StepwiseDiscriminantFunctionAnalysis (const string &source1) |
| Performs stepwise discriminant analysis for one source vs all others. | |
| Elemental_Profile_Set | DifferentiationPower (bool use_log, bool include_target) |
| Computes differentiation power for all source pairs. | |
| Elemental_Profile_Set | DifferentiationPower_Percentage (bool include_target) |
| Computes rank-based differentiation percentage for all source pairs. | |
| Elemental_Profile_Set | DifferentiationPower_P_value (bool include_target) |
| Computes t-test p-values for all source pairs. | |
| Elemental_Profile | DifferentiationPower_Percentage (const string &source1, const string &source2) |
| Computes rank-based differentiation percentage between two sources. | |
| Elemental_Profile | DifferentiationPower (const string &source1, const string &source2, bool use_log) |
| Computes differentiation power metric between two sources. | |
| Elemental_Profile | t_TestPValue (const string &source1, const string &source2, bool use_log) |
| Computes t-test p-values for element-wise differences between two sources. | |
| CMBVector | ANOVA (bool use_log) |
| Performs one-way ANOVA for all elements across source groups. | |
| ANOVA_info | ANOVA (const string &element, bool use_log) |
| Performs one-way ANOVA for a single element across source groups. | |
| string | GetParameterName (int index) const |
| Get the name of a parameter by its index. | |
| bool | InitializeParametersAndObservations (const string &targetsamplename, estimation_mode est_mode=estimation_mode::elemental_profile_and_contribution) |
| Initialize parameters and observations for MCMC optimization. | |
| void | SetParameterEstimationMode (estimation_mode est_mode) |
| Sets the estimation mode for parameter optimization. | |
| bool | SetParameterValue (size_t index, double value) |
| Sets a parameter value and updates corresponding model components. | |
| void | SetProgressReporter (ProgressReporter *_rtw) |
| Sets the progress window for displaying optimization progress. | |
| bool | SolveLevenberg_Marquardt (transformation trans=transformation::linear) |
| Solves for optimal source contributions using the Levenberg-Marquardt algorithm. | |
| CMBTimeSeriesSet | LM_Batch (transformation transform, bool apply_om_size_correction, map< string, vector< string > > &negative_elements) |
| Solves CMB model for all target samples using Levenberg-Marquardt. | |
| CVector | GetPredictedValues () |
| Retrieves predicted values for all observations. | |
| CVector | GradientUpdate (estimation_mode estmode=estimation_mode::elemental_profile_and_contribution) |
| Performs one gradient ascent step with adaptive step size. | |
| Results | MCMC (const string &target_sample, map< string, string > arguments, CMCMC< SourceSinkData > *mcmc, ProgressReporter *progress_window, const string &working_folder) |
| Performs Markov Chain Monte Carlo analysis for Bayesian source apportionment. | |
| CMBMatrix | MCMC_Batch (const map< string, string > &arguments, CMCMC< SourceSinkData > *mcmc, ProgressReporter *progress_window, const string &working_folder, vector< string > *failed_writes=nullptr) |
| Performs batch MCMC analysis on all target samples. | |
| double | GetObjectiveFunctionValue () |
| Returns the objective function value for optimization algorithms. | |
| double | LogLikelihood (estimation_mode est_mode=estimation_mode::elemental_profile_and_contribution) |
| Calculates the total log-likelihood for Bayesian source apportionment. | |
| CMBTimeSeriesSet | BootStrap (const double &percentage, unsigned int num_iterations, const string &target_sample, bool use_softmax, std::uint64_t seed=DefaultRandomSeed) |
| Performs bootstrap uncertainty analysis on source contributions. | |
| bool | BootStrap (Results *results, const double &percentage, unsigned int num_iterations, const string &target_sample, bool use_softmax, std::uint64_t seed=DefaultRandomSeed) |
| Performs bootstrap analysis and generates comprehensive uncertainty results. | |
| CMBTimeSeriesSet | VerifySource (const string &source_group, bool use_softmax, bool apply_om_size_correction) |
| Performs leave-one-out validation on a source group. | |
| ResultItem | GetContribution () |
| Packages source contributions into a ResultItem for output. | |
| ResultItem | GetObservedElementalProfile () |
| Retrieves the observed elemental concentrations for the selected target sample. | |
| ResultItem | GetObservedElementalProfile_Isotope () |
| Retrieves the observed isotope delta values for the selected target sample. | |
| ResultItem | GetPredictedElementalProfile (parameter_mode param_mode=parameter_mode::based_on_fitted_distribution) |
| Generates predicted elemental concentrations for the target sample. | |
| ResultItem | GetPredictedElementalProfile_Isotope (parameter_mode param_mode=parameter_mode::based_on_fitted_distribution) |
| Generates predicted isotope delta values for the target sample. | |
| ResultItem | GetObservedvsModeledElementalProfile (parameter_mode param_mode=parameter_mode::based_on_fitted_distribution) |
| Creates a comparison of observed vs modeled elemental profiles. | |
| ResultItem | GetObservedvsModeledElementalProfile_Isotope (parameter_mode param_mode=parameter_mode::based_on_fitted_distribution) |
| Creates a comparison of observed vs modeled isotope delta values. | |
| ResultItem | GetCalculatedElementMeans () |
| Computes estimated mean concentrations for all source elements. | |
| ResultItem | GetCalculatedElementSigma () |
| Computes estimated standard deviations for all source elements. | |
| ResultItem | GetCalculatedElementMu () |
| Computes μ parameters from fitted log-normal distributions for source elements. | |
| ResultItem | GetEstimatedElementMu () |
| Retrieves estimated μ parameters from Bayesian inference for source elements. | |
| ResultItem | GetEstimatedElementMean () |
| Computes actual mean concentrations from estimated log-normal parameters. | |
| ResultItem | GetEstimatedElementSigma () |
| Retrieves estimated σ parameters from Bayesian inference for source elements. | |
| vector< ResultItem > | GetSourceProfiles () |
| Retrieves elemental profiles for all source groups. | |
| void | AddtoToolsUsed (const string &tool) |
| Adds a tool name to the list of tools used in analysis. | |
| vector< Parameter > & | Parameters () |
| Retrieves reference to the parameters vector. | |
| size_t | ParametersCount () |
| Returns the number of parameters. | |
| size_t | ObservationsCount () |
| Returns the number of observations. | |
| Parameter * | parameter (size_t i) |
| Retrieves pointer to a parameter by index. | |
| const Parameter * | parameter (size_t i) const |
| Retrieves const pointer to a parameter by index. | |
| Observation * | observation (size_t i) |
| Retrieves pointer to an observation by index. | |
| estimation_mode | ParameterEstimationMode () |
| Retrieves the current estimation mode. | |
| ConcentrationSet * | GetElementDistribution (const string &element_name) |
| Retrieves pointer to element distribution at dataset level. | |
| ConcentrationSet * | GetElementDistribution (const string &element_name, const string &sample_group) |
| Retrieves pointer to element distribution for a specific group. | |
| element_information * | GetElementInformation (const string &element_name) |
| Retrieves pointer to element information metadata by name. | |
| void | PopulateElementDistributions () |
| Populate element distributions from all groups. | |
| void | PopulateElementInformation (const map< string, element_information > *ElementInfo=nullptr) |
| Populate element information metadata. | |
| void | AssignAllDistributions () |
| Assign distributions to all elements at both dataset and group levels. | |
| int | CountElements (bool exclude_elements) const |
| Count the number of elements in the dataset. | |
| vector< string > | GetSampleNames (const string &group_name) const |
| Get all sample names within a specific group. | |
| vector< string > | GetGroupNames () const |
| Get all group names in the dataset. | |
| vector< string > | GetElementNames () const |
| Get all element names in the dataset. | |
| void | IncludeExcludeAllElements (bool include_in_analysis) |
| Sets inclusion flag for all elements. | |
| Elemental_Profile | Sample (const string &sample_name) const |
| Retrieves an elemental profile by sample name. | |
| profiles_data | ExtractConcentrationData (const vector< vector< string > > &indicators) const |
| Extract concentration data for specified samples. | |
| Elemental_Profile_Set | ExtractSamplesAsProfileSet (const vector< vector< string > > &indicators) const |
| Extract samples as an Elemental_Profile_Set. | |
| element_data | ExtractElementConcentrations (const string &element, const string &group) const |
| Extract concentration data for a specific element from a group. | |
| map< string, vector< double > > | ExtractElementDataByGroup (const string &element) const |
| Extract concentration data for a specific element from all groups. | |
| SourceSinkData | ExtractSpecificElements (const vector< string > &element_list) const |
| Extract specific elements from source groups. | |
| map< string, ConcentrationSet > | ExtractConcentrationSet () |
| Extracts concentration distributions for all elements across sources. | |
| vector< string > | ElementsToBeUsedInCMB () |
| Identifies chemical elements to be used in CMB analysis. | |
| vector< string > | IsotopesToBeUsedInCMB () |
| Identifies isotopes to be used in CMB analysis. | |
| vector< string > | IsotopesWithUnusableBaseElement () const |
| Lists the isotopes included in the analysis whose base element cannot be used. | |
| CMBMatrix | DFAConfusionMatrix () |
| Leave-one-out confusion matrix of the source samples. | |
| double | IsotopeBaseMean (Elemental_Profile_Set *source_group, const string &base_element, parameter_mode param_mode) |
| Mean content of an isotope's base element in one source group. | |
| void | PopulateConstituentOrders () |
| Populates all element ordering vectors used throughout CMB analysis. | |
| string | SelectedTargetSample () const |
| Retrieves the name of the currently selected target sample. | |
| bool | ToolsUsed (const string &tool_name) |
| Checks if a specific analysis tool has been used. | |
| string | GetOutputPath () const |
| Get the output directory path. | |
| QMap< QString, double > * | GetOptions () |
| Retrieves pointer to the options map. | |
| bool | SetOutputPath (const string &output_path) |
| Set the output directory path. | |
| QJsonObject | ElementInformationToJsonObject () const |
| Exports element information metadata to a JSON object. | |
| QJsonArray | ToolsUsedToJsonObject () const |
| Exports the list of analysis tools used to a JSON array. | |
| QJsonObject | OptionsToJsonObject () const |
| Exports analysis options/settings to a JSON object. | |
| bool | ReadToolsUsedFromJsonObject (const QJsonArray &jsonarray) |
| Deserializes the list of analysis tools from a JSON array. | |
| bool | ReadElementInformationfromJsonObject (const QJsonObject &jsonobject) |
| Deserializes element information metadata from a JSON object. | |
| bool | ReadElementDatafromJsonObject (const QJsonObject &jsonobject) |
| Deserializes elemental profile data from a JSON object. | |
| bool | ReadElementDatafromJsonObject (const QJsonObject &jsonobject, QString &error) |
| As ReadElementDatafromJsonObject(), reporting a refused value. | |
| bool | ReadOptionsfromJsonObject (const QJsonObject &jsonobject) |
| Deserializes analysis options from a JSON object. | |
| QJsonObject | ElementDataToJsonObject () const |
| Exports all elemental profile data to a JSON object. | |
| bool | WriteDataToFile (QFile *file) |
| Writes elemental profile data to a text file. | |
| bool | WriteToFile (QFile *file) |
| Writes dataset to a text file. | |
| bool | ReadFromFile (QFile *fil) |
| Loads complete dataset from a JSON file. | |
| const QString & | LoadError () const |
| Why the last ReadFromFile() failed, or empty if it succeeded. | |
| QString | Role (const element_information::role &role) const |
| Converts element role enum to string representation. | |
| element_information::role | Role (const QString &role_string) const |
| Converts string representation to element role enum. | |
Private Member Functions | |
| Elemental_Profile * | GetElementalProfile (const string &sample_name) |
| Finds and retrieves an elemental profile by sample name. | |
| double | GetParameterValue (size_t index) const |
| Retrieves a single parameter value by index. | |
| bool | SetParameterValue (const CVector &values) |
| Sets multiple parameter values from a vector. | |
| CVector | GetParameterValue () const |
| Retrieves all current parameter values as a vector. | |
| bool | InitializeContributionsRandomly (RandomStream &stream) |
| Initialize source contributions randomly (linear constraint). | |
| bool | InitializeContributionsRandomlySoftmax (RandomStream &stream) |
| Initialize source contributions randomly (softmax transformation). | |
| CVector | GetSourceContributions () |
| Retrieves the contributions from all sources. | |
| CVector | GetContributionVector (bool include_all=true) |
| Retrieves the current source contribution fractions. | |
| CVector | GetContributionVectorSoftmax () |
| Retrieves the softmax parameters for source contributions. | |
| void | SetContribution (size_t source_index, double contribution_value) |
| Sets a single source contribution value. | |
| void | SetContributionSoftmax (size_t source_index, double softmax_value) |
| Sets a single softmax parameter value. | |
| void | SetContribution (const CVector &contributions) |
| Sets all source contributions from a vector. | |
| void | SetContributionSoftmax (const CVector &softmax_params) |
| Sets all source contributions using softmax transformation. | |
| Parameter * | GetElementDistributionMuParameter (size_t element_index, size_t source_index) |
| Retrieves pointer to the μ (mean) parameter for an element distribution. | |
| Parameter * | GetElementDistributionSigmaParameter (size_t element_index, size_t source_index) |
| Retrieves pointer to the σ (std dev) parameter for an element distribution. | |
| double | GetElementDistributionMuValue (size_t element_index, size_t source_index) |
| Retrieves the current value of the μ parameter for an element distribution. | |
| double | GetElementDistributionSigmaValue (size_t element_index, size_t source_index) |
| Retrieves the current value of the σ parameter for an element distribution. | |
| CVector | ObservedDataforSelectedSample (const string &SelectedTargetSample="") |
| Retrieves the observed elemental data for a selected target sample. | |
| CVector | ObservedDataforSelectedSample_Isotope (const string &SelectedTargetSample="") |
| Retrieves the observed isotopic data for a selected target sample. | |
| CVector | ObservedDataforSelectedSample_Isotope_delta (const string &SelectedTargetSample="") |
| Retrieves the observed isotopic data in delta notation. | |
| CVector | PredictTarget (parameter_mode param_mode=parameter_mode::direct) |
| Predicts target sample elemental concentrations based on source contributions. | |
| CVector | PredictTarget_Isotope (parameter_mode param_mode=parameter_mode::direct) |
| Predicts target sample isotopic compositions based on source contributions. | |
| CVector | PredictTarget_Isotope_delta (parameter_mode param_mode=parameter_mode::based_on_fitted_distribution) |
| Predicts target sample isotopic compositions in delta notation. | |
| CMatrix | BuildSourceMeanMatrix (parameter_mode param_mode=parameter_mode::based_on_fitted_distribution) |
| Builds the source mean concentration matrix for chemical elements. | |
| CMatrix | BuildSourceMeanMatrix_Isotopes (parameter_mode param_mode=parameter_mode::based_on_fitted_distribution) |
| Builds the source mean concentration matrix for isotopes. | |
| double | LogPriorContributions () |
| Calculates the log prior probability for source contributions. | |
| double | LogLikelihoodSourceElementalDistributions () |
| Calculates the log-likelihood of source elemental distributions. | |
| double | LogLikelihoodModelvsMeasured (estimation_mode est_mode=estimation_mode::elemental_profile_and_contribution) |
| Calculates the log-likelihood of the model prediction versus measured data. | |
| double | LogLikelihoodModelvsMeasured_Isotope (estimation_mode est_mode=estimation_mode::elemental_profile_and_contribution) |
| Calculates the log-likelihood of model versus measured isotopic data. | |
| CVector | Gradient (const CVector ¶meters, estimation_mode est_mode) |
| Computes the normalized gradient of the log-likelihood function. | |
| CVector | ResidualVector () |
| Calculates the combined residual vector for elemental and isotopic predictions. | |
| CVector_arma | ResidualVector_arma () |
| Calculates the combined residual vector using Armadillo vector format. | |
| CMatrix_arma | ResidualJacobian_arma () |
| Calculates the Jacobian matrix of residuals with respect to contributions (Armadillo). | |
| CMatrix | ResidualJacobian () |
| Calculates the Jacobian matrix of residuals with respect to contributions. | |
| CMatrix | ResidualJacobian_softmax () |
| Calculates the Jacobian using softmax parameterization of contributions. | |
| CVector | OneStepLevenberg_Marquardt (double lambda) |
| Performs one iteration of the Levenberg-Marquardt optimization algorithm. | |
| CVector | OneStepLevenberg_Marquardt_softmax (double lambda) |
| Performs one iteration of Levenberg-Marquardt using softmax parameterization. | |
| vector< string > | GetSourceOrder () const |
| Retrieves the ordering of source groups. | |
| vector< string > | SamplesetsOrder () |
| Retrieves the ordering of sample sets. | |
| vector< string > | ConstituentOrder () |
| Retrieves the ordering of all constituents. | |
| vector< string > | ElementOrder () |
| Retrieves the ordering of chemical elements. | |
| vector< string > | IsotopeOrder () |
| Retrieves the ordering of isotopes. | |
| vector< string > | SizeOMOrder () |
| Retrieves the ordering of size and OM constituents. | |
| int | TotalNumberofSourceSamples () const |
| Counts the total number of source samples across all source groups. | |
| double | GrandMean (const string &element, bool use_log) |
| Computes grand mean concentration for an element across all sources. | |
| Elemental_Profile_Set | LumpAllProfileSets () |
| Combines all source samples into a single profile set. | |
| CMBVector | OptimalBoxCoxParameters () |
| Computes optimal Box-Cox transformation parameters for all elements. | |
| SourceSinkData | RandomlyEliminateSourceSamples (const double &percentage, RandomStream &stream) |
| Creates dataset with randomly excluded source samples for validation. | |
| vector< string > | AllSourceSampleNames () const |
| Retrieves names of all samples across all source groups. | |
| vector< string > | RandomlypickSamples (const double &percentage, RandomStream &stream) const |
| Randomly selects a subset of source samples. | |
| SourceSinkData | ReplaceSourceAsTarget (const string &source_sample_name) const |
| Creates a new dataset with a source sample designated as the target. | |
| CMatrix | WithinGroupCovarianceMatrix () |
| Computes pooled within-group covariance matrix. | |
| CMatrix | BetweenGroupCovarianceMatrix () |
| Computes between-group covariance matrix. | |
| CMatrix | TotalScatterMatrix () |
| Computes total scatter matrix. | |
| double | WilksLambda () |
| Computes Wilks' Lambda statistic for multivariate group separation. | |
| double | DFA_P_Value () |
| Computes p-value for discriminant function analysis. | |
| CMBVectorSet | DFA_Projected () |
| Projects all groups onto the discriminant function axis. | |
| CMBVectorSet | DFA_Projected (const string &source1, const string &source2) |
| Projects two specific groups onto the discriminant function axis. | |
| CMBVectorSet | DFA_Projected (const string &source1, SourceSinkData *original) |
| Projects samples from original dataset onto discriminant function. | |
| CMBVector | DFA_eigvector () |
| Computes the primary discriminant function eigenvector. | |
| CMBVector | DFA_weight_vector (const string &source1, const string &source2) |
| Computes discriminant weight vector for two-group comparison. | |
| CMBVector | DFATransformed (const CMBVector &eigenvector, const string &source_group) |
| Projects samples onto a discriminant function axis. | |
| Elemental_Profile_Set | TheRest (const string &excluded_source) |
| Collects all source samples except those from a specified source group. | |
| CMBVector | MeanElementalContent (const string &group_name) |
| Computes mean elemental concentrations for a specific group. | |
| CMBVector | MeanElementalContent () |
| Computes weighted mean elemental concentrations across all sources. | |
Private Attributes | |
| map< string, element_information > | element_information_ |
| map< string, ConcentrationSet > | element_distributions_ |
| int | numberofconstituents_ |
| int | numberofisotopes_ |
| int | numberofsourcesamplesets_ |
| vector< Observation > | observations_ |
| vector< Parameter > | parameters_ |
| string | outputpath_ |
| string | target_group_ |
| string | selected_target_sample_ |
| vector< string > | samplesetsorder_ |
| vector< string > | constituent_order_ |
| vector< string > | element_order_ |
| vector< string > | isotope_order_ |
| vector< string > | size_om_order_ |
| estimation_mode | parameter_estimation_mode_ |
| string | omconstituent_ |
| string | sizeconstituent_ |
| double | regression_p_value_threshold_ |
| double | distance_coeff_ |
| QString | load_error_ |
| See LoadError(). | |
| double | error_stdev_ = 0 |
| double | error_stdev_isotope_ = 0 |
| double | epsilon_ = 0 |
| ProgressReporter * | rtw_ = nullptr |
| list< string > | tools_used_ |
| QMap< QString, double > | options_ |
Definition at line 70 of file sourcesinkdata.h.
| SourceSinkData::SourceSinkData | ( | ) |
Default constructor.
Initializes an empty SourceSinkData object with default options. Sets outlier deviation threshold to 3.0 by default.
Definition at line 26 of file sourcesinkdata.cpp.
References constituent_order_, distance_coeff_, element_distributions_, element_information_, element_order_, isotope_order_, numberofconstituents_, numberofisotopes_, numberofsourcesamplesets_, observations_, omconstituent_, options_, outputpath_, parameter_estimation_mode_, parameters_, regression_p_value_threshold_, rtw_, samplesetsorder_, selected_target_sample_, size_om_order_, sizeconstituent_, target_group_, and tools_used_.
Referenced by SourceSinkData(), BootStrap(), BootStrap(), BoxCoxTransformed(), BracketTest(), BracketTest(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), CreateTracerDataset(), DFA_Projected(), DiscriminantFunctionAnalysis(), DiscriminantFunctionAnalysis(), ExtractChemicalElements(), ExtractSpecificElements(), LM_Batch(), MCMC(), operator=(), RandomlyEliminateSourceSamples(), ReplaceSourceAsTarget(), StepwiseDiscriminantFunctionAnalysis(), StepwiseDiscriminantFunctionAnalysis(), StepwiseDiscriminantFunctionAnalysis(), and VerifySource().
| SourceSinkData::SourceSinkData | ( | const SourceSinkData & | other | ) |
Copy constructor.
Creates a deep copy of another SourceSinkData object, including all elemental profile sets, element information, distributions, parameters, observations, and analysis settings.
| other | The SourceSinkData object to copy from |
Definition at line 55 of file sourcesinkdata.cpp.
References SourceSinkData(), constituent_order_, distance_coeff_, element_distributions_, element_information_, element_order_, isotope_order_, numberofconstituents_, numberofisotopes_, numberofsourcesamplesets_, observations_, omconstituent_, options_, outputpath_, parameter_estimation_mode_, parameters_, regression_p_value_threshold_, rtw_, samplesetsorder_, selected_target_sample_, size_om_order_, sizeconstituent_, target_group_, and tools_used_.
| void SourceSinkData::AddtoToolsUsed | ( | const string & | tool | ) |
Adds a tool name to the list of tools used in analysis.
Records that a particular analysis tool was applied to this dataset. Prevents duplicate entries.
| tool | Name of the tool used (e.g., "MCMC", "Bootstrap") |
Definition at line 2764 of file sourcesinkdata.cpp.
References tools_used_, and ToolsUsed().
Referenced by Conductor::Execute(), and ReadToolsUsedFromJsonObject().
Retrieves names of all samples across all source groups.
Collects sample names from all source groups (excluding target) into a single flat list.
Definition at line 4258 of file sourcesinkdata.cpp.
References target_group_.
Referenced by RandomlypickSamples().
| CMBVector SourceSinkData::ANOVA | ( | bool | use_log | ) |
Performs one-way ANOVA for all elements across source groups.
Conducts analysis of variance to test whether mean concentrations differ significantly among source groups for each element.
Null hypothesis: μ₁ = μ₂ = ... = μₖ (all source means equal)
| use_log | If true, perform ANOVA on log-transformed concentrations; if false, use linear-space concentrations |
Definition at line 3715 of file sourcesinkdata.cpp.
References ANOVA(), GetElementNames(), ANOVA_info::p_value, and CMBVector::SetLabels().
Referenced by ANOVA(), and Conductor::ExecuteANOVA().
| ANOVA_info SourceSinkData::ANOVA | ( | const string & | element, |
| bool | use_log ) |
Performs one-way ANOVA for a single element across source groups.
Conducts detailed analysis of variance decomposing total variance into between-group and within-group components.
ANOVA decomposition:
| element | Name of the element to analyze |
| use_log | If true, perform ANOVA on log-transformed concentrations |
Definition at line 3731 of file sourcesinkdata.cpp.
References ConcentrationSet::CalculateMean(), ConcentrationSet::CalculateMeanLog(), ConcentrationSet::CalculateSSE(), ConcentrationSet::CalculateSSELog(), ConcentrationSet::CalculateStdDevLog(), ANOVA_info::F, Elemental_Profile_Set::GetElementDistribution(), LumpAllProfileSets(), ANOVA_info::MSB, ANOVA_info::MSW, ANOVA_info::p_value, ANOVA_info::SSB, ANOVA_info::SST, ANOVA_info::SSW, and target_group_.
| Elemental_Profile_Set * SourceSinkData::AppendSampleSet | ( | const string & | name, |
| const Elemental_Profile_Set & | elemental_profile_set = Elemental_Profile_Set() ) |
Add a new sample set (source or target group) to the dataset.
Adds a collection of elemental profiles under a group name. Typical group names are source identifiers (e.g., "Agricultural soil", "Road dust") or the target group name (e.g., "Stream sediment").
| name | Group name for this sample set |
| elemental_profile_set | Collection of elemental profiles for this group (default: empty) |
Definition at line 413 of file sourcesinkdata.cpp.
References elemental_profile_set, and name.
Referenced by DiscriminantFunctionAnalysis(), and DiscriminantFunctionAnalysis().
| void SourceSinkData::AssignAllDistributions | ( | ) |
Assign distributions to all elements at both dataset and group levels.
For each element:
Special handling for isotopes: Always uses normal distribution regardless of best-fit results.
Definition at line 602 of file sourcesinkdata.cpp.
References Distribution::distribution, element_distributions_, element_information_, ConcentrationSet::EstimateDistributionParameters(), GetElementNames(), ConcentrationSet::GetFittedDistribution(), element_information::isotope, normal, Distribution::parameters, and Role().
Referenced by BoxCoxTransformed(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), ExtractChemicalElements(), ExtractSpecificElements(), RandomlyEliminateSourceSamples(), and ReplaceSourceAsTarget().
|
private |
Computes between-group covariance matrix.
Calculates covariance matrix based on deviations of group means from the overall mean. Represents the "signal" or between-group scatter.
Formula: S_B = Σ[n_i × (μ_i - μ_overall)(μ_i - μ_overall)ᵀ] / N
Definition at line 4959 of file sourcesinkdata.cpp.
References GetElementNames(), MeanElementalContent(), CMBVector::size(), and target_group_.
Referenced by DFA_eigvector(), and WilksLambda().
| CMBTimeSeriesSet SourceSinkData::BootStrap | ( | const double & | percentage, |
| unsigned int | num_iterations, | ||
| const string & | target_sample, | ||
| bool | use_softmax, | ||
| std::uint64_t | seed = DefaultRandomSeed ) |
Performs bootstrap uncertainty analysis on source contributions.
Conducts bootstrap resampling to estimate uncertainty in source contribution estimates. Each bootstrap iteration randomly excludes a percentage of source samples, re-solves the CMB model, and records the resulting contributions.
| percentage | Percentage of source samples to exclude per iteration (0-100) |
| num_iterations | Number of bootstrap iterations |
| target_sample | Name of target sample to apportion |
| use_softmax | If true, use softmax transformation for contributions |
Definition at line 3928 of file sourcesinkdata.cpp.
References SourceSinkData(), GetContributionVector(), InitializeParametersAndObservations(), linear, numberofsourcesamplesets_, RandomlyEliminateSourceSamples(), rtw_, samplesetsorder_, softmax, and SolveLevenberg_Marquardt().
Referenced by Conductor::ExecuteErrorAnalysis().
| bool SourceSinkData::BootStrap | ( | Results * | results, |
| const double & | percentage, | ||
| unsigned int | num_iterations, | ||
| const string & | target_sample, | ||
| bool | use_softmax, | ||
| std::uint64_t | seed = DefaultRandomSeed ) |
Performs bootstrap analysis and generates comprehensive uncertainty results.
Conducts bootstrap resampling with full statistical analysis including:
| results | Pointer to Results object to populate with analysis outputs |
| percentage | Percentage of source samples to exclude per iteration (0-100) |
| num_iterations | Number of bootstrap iterations |
| target_sample | Name of target sample to apportion |
| use_softmax | If true, use softmax transformation |
| seed | Seed of the random elimination; the same seed repeats the analysis |
Definition at line 3979 of file sourcesinkdata.cpp.
References SourceSinkData(), Results::Append(), counter, distribution, GetContributionVector(), GetSourceOrder(), high, InitializeParametersAndObservations(), linear, low, normal, numberofsourcesamplesets_, RandomlyEliminateSourceSamples(), rangeset, rtw_, samplesetsorder_, Range::Set(), Range::SetMean(), Range::SetMedian(), ResultItem::SetName(), Results::SetName(), ResultItem::SetResult(), ResultItem::SetShowAsString(), ResultItem::SetShowGraph(), ResultItem::SetShowTable(), ResultItem::SetType(), ResultItem::SetXAxisMode(), ResultItem::setXAxisTitle(), ResultItem::SetYAxisMode(), ResultItem::setYAxisTitle(), ResultItem::SetYLimit(), softmax, SolveLevenberg_Marquardt(), and stacked_bar_chart.
| SourceSinkData SourceSinkData::BoxCoxTransformed | ( | bool | calculate_optimal_lambda = false | ) |
Applies Box-Cox transformation to all source groups for normalization.
Transforms elemental concentrations using the Box-Cox power transformation to improve normality of distributions. This is useful for statistical analyses that assume normally distributed data (e.g., t-tests, ANOVA, discriminant analysis).
Box-Cox transformation: y = (x^λ - 1) / λ (or ln(x) if λ = 0)
The optimal λ parameter for each element is determined by maximum likelihood estimation to best achieve normality.
| calculate_optimal_lambda | If true, compute optimal λ for each element; if false, use default transformation |
Definition at line 3306 of file sourcesinkdata.cpp.
References SourceSinkData(), AssignAllDistributions(), OptimalBoxCoxParameters(), PopulateElementDistributions(), and target_group_.
Referenced by Conductor::BoxCoxTransformedWithReport().
| CMBMatrix SourceSinkData::BracketTest | ( | bool | correct_based_on_om_n_size, |
| bool | exclude_elements, | ||
| bool | exclude_samples, | ||
| double | tolerance = 0 ) |
Performs bracket test on all target samples.
Applies the bracket test to every sample in the target group, producing a matrix showing which elements in which samples fall outside source concentration ranges.
Matrix structure:
| correct_based_on_om_n_size | If true, apply OM/size corrections before testing |
| exclude_elements | If true, filter out elements marked for exclusion |
| exclude_samples | If true, filter out samples marked for exclusion |
| tolerance | Fraction of the source range added at each end (0 = none) |
Definition at line 3255 of file sourcesinkdata.cpp.
References SourceSinkData(), BracketTest(), CountElements(), CreateTracerDataset(), GetElementNames(), CMBMatrix::SetColumnLabel(), CMBMatrix::SetRowLabel(), CMBVector::size(), target_group_, and CMBVector::valueAt().
| CMBVector SourceSinkData::BracketTest | ( | const string & | target_sample, |
| bool | correct_based_on_om_n_size, | ||
| double | tolerance = 0 ) |
Performs bracket test to check if target concentrations fall within source ranges.
Tests whether each element's concentration in the target sample falls within the range (min to max) observed across all source samples. Elements outside source ranges indicate potential issues: missing sources, measurement errors, or non-conservative behavior.
Test criteria for each element:
With a tolerance t, both ends of the range of all source samples move out by t times that range: [min - t(max-min), max + t(max-min)].
| target_sample | Name of the target sample to test |
| correct_based_on_om_n_size | If true, apply OM/size corrections before testing |
| tolerance | Fraction of the source range added at each end (0 = none) |
Definition at line 3200 of file sourcesinkdata.cpp.
References SourceSinkData(), CreateCorrectedAndFilteredDataset(), GetElementNames(), CMBVector::SetLabel(), and target_group_.
Referenced by BracketTest(), Conductor::ExecuteBracketingAnalysis(), and MainWindow::onIncludeExcludeSample().
|
private |
Builds the source mean concentration matrix for chemical elements.
Constructs a matrix where each entry [i,j] represents the mean concentration of element i in source j. Used in the mixing model equation: C_target = S × f
| param_mode | Controls whether to use parametric or empirical means |
Definition at line 1613 of file sourcesinkdata.cpp.
References based_on_fitted_distribution, Distribution::DataMean(), element_order_, Elemental_Profile_Set::GetEstimatedDistribution(), GetSampleSet(), Distribution::Mean(), numberofsourcesamplesets_, and samplesetsorder_.
Referenced by PredictTarget().
|
private |
Builds the source mean concentration matrix for isotopes.
Constructs a matrix where each entry [i,j] represents the mean absolute concentration of isotope i in source j. Converts from delta notation to absolute concentrations.
Conversion formula: [isotope] = (δ/1000 + 1) × R_standard × [base_element]
| param_mode | Controls whether to use parametric or empirical means |
Definition at line 1665 of file sourcesinkdata.cpp.
References element_information::base_element, based_on_fitted_distribution, Distribution::DataMean(), element_information_, Elemental_Profile_Set::GetEstimatedDistribution(), GetSampleSet(), isotope_order_, IsotopeBaseMean(), Distribution::Mean(), numberofsourcesamplesets_, samplesetsorder_, and element_information::standard_ratio.
Referenced by PredictTarget_Isotope(), and PredictTarget_Isotope_delta().
| void SourceSinkData::Clear | ( | ) |
Clear all data from the object.
Resets the SourceSinkData object to its initial empty state by:
Definition at line 377 of file sourcesinkdata.cpp.
References constituent_order_, element_distributions_, element_information_, element_order_, isotope_order_, numberofconstituents_, numberofisotopes_, numberofsourcesamplesets_, observations_, outputpath_, parameters_, samplesetsorder_, selected_target_sample_, size_om_order_, target_group_, and tools_used_.
Referenced by ReadFromFile().
Retrieves the ordering of all constituents.
Definition at line 5575 of file sourcesinkdata.cpp.
References constituent_order_.
| int SourceSinkData::CountElements | ( | bool | exclude_elements | ) | const |
Count the number of elements in the dataset.
Counts elements based on their inclusion status and role. Can count either:
| exclude_elements | If true, only count elements marked for analysis with valid roles |
Definition at line 236 of file sourcesinkdata.cpp.
References element_information::do_not_include, element_information_, element_information::organic_carbon, and element_information::particle_size.
Referenced by BracketTest().
| SourceSinkData SourceSinkData::CreateCorrectedAndFilteredDataset | ( | bool | exclude_samples, |
| bool | exclude_elements, | ||
| bool | omnsizecorrect, | ||
| const string & | target = "" ) const |
Create a corrected and filtered copy of the dataset.
Creates a new SourceSinkData object with optional filtering and corrections:
This is the main method for preparing data before analysis, allowing fine control over which samples/elements to include and whether to apply normalizations.
| exclude_samples | If true, exclude samples not marked for analysis |
| exclude_elements | If true, exclude elements not marked for analysis |
| omnsizecorrect | If true, apply OM and particle size corrections to sources |
| target | Target sample name (empty to use current selected_target_sample_) |
Definition at line 258 of file sourcesinkdata.cpp.
References SourceSinkData(), AssignAllDistributions(), element_information_, omconstituent_, options_, PopulateElementDistributions(), PopulateElementInformation(), regression_p_value_threshold_, selected_target_sample_, sizeconstituent_, and target_group_.
Referenced by BracketTest(), CreateTracerDataset(), Conductor::ExecuteCorrelationMatrix(), Conductor::ExecuteDistributionFitting(), Conductor::ExecuteMLR(), Conductor::ExecuteOMSizeCorrect(), and Conductor::ExecuteOutlierAnalysis().
| SourceSinkData SourceSinkData::CreateCorrectedDataset | ( | const string & | target, |
| bool | omnsizecorrect, | ||
| map< string, element_information > * | elementinfo ) |
Create a corrected copy of the dataset for a specific target sample.
Creates a new SourceSinkData object with:
This method is typically used to prepare data for source apportionment of a specific target sample.
| target | Name of the target sample to analyze |
| omnsizecorrect | If true, apply OM and size corrections to source profiles |
| elementinfo | Element metadata for filtering (nullptr to use internal metadata) |
Definition at line 120 of file sourcesinkdata.cpp.
References SourceSinkData(), Elemental_Profile_Set::AppendProfile(), AssignAllDistributions(), constituent_order_, element_information::do_not_include, element_distributions_, element_information_, element_order_, element_information::isotope, isotope_order_, numberofconstituents_, numberofisotopes_, numberofsourcesamplesets_, observations_, omconstituent_, options_, element_information::organic_carbon, outputpath_, parameter_estimation_mode_, element_information::particle_size, PopulateElementDistributions(), regression_p_value_threshold_, samplesetsorder_, selected_target_sample_, Elemental_Profile_Set::SetRegressionModels(), size_om_order_, sizeconstituent_, and target_group_.
Referenced by Conductor::ExecuteANOVA(), Conductor::ExecuteAutoSelect(), Conductor::ExecuteCorrelationMatrix(), Conductor::ExecuteDFA(), Conductor::ExecuteDFAM(), Conductor::ExecuteDFAOnevsRest(), Conductor::ExecuteDistributionFitting(), Conductor::ExecuteEDP(), Conductor::ExecuteEDPM(), Conductor::ExecuteErrorAnalysis(), Conductor::ExecuteLevenbergMarquardt(), Conductor::ExecuteSDFA(), Conductor::ExecuteSDFAM(), Conductor::ExecuteSDFAOnevsRest(), LM_Batch(), MCMC(), and VerifySource().
| SourceSinkData SourceSinkData::CreateTracerDataset | ( | bool | exclude_samples, |
| bool | exclude_elements, | ||
| bool | omnsizecorrect, | ||
| const string & | target = "" ) const |
As CreateCorrectedAndFilteredDataset, keeping only the tracers.
Elements and isotopes only: particle size, organic matter and excluded constituents are dropped whatever exclude_elements says. Used by the tools that test or select tracers (ANOVA, DFA, discriminant power, auto-select, bracketing), where D50 or TOC must not be tested, selected or removed as if they were tracers.
Definition at line 220 of file sourcesinkdata.cpp.
References SourceSinkData(), CreateCorrectedAndFilteredDataset(), element_information::element, element_information_, element_information::isotope, and name.
Referenced by BracketTest(), Conductor::ExecuteANOVA(), Conductor::ExecuteAutoSelect(), Conductor::ExecuteBracketingAnalysis(), Conductor::ExecuteDFA(), Conductor::ExecuteDFAM(), Conductor::ExecuteDFAOnevsRest(), Conductor::ExecuteEDP(), Conductor::ExecuteEDPM(), Conductor::ExecuteSDFA(), Conductor::ExecuteSDFAM(), and Conductor::ExecuteSDFAOnevsRest().
|
private |
Computes the primary discriminant function eigenvector.
Calculates the eigenvector corresponding to the largest eigenvalue of S_W⁻¹ × S_B, which defines the discriminant function axis.
Definition at line 5149 of file sourcesinkdata.cpp.
References BetweenGroupCovarianceMatrix(), GetElementNames(), CMBVector::SetLabels(), and WithinGroupCovarianceMatrix().
Referenced by DFA_Projected(), DFA_Projected(), DFA_Projected(), DiscriminantFunctionAnalysis(), and DiscriminantFunctionAnalysis().
|
private |
Computes p-value for discriminant function analysis.
Tests the null hypothesis that all source groups have the same mean elemental composition using Wilks' Lambda transformed to chi-squared.
Chi-squared transformation: χ² = -[N - 1 - (p + k)/2] × ln(Λ)
Definition at line 5053 of file sourcesinkdata.cpp.
References GetElementNames(), log, numberofsourcesamplesets_, target_group_, TotalNumberofSourceSamples(), and WilksLambda().
Referenced by DiscriminantFunctionAnalysis(), DiscriminantFunctionAnalysis(), and StepwiseDiscriminantFunctionAnalysis().
|
private |
Projects all groups onto the discriminant function axis.
Computes discriminant scores for all samples in all groups by projecting elemental profiles onto the primary discriminant eigenvector.
Definition at line 5084 of file sourcesinkdata.cpp.
References CMBVectorSet::Append(), and DFA_eigvector().
Referenced by DiscriminantFunctionAnalysis(), DiscriminantFunctionAnalysis(), and StepwiseDiscriminantFunctionAnalysis().
|
private |
Projects two specific groups onto the discriminant function axis.
| source1 | Name of first source group |
| source2 | Name of second source group |
Definition at line 5104 of file sourcesinkdata.cpp.
References CMBVectorSet::Append(), and DFA_eigvector().
|
private |
Projects samples from original dataset onto discriminant function.
Uses discriminant function computed from current dataset to project samples from the original dataset. Useful for validating on held-out data.
| source1 | Name of source used in discriminant function |
| original | Pointer to original dataset |
Definition at line 5125 of file sourcesinkdata.cpp.
References SourceSinkData(), CMBVectorSet::Append(), DFA_eigvector(), and target_group_.
|
private |
Computes discriminant weight vector for two-group comparison.
Calculates the linear discriminant weights for separating two specific source groups using Fisher's linear discriminant analysis.
Formula: w = (μ₂ - μ₁) / (Σ₁ + Σ₂)
| source1 | Name of first source group |
| source2 | Name of second source group |
Definition at line 5187 of file sourcesinkdata.cpp.
References GetElementNames(), and CMBVector::SetLabels().
| CMBMatrix SourceSinkData::DFAConfusionMatrix | ( | ) |
Leave-one-out confusion matrix of the source samples.
Linear discriminant classification with equal priors: each source sample, left out in turn, is assigned to the group whose mean (computed without it) is nearest in Mahalanobis distance with the pooled within-group covariance. Rows are the true groups, columns the groups assigned, and the last column the percentage classified correctly.
Definition at line 4837 of file sourcesinkdata.cpp.
References GetElementNames(), CMBMatrix::SetColumnLabel(), CMBMatrix::SetRowLabel(), target_group_, and x.
Referenced by Conductor::ExecuteSDFAM().
|
private |
Projects samples onto a discriminant function axis.
Transforms elemental profiles from a source group by computing their projections (dot products) with a discriminant eigenvector.
Projection formula: score_i = Σ(x_ij × w_j)
| eigenvector | Discriminant function coefficients |
| source_group | Name of the source group to project |
Definition at line 3153 of file sourcesinkdata.cpp.
References CMBVector::SetLabel().
| Elemental_Profile_Set SourceSinkData::DifferentiationPower | ( | bool | use_log, |
| bool | include_target ) |
Computes differentiation power for all source pairs.
Performs pairwise differentiation power analysis for all combinations of source groups, generating a comprehensive matrix of source separability.
Formula: D = 2 × |μ₁ - μ₂| / (σ₁ + σ₂)
Interpretation:
| use_log | If true, compute using log-space statistics; if false, use linear-space statistics |
| include_target | If true, include target group in comparisons |
Definition at line 3493 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::AppendProfile(), DifferentiationPower(), and target_group_.
Referenced by DifferentiationPower(), Conductor::ExecuteEDP(), and Conductor::ExecuteEDPM().
| Elemental_Profile SourceSinkData::DifferentiationPower | ( | const string & | source1, |
| const string & | source2, | ||
| bool | use_log ) |
Computes differentiation power metric between two sources.
Calculates a standardized measure of how well each element differentiates between two sources. The metric quantifies separation in units of pooled standard deviations.
Formula: D = 2 × |μ₁ - μ₂| / (σ₁ + σ₂)
Interpretation:
| source1 | Name of first source group |
| source2 | Name of second source group |
| use_log | If true, compute using log-space statistics; if false, use linear-space statistics |
Definition at line 3453 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), ConcentrationSet::CalculateMean(), ConcentrationSet::CalculateMeanLog(), ConcentrationSet::CalculateStdDev(), ConcentrationSet::CalculateStdDevLog(), and GetElementNames().
| Elemental_Profile_Set SourceSinkData::DifferentiationPower_P_value | ( | bool | include_target | ) |
Computes t-test p-values for all source pairs.
Performs pairwise t-test analysis for all combinations of source groups, generating a comprehensive matrix of statistical significance values.
| include_target | If true, include target group in comparisons |
Definition at line 3576 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::AppendProfile(), t_TestPValue(), and target_group_.
Referenced by Conductor::ExecuteAutoSelect(), and Conductor::ExecuteEDPM().
| Elemental_Profile_Set SourceSinkData::DifferentiationPower_Percentage | ( | bool | include_target | ) |
Computes rank-based differentiation percentage for all source pairs.
Performs pairwise rank-based differentiation analysis for all combinations of source groups. Provides a non-parametric measure of source separability.
| include_target | If true, include target group in comparisons |
Definition at line 3553 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::AppendProfile(), DifferentiationPower_Percentage(), and target_group_.
Referenced by DifferentiationPower_Percentage(), Conductor::ExecuteEDP(), and Conductor::ExecuteEDPM().
| Elemental_Profile SourceSinkData::DifferentiationPower_Percentage | ( | const string & | source1, |
| const string & | source2 ) |
Computes rank-based differentiation percentage between two sources.
Calculates the percentage of samples that can be correctly classified based on element concentrations using a rank-based approach. Provides a distribution-free measure of source separability.
Method:
| source1 | Name of first source group |
| source2 | Name of second source group |
Definition at line 3516 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), ConcentrationSet::AppendSet(), ConcentrationSet::CalculateRanks(), and GetElementNames().
| DFA_result SourceSinkData::DiscriminantFunctionAnalysis | ( | ) |
Performs discriminant function analysis for all source groups.
Conducts pairwise discriminant function analysis (DFA) comparing each source group against all others combined. DFA identifies the linear combination of elemental concentrations that best separates each source from the rest, which helps assess source uniqueness and potential confounding.
For each source, computes:
Definition at line 3020 of file sourcesinkdata.cpp.
References CMBVectorSet::Append(), CMBVectorSetSet::Append(), counter, DiscriminantFunctionAnalysis(), DFA_result::eigen_vectors, DFA_result::F_test_P_value, DFA_result::multi_projected, DFA_result::p_values, DFA_result::projected, CMBVector::SetLabel(), target_group_, and DFA_result::wilkslambda.
Referenced by DiscriminantFunctionAnalysis(), Conductor::ExecuteDFA(), Conductor::ExecuteDFAM(), Conductor::ExecuteDFAOnevsRest(), Conductor::ExecuteSDFAM(), StepwiseDiscriminantFunctionAnalysis(), and StepwiseDiscriminantFunctionAnalysis().
| DFA_result SourceSinkData::DiscriminantFunctionAnalysis | ( | const string & | source1 | ) |
Performs discriminant function analysis for one source vs all others.
Conducts DFA comparing a single source group against all other sources combined ("one vs rest" comparison).
| source1 | Name of source group to test |
Definition at line 3100 of file sourcesinkdata.cpp.
References SourceSinkData(), CMBVectorSet::Append(), AppendSampleSet(), DFA_eigvector(), DFA_P_Value(), DFA_Projected(), DFA_result::eigen_vectors, element_information_, DFA_result::F_test_P_value, CMBVectorSet::FTest_p_value(), DFA_result::p_values, PopulateElementInformation(), DFA_result::projected, TheRest(), WilksLambda(), and DFA_result::wilkslambda.
| DFA_result SourceSinkData::DiscriminantFunctionAnalysis | ( | const string & | source1, |
| const string & | source2 ) |
Performs discriminant function analysis between two specific sources.
Conducts pairwise DFA to assess how well two source groups can be distinguished based on their elemental compositions.
| source1 | Name of first source group |
| source2 | Name of second source group |
Definition at line 3060 of file sourcesinkdata.cpp.
References SourceSinkData(), CMBVectorSet::Append(), AppendSampleSet(), DFA_eigvector(), DFA_P_Value(), DFA_Projected(), DFA_result::eigen_vectors, element_information_, DFA_result::F_test_P_value, CMBVectorSet::FTest_p_value(), DFA_result::p_values, PopulateElementInformation(), DFA_result::projected, CMBVector::size(), WilksLambda(), and DFA_result::wilkslambda.
| QJsonObject SourceSinkData::ElementDataToJsonObject | ( | ) | const |
Exports all elemental profile data to a JSON object.
Serializes all sample groups and their elemental profiles to JSON format.
Definition at line 2843 of file sourcesinkdata.cpp.
Referenced by MainWindow::buildProjectJson().
| QJsonObject SourceSinkData::ElementInformationToJsonObject | ( | ) | const |
Exports element information metadata to a JSON object.
Serializes all element metadata (role, standard ratio, base element, inclusion flag) to a JSON object for saving or transmission.
Definition at line 2911 of file sourcesinkdata.cpp.
References element_information_, and Role().
Referenced by MainWindow::buildProjectJson().
Retrieves the ordering of chemical elements.
Definition at line 5580 of file sourcesinkdata.cpp.
References element_order_.
Referenced by GetObservedElementalProfile(), GetPredictedElementalProfile(), and MCMC().
Identifies chemical elements to be used in CMB analysis.
Scans the element information map and collects all elements marked with the 'element' role. Updates constituent count and ordering vectors.
Definition at line 2202 of file sourcesinkdata.cpp.
References constituent_order_, element_information::element, element_information_, and numberofconstituents_.
| SourceSinkData SourceSinkData::ExtractChemicalElements | ( | bool | isotopes | ) | const |
Extract only chemical elements (and optionally isotopes).
Creates a new SourceSinkData containing only elements with role 'element' (and optionally 'isotope'), excluding particle size, organic matter, and other non-element constituents.
| isotopes | If true, also include isotope ratios |
Definition at line 332 of file sourcesinkdata.cpp.
References SourceSinkData(), AssignAllDistributions(), element_information_, ExtractChemicalElements(), omconstituent_, PopulateElementDistributions(), PopulateElementInformation(), regression_p_value_threshold_, sizeconstituent_, and target_group_.
Referenced by Conductor::ExecuteAutoSelect(), and ExtractChemicalElements().
| profiles_data SourceSinkData::ExtractConcentrationData | ( | const vector< vector< string > > & | indicators | ) | const |
Extract concentration data for specified samples.
Extracts elemental concentration data for a list of samples identified by [group_name, sample_name] pairs. Returns data in a structured format suitable for analysis.
| indicators | Vector of [group_name, sample_name] pairs identifying samples |
Definition at line 490 of file sourcesinkdata.cpp.
References profiles_data::element_names, Elemental_Profile_Set::GetConcentrationsForSample(), GetElementNames(), profiles_data::sample_names, and profiles_data::values.
| map< string, ConcentrationSet > SourceSinkData::ExtractConcentrationSet | ( | ) |
Extracts concentration distributions for all elements across sources.
Collects all concentration values for each element across all source samples (excluding target) into ConcentrationSet objects. This aggregates data for statistical analysis of elemental distributions across the entire source dataset.
Definition at line 3340 of file sourcesinkdata.cpp.
References ConcentrationSet::AppendValue(), GetElementNames(), and target_group_.
Referenced by OptimalBoxCoxParameters().
| element_data SourceSinkData::ExtractElementConcentrations | ( | const string & | element, |
| const string & | group ) const |
Extract concentration data for a specific element from a group.
Retrieves all concentration values for a single element across all samples within a specified group. Useful for univariate analysis of a single element's distribution within a source or target group.
| element | Element name to extract |
| group | Group name to extract from |
Definition at line 540 of file sourcesinkdata.cpp.
References element_data::group_name, element_data::sample_names, and element_data::values.
Referenced by ExtractElementDataByGroup().
| map< string, vector< double > > SourceSinkData::ExtractElementDataByGroup | ( | const string & | element | ) | const |
Extract concentration data for a specific element from all groups.
Retrieves all concentration values for a single element organized by group. Returns a map where keys are group names and values are vectors of concentrations for that element within each group.
| element | Element name to extract |
Definition at line 587 of file sourcesinkdata.cpp.
References ExtractElementConcentrations(), GetGroupNames(), and element_data::values.
| Elemental_Profile_Set SourceSinkData::ExtractSamplesAsProfileSet | ( | const vector< vector< string > > & | indicators | ) | const |
Extract samples as an Elemental_Profile_Set.
Extracts specified samples and combines them into a single profile set. Sample names are prefixed with their group name (e.g., "Agricultural-Sample1") to ensure uniqueness when combining samples from different groups.
| indicators | Vector of [group_name, sample_name] pairs identifying samples |
Definition at line 517 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::AppendProfile().
| SourceSinkData SourceSinkData::ExtractSpecificElements | ( | const vector< string > & | element_list | ) | const |
Extract specific elements from source groups.
Creates a new SourceSinkData containing only the specified elements from source groups. Target group is excluded. Useful for subset analysis or element selection optimization.
| element_list | List of element names to extract |
Definition at line 356 of file sourcesinkdata.cpp.
References SourceSinkData(), AssignAllDistributions(), element_information_, PopulateElementDistributions(), PopulateElementInformation(), and target_group_.
Referenced by StepwiseDiscriminantFunctionAnalysis(), StepwiseDiscriminantFunctionAnalysis(), and StepwiseDiscriminantFunctionAnalysis().
| string SourceSinkData::FirstOMConstituent | ( | ) |
Retrieves the name of the first organic matter constituent.
Searches element information for the first element designated as organic carbon/matter.
Definition at line 4803 of file sourcesinkdata.cpp.
References element_information_, and element_information::organic_carbon.
| string SourceSinkData::FirstSizeConstituent | ( | ) |
Retrieves the name of the first particle size constituent.
Searches element information for the first element designated as particle size.
Definition at line 4820 of file sourcesinkdata.cpp.
References element_information_, and element_information::particle_size.
| ResultItem SourceSinkData::GetCalculatedElementMeans | ( | ) |
Computes estimated mean concentrations for all source elements.
Calculates the mean elemental concentrations for each source group using the current estimated distributions.
Definition at line 2554 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), Elemental_Profile_Set::AppendProfile(), element_order_, elemental_profile_set, ResultItem::SetName(), ResultItem::SetResult(), ResultItem::SetType(), and target_group_.
| ResultItem SourceSinkData::GetCalculatedElementMu | ( | ) |
Computes μ parameters from fitted log-normal distributions for source elements.
Calculates the μ (log-space mean) parameter for each element in each source group based on the fitted log-normal distributions from source sample data.
Definition at line 2637 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), Elemental_Profile_Set::AppendProfile(), element_order_, elemental_profile_set, ResultItem::SetName(), ResultItem::SetResult(), ResultItem::SetType(), and target_group_.
| ResultItem SourceSinkData::GetCalculatedElementSigma | ( | ) |
Computes estimated standard deviations for all source elements.
Calculates the standard deviations of elemental concentrations for each source group using the current estimated distributions.
Definition at line 2578 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), Elemental_Profile_Set::AppendProfile(), element_order_, elemental_profile_set, lognormal, normal, ResultItem::SetName(), ResultItem::SetResult(), ResultItem::SetType(), and target_group_.
| ResultItem SourceSinkData::GetContribution | ( | ) |
Packages source contributions into a ResultItem for output.
Creates a ResultItem containing the current source contribution estimates, formatted for export or display.
Definition at line 2356 of file sourcesinkdata.cpp.
References contribution, GetContributionVector(), GetSourceOrder(), ResultItem::SetName(), ResultItem::SetResult(), and ResultItem::SetType().
Referenced by Conductor::ExecuteLevenbergMarquardt().
|
private |
Retrieves the current source contribution fractions.
Returns a vector of contribution fractions from each source. Contributions represent the fraction of the target sample originating from each source, subject to the constraint: Σ f_i = 1.
| include_all | If true, returns all n contributions including the constrained one. If false, returns only the n-1 independent contributions used in optimization. |
Definition at line 1715 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::GetContribution(), GetSampleSet(), numberofsourcesamplesets_, and samplesetsorder_.
Referenced by BootStrap(), BootStrap(), GetContribution(), InitializeContributionsRandomly(), LM_Batch(), NegativeContributionCheck(), PredictTarget(), PredictTarget_Isotope(), PredictTarget_Isotope_delta(), ResidualJacobian(), ResidualJacobian_arma(), SetContribution(), SetContributionSoftmax(), SetParameterValue(), SolveLevenberg_Marquardt(), and VerifySource().
|
private |
Retrieves the softmax parameters for source contributions.
Returns the unconstrained softmax parameters x_i that are transformed to contribution fractions via: f_i = exp(x_i) / Σ exp(x_j)
Definition at line 1735 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::GetContributionSoftmax(), GetSampleSet(), numberofsourcesamplesets_, and samplesetsorder_.
Referenced by ResidualJacobian_softmax(), and SolveLevenberg_Marquardt().
|
private |
Finds and retrieves an elemental profile by sample name.
Searches all groups (sources and target) for a sample with the given name and returns a pointer to its elemental profile. Useful when the group containing the sample is unknown.
| sample_name | Name of the sample to find |
Definition at line 2336 of file sourcesinkdata.cpp.
Referenced by InitializeParametersAndObservations().
| ConcentrationSet * SourceSinkData::GetElementDistribution | ( | const string & | element_name | ) |
Retrieves pointer to element distribution at dataset level.
| element_name | Name of the element |
Definition at line 5540 of file sourcesinkdata.cpp.
References element_distributions_.
Referenced by Conductor::ExecuteDistributionFitting(), Conductor::ExecuteKolmogorovSmirnovIndividual(), GetElementDistribution(), and SetParameterValue().
| ConcentrationSet * SourceSinkData::GetElementDistribution | ( | const string & | element_name, |
| const string & | sample_group ) |
Retrieves pointer to element distribution for a specific group.
| element_name | Name of the element |
| sample_group | Name of the source or target group |
Definition at line 5548 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::GetElementDistribution(), GetElementDistribution(), and GetSampleSet().
|
private |
Retrieves pointer to the μ (mean) parameter for an element distribution.
Accesses the parameter object representing the mean (μ) of the log-normal distribution for a specific element in a specific source.
| element_index | Index of the element in element_order_ (0-based) |
| source_index | Index of the source in samplesetsorder_ (0-based) |
Definition at line 1822 of file sourcesinkdata.cpp.
References numberofsourcesamplesets_, and parameters_.
Referenced by GetElementDistributionMuValue().
|
private |
Retrieves the current value of the μ parameter for an element distribution.
| element_index | Index of the element in element_order_ (0-based) |
| source_index | Index of the source in samplesetsorder_ (0-based) |
Definition at line 1875 of file sourcesinkdata.cpp.
References GetElementDistributionMuParameter(), and Parameter::Value().
|
private |
Retrieves pointer to the σ (std dev) parameter for an element distribution.
Accesses the parameter object representing the standard deviation (σ) of the log-normal distribution for a specific element in a specific source.
| element_index | Index of the element in element_order_ (0-based) |
| source_index | Index of the source in samplesetsorder_ (0-based) |
Definition at line 1848 of file sourcesinkdata.cpp.
References numberofconstituents_, numberofsourcesamplesets_, and parameters_.
Referenced by GetElementDistributionSigmaValue().
|
private |
Retrieves the current value of the σ parameter for an element distribution.
| element_index | Index of the element in element_order_ (0-based) |
| source_index | Index of the source in samplesetsorder_ (0-based) |
Definition at line 1890 of file sourcesinkdata.cpp.
References GetElementDistributionSigmaParameter(), and Parameter::Value().
| map< string, element_information > * SourceSinkData::GetElementInformation | ( | ) |
Retrieves pointer to the element information map.
Provides access to element metadata including roles, standard ratios, base elements, and inclusion flags for all elements in the dataset.
Definition at line 5527 of file sourcesinkdata.cpp.
References element_information_.
Referenced by LM_Batch(), MCMC(), FormElementInformation::SyncIncludeAllCheckBox(), and VerifySource().
| element_information * SourceSinkData::GetElementInformation | ( | const string & | element_name | ) |
Retrieves pointer to element information metadata by name.
| element_name | Name of the element |
Definition at line 5532 of file sourcesinkdata.cpp.
References element_information_.
Get all element names in the dataset.
Returns element names by examining the first sample of the first group. Assumes all samples have the same elements (which should be true after proper data loading).
Definition at line 465 of file sourcesinkdata.cpp.
Referenced by GenericForm::GenericForm(), ANOVA(), AssignAllDistributions(), BetweenGroupCovarianceMatrix(), BracketTest(), BracketTest(), DFA_eigvector(), DFA_P_Value(), DFA_weight_vector(), DFAConfusionMatrix(), DifferentiationPower(), DifferentiationPower_Percentage(), ExtractConcentrationData(), ExtractConcentrationSet(), MeanElementalContent(), MeanElementalContent(), OptimalBoxCoxParameters(), PopulateElementDistributions(), PopulateElementInformation(), StepwiseDiscriminantFunctionAnalysis(), StepwiseDiscriminantFunctionAnalysis(), StepwiseDiscriminantFunctionAnalysis(), t_TestPValue(), TotalScatterMatrix(), and WithinGroupCovarianceMatrix().
| ResultItem SourceSinkData::GetEstimatedElementMean | ( | ) |
Computes actual mean concentrations from estimated log-normal parameters.
Calculates the actual concentration means for each element in each source using the estimated μ and σ parameters from Bayesian inference.
Formula: Mean = exp(μ + σ²/2)
Definition at line 2685 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), Elemental_Profile_Set::AppendProfile(), element_order_, elemental_profile_set, ResultItem::SetName(), ResultItem::SetResult(), ResultItem::SetType(), and target_group_.
| ResultItem SourceSinkData::GetEstimatedElementMu | ( | ) |
Retrieves estimated μ parameters from Bayesian inference for source elements.
Returns the inferred μ (log-space mean) parameters for each element in each source group as estimated during MCMC sampling or optimization.
Definition at line 2661 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), Elemental_Profile_Set::AppendProfile(), element_order_, elemental_profile_set, ResultItem::SetName(), ResultItem::SetResult(), ResultItem::SetType(), and target_group_.
| ResultItem SourceSinkData::GetEstimatedElementSigma | ( | ) |
Retrieves estimated σ parameters from Bayesian inference for source elements.
Returns the inferred σ (log-space standard deviation) parameters for each element in each source group as estimated during MCMC sampling or optimization.
Definition at line 2711 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), Elemental_Profile_Set::AppendProfile(), element_order_, elemental_profile_set, ResultItem::SetName(), ResultItem::SetResult(), ResultItem::SetType(), and target_group_.
| Distribution * SourceSinkData::GetFittedDistribution | ( | const string & | element_name | ) |
Get the fitted distribution for a specific element at dataset level.
Returns a pointer to the Distribution object fitted to all data for this element (across all groups). This is the distribution used for likelihood calculations in MCMC.
| element_name | Name of the element |
Definition at line 641 of file sourcesinkdata.cpp.
References element_distributions_.
Get all group names in the dataset.
Returns the names of all sample sets (source and target groups). These are the top-level keys of the SourceSinkData map.
Definition at line 452 of file sourcesinkdata.cpp.
Referenced by ExtractElementDataByGroup().
| vector< ResultItem > SourceSinkData::GetMLRResults | ( | ) |
Retrieves multiple linear regression results for all sample groups.
Collects the organic matter (OM) and particle size regression models for each source group. These regressions are used to correct elemental concentrations for variations in OM content and particle size distribution.
Definition at line 2463 of file sourcesinkdata.cpp.
References ResultItem::SetName(), and ResultItem::SetShowTable().
Referenced by Conductor::ExecuteMLR().
| double SourceSinkData::GetObjectiveFunctionValue | ( | ) |
Returns the objective function value for optimization algorithms.
Computes the negative log-likelihood based on the current parameter values and estimation mode. Used by optimization algorithms where minimizing -log(L) is equivalent to maximizing likelihood L.
Definition at line 1572 of file sourcesinkdata.cpp.
References LogLikelihood(), and parameter_estimation_mode_.
| ResultItem SourceSinkData::GetObservedElementalProfile | ( | ) |
Retrieves the observed elemental concentrations for the selected target sample.
Extracts the measured elemental composition of the currently selected target sample. These are the observed values that the model attempts to reproduce.
Definition at line 2508 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), ElementOrder(), ObservedDataforSelectedSample(), predicted_concentration, selected_target_sample_, ResultItem::SetName(), ResultItem::SetResult(), and ResultItem::SetType().
Referenced by GetObservedvsModeledElementalProfile().
| ResultItem SourceSinkData::GetObservedElementalProfile_Isotope | ( | ) |
Retrieves the observed isotope delta values for the selected target sample.
Extracts the measured isotopic composition (δ values in ‰) of the currently selected target sample.
Definition at line 2531 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), IsotopeOrder(), ObservedDataforSelectedSample_Isotope_delta(), predicted_concentration, selected_target_sample_, ResultItem::SetName(), ResultItem::SetResult(), and ResultItem::SetType().
Referenced by GetObservedvsModeledElementalProfile_Isotope().
| ResultItem SourceSinkData::GetObservedvsModeledElementalProfile | ( | parameter_mode | param_mode = parameter_mode::based_on_fitted_distribution | ) |
Creates a comparison of observed vs modeled elemental profiles.
Generates a profile set containing both the observed target sample composition and the model's predicted composition for side-by-side comparison.
| param_mode | Controls whether to use parametric or empirical source means |
Definition at line 2438 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::AppendProfile(), elemental_profile_set, GetObservedElementalProfile(), GetPredictedElementalProfile(), ResultItem::Result(), ResultItem::SetName(), ResultItem::SetResult(), and ResultItem::SetType().
Referenced by Conductor::ExecuteLevenbergMarquardt().
| ResultItem SourceSinkData::GetObservedvsModeledElementalProfile_Isotope | ( | parameter_mode | param_mode = parameter_mode::based_on_fitted_distribution | ) |
Creates a comparison of observed vs modeled isotope delta values.
Generates a profile set containing both the observed target sample isotopic composition and the model's predicted isotope delta values.
| param_mode | Controls whether to use parametric or empirical source means |
Definition at line 2483 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::AppendProfile(), elemental_profile_set, GetObservedElementalProfile_Isotope(), GetPredictedElementalProfile_Isotope(), ResultItem::Result(), ResultItem::SetName(), ResultItem::SetResult(), and ResultItem::SetType().
Referenced by Conductor::ExecuteLevenbergMarquardt().
| QMap< QString, double > * SourceSinkData::GetOptions | ( | ) |
Retrieves pointer to the options map.
Definition at line 5626 of file sourcesinkdata.cpp.
References options_.
Referenced by MainWindow::onIncludeExcludeSample().
| string SourceSinkData::GetOutputPath | ( | ) | const |
Get the output directory path.
Returns the path where analysis results and output files will be saved.
Definition at line 5633 of file sourcesinkdata.cpp.
References outputpath_.
| string SourceSinkData::GetParameterName | ( | int | index | ) | const |
Get the name of a parameter by its index.
Retrieves the descriptive name of an optimization parameter (e.g., "Agricultural_contribution", "Urban_Al_mu") by its position in the parameters vector.
| index | Parameter index (0-based) |
Definition at line 680 of file sourcesinkdata.cpp.
References Parameter::Name(), and parameter().
|
private |
Retrieves all current parameter values as a vector.
Returns a vector containing all parameter values in the order they appear in the parameters_ vector. The parameter layout depends on estimation_mode_.
Definition at line 2082 of file sourcesinkdata.cpp.
References parameters_.
Referenced by GradientUpdate().
|
private |
Retrieves a single parameter value by index.
| index | Parameter index in the parameters_ vector |
Definition at line 2061 of file sourcesinkdata.cpp.
References parameters_.
| ResultItem SourceSinkData::GetPredictedElementalProfile | ( | parameter_mode | param_mode = parameter_mode::based_on_fitted_distribution | ) |
Generates predicted elemental concentrations for the target sample.
Computes the model's predicted elemental composition using the current source contributions and profiles.
| param_mode | Controls whether to use parametric or empirical source means |
Definition at line 2378 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), ElementOrder(), predicted_concentration, PredictTarget(), ResultItem::SetName(), ResultItem::SetResult(), and ResultItem::SetType().
Referenced by Conductor::ExecuteLevenbergMarquardt(), and GetObservedvsModeledElementalProfile().
| ResultItem SourceSinkData::GetPredictedElementalProfile_Isotope | ( | parameter_mode | param_mode = parameter_mode::based_on_fitted_distribution | ) |
Generates predicted isotope delta values for the target sample.
Computes the model's predicted isotopic composition (δ values in ‰) using current source contributions and isotope profiles.
| param_mode | Controls whether to use parametric or empirical source means |
Definition at line 2415 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), IsotopeOrder(), predicted_concentration, PredictTarget_Isotope_delta(), ResultItem::SetName(), ResultItem::SetResult(), and ResultItem::SetType().
Referenced by GetObservedvsModeledElementalProfile_Isotope().
| CVector SourceSinkData::GetPredictedValues | ( | ) |
Retrieves predicted values for all observations.
Collects the predicted values from all observation objects for comparison with actual observations.
Definition at line 2401 of file sourcesinkdata.cpp.
References observation(), ObservationsCount(), and Observation::PredictedValue().
Get all sample names within a specific group.
Returns the names of all samples (elemental profiles) within a specified source or target group.
| group_name | Name of the group to query |
Definition at line 440 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::GetSampleNames().
Referenced by GenericForm::GenericForm().
| Elemental_Profile_Set * SourceSinkData::GetSampleSet | ( | const string & | name | ) |
Get a sample set (source or target group) by name.
Retrieves a pointer to the Elemental_Profile_Set for a specific group. Returns nullptr if the group does not exist.
| name | Group name to retrieve |
Definition at line 431 of file sourcesinkdata.cpp.
References name.
Referenced by BuildSourceMeanMatrix(), BuildSourceMeanMatrix_Isotopes(), GetContributionVector(), GetContributionVectorSoftmax(), GetElementDistribution(), InitializeContributionsRandomly(), InitializeContributionsRandomlySoftmax(), LM_Batch(), LogLikelihoodSourceElementalDistributions(), ObservedDataforSelectedSample(), ObservedDataforSelectedSample_Isotope(), ObservedDataforSelectedSample_Isotope_delta(), PredictTarget_Isotope_delta(), SetContribution(), SetContributionSoftmax(), SetParameterValue(), and VerifySource().
|
private |
Retrieves the contributions from all sources.
Calculates source contributions where the first (size-2) sources have their contributions stored as parameters, and the last source's contribution is calculated as the remainder to ensure all contributions sum to 1.
Definition at line 1045 of file sourcesinkdata.cpp.
References parameter(), and Parameter::Value().
Referenced by LogPriorContributions().
Retrieves the ordering of source groups.
Definition at line 5565 of file sourcesinkdata.cpp.
References samplesetsorder_.
Referenced by BootStrap(), GetContribution(), InitializeContributionsRandomly(), InitializeContributionsRandomlySoftmax(), MCMC(), NegativeContributionCheck(), ResidualJacobian(), ResidualJacobian_arma(), and ResidualJacobian_softmax().
| vector< ResultItem > SourceSinkData::GetSourceProfiles | ( | ) |
Retrieves elemental profiles for all source groups.
Collects the complete elemental profile sets for each source group, packaged as ResultItems for display.
Definition at line 2606 of file sourcesinkdata.cpp.
References elemental_profile_set, ResultItem::SetName(), ResultItem::SetResult(), ResultItem::SetShowAsString(), ResultItem::SetShowGraph(), ResultItem::SetShowTable(), ResultItem::SetType(), and target_group_.
Referenced by Conductor::ExecuteOMSizeCorrect().
| string SourceSinkData::GetTargetGroup | ( | ) | const |
Retrieves the name of the target group.
Definition at line 5507 of file sourcesinkdata.cpp.
References target_group_.
Referenced by InitializeParametersAndObservations(), ObservedDataforSelectedSample(), ObservedDataforSelectedSample_Isotope(), and ObservedDataforSelectedSample_Isotope_delta().
|
private |
Computes the normalized gradient of the log-likelihood function.
Calculates the gradient vector ∇log(L) using numerical differentiation (finite differences). The gradient points in the direction of steepest ascent for the log-likelihood.
Numerical Differentiation: ∂log(L)/∂θ_i ≈ [log(L(θ + ε·e_i)) - log(L(θ))] / ε
| parameters | Parameter vector at which to evaluate the gradient |
| est_mode | Estimation mode determining which likelihood components to include |
Definition at line 2095 of file sourcesinkdata.cpp.
References epsilon_, LogLikelihood(), and SetParameterValue().
Referenced by GradientUpdate().
| CVector SourceSinkData::GradientUpdate | ( | estimation_mode | estmode = estimation_mode::elemental_profile_and_contribution | ) |
Performs one gradient ascent step with adaptive step size.
Executes a single iteration of gradient ascent optimization on the log-likelihood function using an adaptive step size (distance_coeff_).
Algorithm:
| estmode | Estimation mode determining which likelihood components to include |
Definition at line 2125 of file sourcesinkdata.cpp.
References distance_coeff_, GetParameterValue(), Gradient(), LogLikelihood(), and SetParameterValue().
|
private |
Computes grand mean concentration for an element across all sources.
Calculates the overall mean concentration weighted by sample sizes across all source groups (excluding target).
Formula: μ_grand = Σ(n_i × μ_i) / Σ(n_i)
| element | Name of the element |
| use_log | If true, compute using log-space means |
Definition at line 3662 of file sourcesinkdata.cpp.
References ConcentrationSet::CalculateMean(), ConcentrationSet::CalculateMeanLog(), and target_group_.
| void SourceSinkData::IncludeExcludeAllElements | ( | bool | include_in_analysis | ) |
Sets inclusion flag for all elements.
Enables or disables all elements for analysis in batch.
| include_in_analysis | If true, include all; if false, exclude all |
Definition at line 3651 of file sourcesinkdata.cpp.
References element_information_.
Referenced by FormElementInformation::OnIncludeAllToggled().
Sets element inclusion based on a specified list.
First excludes all elements from analysis, then includes only those specified in the provided list. Useful for restricting analysis to a subset of elements (e.g., elements with sufficient data quality).
| elements | Vector of element names to include in analysis |
Definition at line 3828 of file sourcesinkdata.cpp.
References element_information::element, element_information_, and element_information::isotope.
Referenced by Conductor::ExecuteANOVA(), Conductor::ExecuteAutoSelect(), and Conductor::ExecuteSDFAM().
|
private |
Initialize source contributions randomly (linear constraint).
Randomly initializes contribution values for all sources such that they sum to 1.0 and all values are non-negative. Uses uniform random sampling with rejection until valid contributions are found.
| stream | Source of the random numbers |
Definition at line 689 of file sourcesinkdata.cpp.
References GetContributionVector(), GetSampleSet(), GetSourceOrder(), samplesetsorder_, Elemental_Profile_Set::SetContribution(), SetContribution(), and RandomStream::Uniform().
Referenced by SolveLevenberg_Marquardt().
|
private |
Initialize source contributions randomly (softmax transformation).
Randomly initializes contribution values using softmax transformation of normally distributed random variables. This ensures contributions automatically sum to 1.0 and are non-negative without rejection sampling.
Softmax transformation: contribution_i = exp(X_i) / sum(exp(X_j)) where X ~ N(0,1)
| stream | Source of the random numbers |
Definition at line 706 of file sourcesinkdata.cpp.
References GetSampleSet(), GetSourceOrder(), samplesetsorder_, Elemental_Profile_Set::SetContribution(), SetContributionSoftmax(), and RandomStream::StandardNormal().
Referenced by SolveLevenberg_Marquardt().
| bool SourceSinkData::InitializeParametersAndObservations | ( | const string & | targetsamplename, |
| estimation_mode | est_mode = estimation_mode::elemental_profile_and_contribution ) |
Initialize parameters and observations for MCMC optimization.
Sets up the complete parameter space and observation vector for Bayesian inference of source contributions and/or source profiles. The exact parameters created depend on the estimation mode:
| targetsamplename | Name of the target sample to unmix |
| est_mode | Estimation mode controlling which parameters to optimize |
Definition at line 756 of file sourcesinkdata.cpp.
References Observation::AppendValues(), dirichlet, element_information::element, element_information_, GetElementalProfile(), GetTargetGroup(), element_information::isotope, lognormal, normal, numberofconstituents_, numberofisotopes_, numberofsourcesamplesets_, observations_, only_contributions, Distribution::parameters, parameters_, PopulateConstituentOrders(), samplesetsorder_, selected_target_sample_, Observation::SetName(), Parameter::SetName(), Parameter::SetPriorDistribution(), Parameter::SetRange(), Distribution::SetType(), source_elemental_profiles_based_on_source_data, and target_group_.
Referenced by BootStrap(), BootStrap(), Conductor::ExecuteErrorAnalysis(), Conductor::ExecuteLevenbergMarquardt(), LM_Batch(), MCMC(), MCMC_Batch(), and VerifySource().
| double SourceSinkData::IsotopeBaseMean | ( | Elemental_Profile_Set * | source_group, |
| const string & | base_element, | ||
| parameter_mode | param_mode ) |
Mean content of an isotope's base element in one source group.
From the estimated distribution when the base element is a tracer, and from the distribution fitted to the source samples when it is not (the organic matter constituent, e.g. TOC for delta 13C).
Definition at line 1651 of file sourcesinkdata.cpp.
References based_on_fitted_distribution, distribution, element_order_, Elemental_Profile_Set::GetEstimatedDistribution(), Elemental_Profile_Set::GetFittedDistribution(), and Distribution::Mean().
Referenced by BuildSourceMeanMatrix_Isotopes(), and PredictTarget_Isotope_delta().
Retrieves the ordering of isotopes.
Definition at line 5585 of file sourcesinkdata.cpp.
References isotope_order_.
Referenced by GetObservedElementalProfile_Isotope(), GetPredictedElementalProfile_Isotope(), and MCMC().
Identifies isotopes to be used in CMB analysis.
Scans the element information map and collects all isotopes marked with the 'isotope' role AND flagged for inclusion in analysis.
Definition at line 2221 of file sourcesinkdata.cpp.
References element_information_, element_information::isotope, isotope_order_, and numberofisotopes_.
Lists the isotopes included in the analysis whose base element cannot be used.
Fingerprinting converts an isotope's delta value to a concentration with the concentration of its base element, so the base element must exist, be an element, and be included in the analysis.
Definition at line 2240 of file sourcesinkdata.cpp.
References element_information::element, element_information_, element_information::isotope, and element_information::organic_carbon.
Referenced by Conductor::Execute().
| CMBTimeSeriesSet SourceSinkData::LM_Batch | ( | transformation | transform, |
| bool | apply_om_size_correction, | ||
| map< string, vector< string > > & | negative_elements ) |
Solves CMB model for all target samples using Levenberg-Marquardt.
Performs batch source apportionment on all samples in the target group, solving the CMB model via Levenberg-Marquardt optimization for each sample.
| transform | Transformation type (linear or softmax) for contributions |
| apply_om_size_correction | If true, apply OM and size corrections before solving |
| negative_elements | [out] Map of sample names to vectors of elements with negative values |
Definition at line 4191 of file sourcesinkdata.cpp.
References SourceSinkData(), CreateCorrectedDataset(), GetContributionVector(), GetElementInformation(), GetSampleSet(), InitializeParametersAndObservations(), NegativeValueCheck(), numberofsourcesamplesets_, rtw_, samplesetsorder_, CMBTimeSeriesSet::SetLabel(), SolveLevenberg_Marquardt(), and target_group_.
|
inline |
Why the last ReadFromFile() failed, or empty if it succeeded.
Definition at line 1866 of file sourcesinkdata.h.
References load_error_.
| double SourceSinkData::LogLikelihood | ( | estimation_mode | est_mode = estimation_mode::elemental_profile_and_contribution | ) |
Calculates the total log-likelihood for Bayesian source apportionment.
Computes the posterior log-likelihood by summing multiple components based on the estimation mode. Components include source data likelihood, observation likelihood (elements and isotopes), and contribution priors.
| est_mode | Estimation mode determining which likelihood terms to include |
Definition at line 1577 of file sourcesinkdata.cpp.
References LogLikelihoodModelvsMeasured(), LogLikelihoodModelvsMeasured_Isotope(), LogLikelihoodSourceElementalDistributions(), LogPriorContributions(), only_contributions, and source_elemental_profiles_based_on_source_data.
Referenced by GetObjectiveFunctionValue(), Gradient(), and GradientUpdate().
|
private |
Calculates the log-likelihood of the model prediction versus measured data.
Compares the model's predicted elemental concentrations against the observed data for the selected target sample. Computed in log-space assuming log-normally distributed errors.
Formula: log(L) = -n*log(σ) - ||log(C_pred) - log(C_obs)||² / (2σ²)
| est_mode | Estimation mode determining how predictions are made |
Definition at line 1126 of file sourcesinkdata.cpp.
References based_on_fitted_distribution, direct, elemental_profile_and_contribution, error_stdev_, log, ObservedDataforSelectedSample(), PredictTarget(), and selected_target_sample_.
Referenced by LogLikelihood().
|
private |
Calculates the log-likelihood of model versus measured isotopic data.
Compares the model's predicted isotopic delta values against the observed isotopic data for the selected target sample. Operates in linear space assuming normally distributed errors in delta values.
Formula: log(L) = -n*log(σ_iso) - ||δ_pred - δ_obs||² / (2σ_iso²)
| est_mode | Estimation mode determining how predictions are made |
Definition at line 1157 of file sourcesinkdata.cpp.
References based_on_fitted_distribution, direct, elemental_profile_and_contribution, error_stdev_isotope_, log, ObservedDataforSelectedSample_Isotope_delta(), PredictTarget_Isotope_delta(), and selected_target_sample_.
Referenced by LogLikelihood().
|
private |
Calculates the log-likelihood of source elemental distributions.
Computes the total log-likelihood by evaluating how well each source sample's observed elemental concentrations fit their respective estimated distributions.
Definition at line 1065 of file sourcesinkdata.cpp.
References element_order_, Distribution::EvalLog(), Elemental_Profile_Set::GetElementDistribution(), ConcentrationSet::GetEstimatedDistribution(), GetSampleSet(), numberofsourcesamplesets_, and samplesetsorder_.
Referenced by LogLikelihood().
|
private |
Calculates the log prior probability for source contributions.
Evaluates whether the current source contributions are physically valid by checking if all contributions are non-negative. Acts as a constraint in Bayesian inference.
Definition at line 1057 of file sourcesinkdata.cpp.
References GetSourceContributions().
Referenced by LogLikelihood().
|
private |
Combines all source samples into a single profile set.
Pools samples from all source groups into one unified Elemental_Profile_Set.
Definition at line 3695 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::AppendProfiles(), target_group_, and Elemental_Profile_Set::UpdateElementDistributions().
Referenced by ANOVA().
| Results SourceSinkData::MCMC | ( | const string & | target_sample, |
| map< string, string > | arguments, | ||
| CMCMC< SourceSinkData > * | mcmc, | ||
| ProgressReporter * | progress_window, | ||
| const string & | working_folder ) |
Performs Markov Chain Monte Carlo analysis for Bayesian source apportionment.
Conducts full Bayesian inference using MCMC sampling to estimate posterior distributions of source contributions and model parameters. Generates comprehensive uncertainty quantification including credible intervals, posterior distributions, and predicted concentrations.
| target_sample | Name of target sample to apportion |
| arguments | Map of MCMC settings (number of samples, chains, burnin, etc.) |
| mcmc | Pointer to MCMC sampler object |
| progress_window | Pointer to progress reporter for updates |
| working_folder | Base directory for output files |
Definition at line 4305 of file sourcesinkdata.cpp.
References SourceSinkData(), Results::Append(), Results::AppendError(), CreateCorrectedDataset(), mcmcdiagnostics::Diagnose(), distribution, distribution_with_observed, mcmcdiagnostics::Diagnostics::effective_sample_size, element_information::element, ElementOrder(), GetElementInformation(), GetSourceOrder(), high, CMCMC< T >::initialize(), InitializeParametersAndObservations(), element_information::isotope, IsotopeOrder(), log, low, mcmc_samples, Range::mean, CMCMC< T >::Model, NegativeValueCheck(), normal, observation(), ParseRandomSeed(), CMCMC< T >::predicted, rangeset, rangeset_with_observed, mcmcdiagnostics::Diagnostics::rhat, Range::Set(), Results::SetError(), CMBVector::SetLabel(), Interface::SetLimit(), Range::SetMean(), Range::SetMedian(), ResultItem::SetName(), Results::SetName(), CMBTimeSeriesSet::SetObservedValue(), ProgressReporter::SetProgress(), CMCMC< T >::SetProperty(), CMCMC< T >::SetRandomSeed(), ResultItem::SetResult(), ResultItem::SetShowAsString(), ResultItem::SetShowGraph(), ResultItem::SetShowTable(), ProgressReporter::SetTitle(), ResultItem::SetType(), Range::SetValue(), ResultItem::setXAxisTitle(), ResultItem::SetYAxisMode(), ProgressReporter::SetYAxisTitle(), ResultItem::setYAxisTitle(), ResultItem::SetYLimit(), SourceGroupNames(), ProgressReporter::Start(), CMCMC< T >::step(), Observation::Value(), and vector.
Referenced by Conductor::ExecuteCMBBayesian(), and MCMC_Batch().
| CMBMatrix SourceSinkData::MCMC_Batch | ( | const map< string, string > & | arguments, |
| CMCMC< SourceSinkData > * | mcmc, | ||
| ProgressReporter * | progress_window, | ||
| const string & | working_folder, | ||
| vector< string > * | failed_writes = nullptr ) |
Performs batch MCMC analysis on all target samples.
Conducts full Bayesian MCMC analysis for every sample in the target group, generating comprehensive results for each sample and summarizing credible intervals in a matrix.
Output matrix structure:
| arguments | Map of MCMC settings |
| mcmc | Pointer to MCMC sampler object |
| progress_window | Pointer to progress reporter for updates |
| working_folder | Base directory for output folders |
| failed_writes | If not null, receives one line for each output folder or file that could not be written |
Definition at line 4668 of file sourcesinkdata.cpp.
References ProgressReporter::ClearGraph(), Range::Get(), high, InitializeParametersAndObservations(), low, MCMC(), Range::Mean(), Range::Median(), numberofsourcesamplesets_, SafeFileName(), samplesetsorder_, CMBMatrix::SetColumnLabel(), ProgressReporter::SetLabel(), ProgressReporter::SetProgress2(), CMBMatrix::SetRowLabel(), and target_group_.
|
private |
Computes weighted mean elemental concentrations across all sources.
Calculates the overall mean concentration for each element, weighted by the number of samples in each source group.
Formula: μ_overall = Σ(n_i × μ_i) / Σ(n_i)
Definition at line 5229 of file sourcesinkdata.cpp.
References element_order_, GetElementNames(), MeanElementalContent(), CMBVector::SetLabels(), and target_group_.
Referenced by BetweenGroupCovarianceMatrix(), MeanElementalContent(), and TotalScatterMatrix().
Computes mean elemental concentrations for a specific group.
Calculates the mean concentration for each element within a specified source or target group.
| group_name | Name of the group (source or target) |
Definition at line 5213 of file sourcesinkdata.cpp.
References GetElementNames(), and CMBVector::SetLabels().
Checks the solved source contributions for negative values.
A contribution is the fraction of the target sample a source supplied, so a negative one is not a physically possible answer. The linear parameterization of Levenberg-Marquardt constrains the contributions to sum to one but not to stay non-negative, so it can return one; the softmax parameterization cannot.
Call after solving. Values below zero only by round-off are not reported.
Definition at line 3628 of file sourcesinkdata.cpp.
References GetContributionVector(), and GetSourceOrder().
Referenced by Conductor::ExecuteLevenbergMarquardt().
Checks for zero or negative concentration values across all sources.
Scans all source groups for elements with zero or negative concentrations, which are problematic for log-normal distributions and certain statistical analyses. Returns detailed error messages identifying problematic elements and their source groups.
Definition at line 3599 of file sourcesinkdata.cpp.
References element_order_, PopulateConstituentOrders(), and target_group_.
Referenced by Conductor::CheckNegativeElements(), LM_Batch(), MCMC(), and VerifySource().
| Observation * SourceSinkData::observation | ( | size_t | i | ) |
Retrieves pointer to an observation by index.
| i | Observation index (0-based) |
Definition at line 5493 of file sourcesinkdata.cpp.
References observations_.
Referenced by GetPredictedValues(), MCMC(), PredictTarget(), and PredictTarget_Isotope_delta().
| size_t SourceSinkData::ObservationsCount | ( | ) |
Returns the number of observations.
Definition at line 5472 of file sourcesinkdata.cpp.
References observations_.
Referenced by GetPredictedValues().
|
private |
Retrieves the observed elemental data for a selected target sample.
Extracts the elemental concentration values for a specific target sample, returning them in the order specified by element_order_.
| SelectedTargetSample | Name of the target sample (empty = use selected_target_sample_) |
Definition at line 1085 of file sourcesinkdata.cpp.
References element_order_, Elemental_Profile_Set::GetProfile(), GetSampleSet(), GetTargetGroup(), Elemental_Profile::GetValue(), selected_target_sample_, and SelectedTargetSample().
Referenced by GetObservedElementalProfile(), LogLikelihoodModelvsMeasured(), ResidualVector(), and ResidualVector_arma().
|
private |
Retrieves the observed isotopic data for a selected target sample.
Extracts and converts isotopic ratio values for a specific target sample into absolute concentrations using the delta notation formula: concentration = (δ/1000 + 1) × standard_ratio × base_element_concentration
| SelectedTargetSample | Name of the target sample (empty = use selected_target_sample_) |
Definition at line 1097 of file sourcesinkdata.cpp.
References element_information_, Elemental_Profile_Set::GetProfile(), GetSampleSet(), GetTargetGroup(), Elemental_Profile::GetValue(), isotope_order_, selected_target_sample_, and SelectedTargetSample().
|
private |
Retrieves the observed isotopic data in delta notation.
Extracts isotopic ratio values for a specific target sample in their original delta notation (‰) format, without conversion to absolute concentrations.
| SelectedTargetSample | Name of the target sample (empty = use selected_target_sample_) |
Definition at line 1112 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::GetProfile(), GetSampleSet(), GetTargetGroup(), Elemental_Profile::GetValue(), isotope_order_, selected_target_sample_, and SelectedTargetSample().
Referenced by GetObservedElementalProfile_Isotope(), LogLikelihoodModelvsMeasured_Isotope(), ResidualVector(), and ResidualVector_arma().
Retrieves the names of OM and particle size constituents.
Returns a vector containing the names of the organic matter and particle size constituents set via PerformRegressionVsOMAndSize().
Definition at line 5616 of file sourcesinkdata.cpp.
References omconstituent_, and sizeconstituent_.
|
private |
Performs one iteration of the Levenberg-Marquardt optimization algorithm.
Computes the parameter update step for source contributions using the Levenberg-Marquardt algorithm, which interpolates between Gauss-Newton and gradient descent methods.
The algorithm solves: (J^T J + λ diag(J^T J)) dx = -J^T r
| lambda | Damping parameter controlling trade-off (typical: 0.001 to 1000) |
Definition at line 1344 of file sourcesinkdata.cpp.
References ResidualJacobian(), and ResidualVector().
Referenced by SolveLevenberg_Marquardt().
|
private |
Performs one iteration of Levenberg-Marquardt using softmax parameterization.
Computes the parameter update step for softmax-parameterized source contributions.
| lambda | Damping parameter |
Definition at line 1374 of file sourcesinkdata.cpp.
References ResidualJacobian_softmax(), and ResidualVector().
Referenced by SolveLevenberg_Marquardt().
| SourceSinkData & SourceSinkData::operator= | ( | const SourceSinkData & | other | ) |
Assignment operator.
Assigns all data from another SourceSinkData object to this one. Performs deep copy of all member variables.
| other | The SourceSinkData object to assign from |
Definition at line 83 of file sourcesinkdata.cpp.
References SourceSinkData(), constituent_order_, distance_coeff_, element_distributions_, element_information_, element_order_, isotope_order_, numberofconstituents_, numberofisotopes_, numberofsourcesamplesets_, observations_, omconstituent_, options_, outputpath_, parameter_estimation_mode_, parameters_, regression_p_value_threshold_, samplesetsorder_, selected_target_sample_, size_om_order_, sizeconstituent_, target_group_, and tools_used_.
|
private |
Computes optimal Box-Cox transformation parameters for all elements.
Determines the optimal λ (lambda) parameter for each element's Box-Cox transformation by maximizing the log-likelihood of achieving normality.
Box-Cox transformation: y = (x^λ - 1) / λ (or ln(x) if λ = 0)
Special cases:
Definition at line 3372 of file sourcesinkdata.cpp.
References ExtractConcentrationSet(), GetElementNames(), and CMBVector::SetLabels().
Referenced by BoxCoxTransformed().
| QJsonObject SourceSinkData::OptionsToJsonObject | ( | ) | const |
Exports analysis options/settings to a JSON object.
Serializes all analysis configuration options (numerical parameters, thresholds, flags) as key-value pairs.
Definition at line 2751 of file sourcesinkdata.cpp.
References options_.
Referenced by MainWindow::buildProjectJson().
| void SourceSinkData::OutlierAnalysisForAll | ( | const double & | lower_threshold = -3, |
| const double & | upper_threshold = 3 ) |
Performs outlier detection on all source groups.
Applies Box-Cox transformation and identifies outliers based on standardized residuals. Samples with standardized values outside the threshold range are flagged as outliers in their notes.
Detection method:
| lower_threshold | Lower bound for standardized values (e.g., -3.0) |
| upper_threshold | Upper bound for standardized values (e.g., +3.0) |
Definition at line 3007 of file sourcesinkdata.cpp.
References target_group_.
Referenced by MainWindow::onIncludeExcludeSample().
| Parameter * SourceSinkData::parameter | ( | size_t | i | ) |
Retrieves pointer to a parameter by index.
| i | Parameter index (0-based) |
Definition at line 5477 of file sourcesinkdata.cpp.
References parameters_.
Referenced by GetParameterName(), and GetSourceContributions().
| const Parameter * SourceSinkData::parameter | ( | size_t | i | ) | const |
Retrieves const pointer to a parameter by index.
| i | Parameter index (0-based) |
Definition at line 5485 of file sourcesinkdata.cpp.
References parameters_.
| estimation_mode SourceSinkData::ParameterEstimationMode | ( | ) |
Retrieves the current estimation mode.
Definition at line 5517 of file sourcesinkdata.cpp.
References parameter_estimation_mode_.
Retrieves reference to the parameters vector.
Definition at line 5462 of file sourcesinkdata.cpp.
References parameters_.
| size_t SourceSinkData::ParametersCount | ( | ) |
Returns the number of parameters.
Definition at line 5467 of file sourcesinkdata.cpp.
References parameters_.
| bool SourceSinkData::PerformRegressionVsOMAndSize | ( | const string & | om, |
| const string & | particle_size, | ||
| regression_form | form, | ||
| const double & | p_value_threshold = 0.05 ) |
Performs multiple linear regression of elements vs OM and particle size.
Computes regression models for all sample groups to quantify how elemental concentrations vary with organic matter (OM) content and particle size. These models are used to correct elemental profiles for OM/size variations.
Regression forms:
| om | Name of the organic matter constituent (e.g., "OC", "OM") |
| particle_size | Name of the particle size constituent (e.g., "D50", "PM2.5") |
| form | Regression form (linear or multiplicative) |
| p_value_threshold | Significance threshold for including predictors (default: 0.05) |
Definition at line 2967 of file sourcesinkdata.cpp.
References element_information_, MultipleLinearRegression::GetIndependentVariableNames(), element_information::isotope, name, omconstituent_, regression_p_value_threshold_, MultipleLinearRegression::SetEffective(), and sizeconstituent_.
Referenced by Conductor::ExecuteMLR().
| void SourceSinkData::PopulateConstituentOrders | ( | ) |
Populates all element ordering vectors used throughout CMB analysis.
Scans the element information map and organizes elements into separate ordering vectors based on their roles. These vectors define the order in which elements appear in matrices, parameter vectors, and observations.
Populated Vectors:
Definition at line 2266 of file sourcesinkdata.cpp.
References constituent_order_, element_information::element, element_information_, element_order_, element_information::isotope, isotope_order_, numberofconstituents_, element_information::organic_carbon, element_information::particle_size, and size_om_order_.
Referenced by InitializeParametersAndObservations(), and NegativeValueCheck().
| void SourceSinkData::PopulateElementDistributions | ( | ) |
Populate element distributions from all groups.
Builds concentration distributions for each element by collecting all concentration values across all groups (sources and target). First updates distributions within each group, then aggregates them into the overall element_distributions_ map.
Definition at line 566 of file sourcesinkdata.cpp.
References element_distributions_, and GetElementNames().
Referenced by BoxCoxTransformed(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), ExtractChemicalElements(), ExtractSpecificElements(), RandomlyEliminateSourceSamples(), and ReplaceSourceAsTarget().
| void SourceSinkData::PopulateElementInformation | ( | const map< string, element_information > * | ElementInfo = nullptr | ) |
Populate element information metadata.
Initializes or updates the element_information_ map with metadata for all elements in the dataset. If ElementInfo is provided, copies metadata from it; otherwise initializes with default values.
Also updates the count of source sample sets (total groups minus target group if present).
| ElementInfo | Optional source of element metadata (nullptr for defaults) |
Definition at line 650 of file sourcesinkdata.cpp.
References element_information_, GetElementNames(), numberofsourcesamplesets_, and target_group_.
Referenced by CreateCorrectedAndFilteredDataset(), DiscriminantFunctionAnalysis(), DiscriminantFunctionAnalysis(), ExtractChemicalElements(), ExtractSpecificElements(), RandomlyEliminateSourceSamples(), and ReplaceSourceAsTarget().
|
private |
Predicts target sample elemental concentrations based on source contributions.
Calculates the predicted elemental composition of the target sample as a linear combination of source profiles weighted by their contributions: C_predicted = Σ (source_mean_i × contribution_i)
| param_mode | Parameter mode for obtaining source mean values |
Definition at line 1520 of file sourcesinkdata.cpp.
References BuildSourceMeanMatrix(), element_order_, GetContributionVector(), observation(), and Observation::SetPredictedValue().
Referenced by GetPredictedElementalProfile(), LogLikelihoodModelvsMeasured(), ResidualVector(), and ResidualVector_arma().
|
private |
Predicts target sample isotopic compositions based on source contributions.
Calculates the predicted isotopic composition (as absolute concentrations) of the target sample as a linear combination of source isotopic profiles.
| param_mode | Parameter mode for obtaining source mean values |
Definition at line 1536 of file sourcesinkdata.cpp.
References BuildSourceMeanMatrix_Isotopes(), and GetContributionVector().
|
private |
Predicts target sample isotopic compositions in delta notation.
Calculates the predicted isotopic composition in delta notation (‰) by first computing absolute concentrations, then converting back to delta values.
| param_mode | Parameter mode for obtaining source mean values |
Definition at line 1546 of file sourcesinkdata.cpp.
References BuildSourceMeanMatrix_Isotopes(), element_information_, element_order_, GetContributionVector(), GetSampleSet(), isotope_order_, IsotopeBaseMean(), numberofisotopes_, numberofsourcesamplesets_, observation(), samplesetsorder_, and Observation::SetPredictedValue().
Referenced by GetPredictedElementalProfile_Isotope(), LogLikelihoodModelvsMeasured_Isotope(), ResidualVector(), and ResidualVector_arma().
|
private |
Creates dataset with randomly excluded source samples for validation.
Generates a new dataset with a specified percentage of source samples randomly removed. Useful for bootstrap validation and uncertainty analysis.
| percentage | Percentage of samples to exclude (0-100) |
Definition at line 3852 of file sourcesinkdata.cpp.
References SourceSinkData(), AssignAllDistributions(), element_information_, omconstituent_, PopulateElementDistributions(), PopulateElementInformation(), RandomlypickSamples(), sizeconstituent_, and target_group_.
Referenced by BootStrap(), and BootStrap().
|
private |
Randomly selects a subset of source samples.
Performs Bernoulli sampling on all source samples, where each sample is independently included with the specified probability.
| percentage | Probability of selecting each sample (0.0 to 1.0) |
Definition at line 4283 of file sourcesinkdata.cpp.
References AllSourceSampleNames(), and RandomStream::Uniform().
Referenced by RandomlyEliminateSourceSamples().
| bool SourceSinkData::ReadElementDatafromJsonObject | ( | const QJsonObject & | jsonobject | ) |
Deserializes elemental profile data from a JSON object.
Loads all sample groups and their elemental profiles from JSON format. Clears existing data before loading.
| jsonobject | JSON object containing elemental profile sets |
Definition at line 2805 of file sourcesinkdata.cpp.
References ReadElementDatafromJsonObject().
Referenced by ReadElementDatafromJsonObject(), and ReadFromFile().
| bool SourceSinkData::ReadElementDatafromJsonObject | ( | const QJsonObject & | jsonobject, |
| QString & | error ) |
As ReadElementDatafromJsonObject(), reporting a refused value.
| error | Set to "group 'G', sample 'S', constituent 'X': <reason>" if a value is not a finite number |
Definition at line 2811 of file sourcesinkdata.cpp.
References elemental_profile_set.
| bool SourceSinkData::ReadElementInformationfromJsonObject | ( | const QJsonObject & | jsonobject | ) |
Deserializes element information metadata from a JSON object.
Loads element roles, standard ratios, base elements, and inclusion flags from JSON format. Clears existing element information before loading.
| jsonobject | JSON object containing element metadata |
Definition at line 2784 of file sourcesinkdata.cpp.
References element_information::base_element, element_information_, element_information::include_in_analysis, element_information::notes, element_information::Role, Role(), and element_information::standard_ratio.
Referenced by ReadFromFile().
| bool SourceSinkData::ReadFromFile | ( | QFile * | fil | ) |
Loads complete dataset from a JSON file.
Deserializes all dataset components from a JSON file: elemental profiles, element information, tools used, options, and target group designation. Clears existing data before loading.
| fil | Pointer to an open QFile for reading |
Definition at line 2878 of file sourcesinkdata.cpp.
References Clear(), load_error_, ReadElementDatafromJsonObject(), ReadElementInformationfromJsonObject(), ReadOptionsfromJsonObject(), ReadToolsUsedFromJsonObject(), and target_group_.
Referenced by MainWindow::LoadModel().
| bool SourceSinkData::ReadOptionsfromJsonObject | ( | const QJsonObject & | jsonobject | ) |
Deserializes analysis options from a JSON object.
Loads configuration options and settings from JSON format.
| jsonobject | JSON object containing option key-value pairs |
Definition at line 2832 of file sourcesinkdata.cpp.
References options_.
Referenced by ReadFromFile().
| bool SourceSinkData::ReadToolsUsedFromJsonObject | ( | const QJsonArray & | jsonarray | ) |
Deserializes the list of analysis tools from a JSON array.
| jsonarray | JSON array containing tool names |
Definition at line 2773 of file sourcesinkdata.cpp.
References AddtoToolsUsed().
Referenced by ReadFromFile().
|
private |
Creates a new dataset with a source sample designated as the target.
Generates a modified dataset where a specified source sample becomes the new target sample. Useful for leave-one-out validation.
| source_sample_name | Name of the source sample to use as new target |
Definition at line 3902 of file sourcesinkdata.cpp.
References SourceSinkData(), Elemental_Profile_Set::AppendProfile(), AssignAllDistributions(), element_information_, omconstituent_, PopulateElementDistributions(), PopulateElementInformation(), Sample(), sizeconstituent_, and target_group_.
Referenced by VerifySource().
|
private |
Calculates the Jacobian matrix of residuals with respect to contributions.
Computes the numerical derivative of the residual vector with respect to the first (n-1) source contributions using finite differences.
Definition at line 1278 of file sourcesinkdata.cpp.
References element_order_, GetContributionVector(), GetSourceOrder(), isotope_order_, ResidualVector(), and SetContribution().
Referenced by OneStepLevenberg_Marquardt().
|
private |
Calculates the Jacobian matrix of residuals with respect to contributions (Armadillo).
Computes the numerical derivative of the residual vector with respect to the first (n-1) source contributions using finite differences.
The Jacobian matrix J has dimensions [(n-1) sources × (elements + isotopes)], where J[i,j] = ∂residual_j / ∂contribution_i
Definition at line 1246 of file sourcesinkdata.cpp.
References element_order_, GetContributionVector(), GetSourceOrder(), isotope_order_, ResidualVector_arma(), and SetContribution().
|
private |
Calculates the Jacobian using softmax parameterization of contributions.
Computes the numerical derivative of residuals with respect to unconstrained softmax parameters. Includes all n sources since softmax transformation ensures contributions sum to 1 automatically.
Definition at line 1310 of file sourcesinkdata.cpp.
References element_order_, GetContributionVectorSoftmax(), GetSourceOrder(), isotope_order_, ResidualVector(), and SetContributionSoftmax().
Referenced by OneStepLevenberg_Marquardt_softmax().
|
private |
Calculates the combined residual vector for elemental and isotopic predictions.
Computes residuals between predicted and observed values for both elemental concentrations (in log-space) and isotopic delta values (in linear space).
Combined residual vector structure: [log(C_pred/C_obs) for each element, δ_pred - δ_obs for each isotope]
Definition at line 1183 of file sourcesinkdata.cpp.
References direct, ObservedDataforSelectedSample(), ObservedDataforSelectedSample_Isotope_delta(), PredictTarget(), PredictTarget_Isotope_delta(), and selected_target_sample_.
Referenced by OneStepLevenberg_Marquardt(), OneStepLevenberg_Marquardt_softmax(), ResidualJacobian(), ResidualJacobian_softmax(), and SolveLevenberg_Marquardt().
|
private |
Calculates the combined residual vector using Armadillo vector format.
Armadillo-based implementation of residual calculation for compatibility with linear algebra operations and optimization routines that use Armadillo types.
Definition at line 1221 of file sourcesinkdata.cpp.
References ObservedDataforSelectedSample(), ObservedDataforSelectedSample_Isotope_delta(), PredictTarget(), PredictTarget_Isotope_delta(), and selected_target_sample_.
Referenced by ResidualJacobian_arma().
| QString SourceSinkData::Role | ( | const element_information::role & | role | ) | const |
Converts element role enum to string representation.
Converts the element_information::role enumeration to a human-readable string for serialization, display, or file output.
Mappings:
| role | Element role enumeration value |
Definition at line 2931 of file sourcesinkdata.cpp.
References element_information::do_not_include, element_information::element, element_information::isotope, element_information::organic_carbon, and element_information::particle_size.
Referenced by AssignAllDistributions(), ElementInformationToJsonObject(), and ReadElementInformationfromJsonObject().
| element_information::role SourceSinkData::Role | ( | const QString & | role_string | ) | const |
Converts string representation to element role enum.
Parses a string and returns the corresponding element_information::role enumeration for deserialization or configuration loading.
Mappings:
| role_string | QString representation of the role |
Definition at line 2949 of file sourcesinkdata.cpp.
References element_information::do_not_include, element_information::element, element_information::isotope, element_information::organic_carbon, and element_information::particle_size.
| Elemental_Profile SourceSinkData::Sample | ( | const string & | sample_name | ) | const |
Retrieves an elemental profile by sample name.
Searches all groups (sources and target) for a sample with the specified name and returns its elemental profile. Returns empty profile if not found.
| sample_name | Name of the sample to retrieve |
Definition at line 3888 of file sourcesinkdata.cpp.
Referenced by ReplaceSourceAsTarget().
Retrieves the ordering of sample sets.
Definition at line 5570 of file sourcesinkdata.cpp.
References samplesetsorder_.
| string SourceSinkData::SelectedTargetSample | ( | ) | const |
Retrieves the name of the currently selected target sample.
Definition at line 5659 of file sourcesinkdata.cpp.
References selected_target_sample_.
Referenced by ObservedDataforSelectedSample(), ObservedDataforSelectedSample_Isotope(), and ObservedDataforSelectedSample_Isotope_delta().
|
private |
Sets all source contributions from a vector.
Updates contributions for multiple sources. If the vector has n-1 elements, the last contribution is computed automatically.
| contributions | Vector of contribution values |
Definition at line 1778 of file sourcesinkdata.cpp.
References SetContribution().
|
private |
Sets a single source contribution value.
Updates the contribution fraction for the specified source and automatically recalculates the last source's contribution to maintain the sum constraint.
| source_index | Index of the source to update (0-based) |
| contribution_value | New contribution fraction (must satisfy 0 ≤ f ≤ 1) |
Definition at line 1754 of file sourcesinkdata.cpp.
References GetContributionVector(), GetSampleSet(), samplesetsorder_, and Elemental_Profile_Set::SetContribution().
Referenced by InitializeContributionsRandomly(), ResidualJacobian(), ResidualJacobian_arma(), SetContribution(), SetContributionSoftmax(), and SolveLevenberg_Marquardt().
|
private |
Sets all source contributions using softmax transformation.
Applies the softmax transformation to convert unconstrained parameters to valid contribution fractions: f_i = exp(x_i) / Σ exp(x_j)
| softmax_params | Vector of unconstrained softmax parameters |
Definition at line 1793 of file sourcesinkdata.cpp.
References contribution, GetContributionVector(), SetContribution(), and SetContributionSoftmax().
|
private |
Sets a single softmax parameter value.
Updates the unconstrained softmax parameter for the specified source. Does NOT automatically update the actual contribution fractions.
| source_index | Index of the source to update (0-based) |
| softmax_value | New softmax parameter (unbounded: x ∈ ℝ) |
Definition at line 1771 of file sourcesinkdata.cpp.
References GetSampleSet(), samplesetsorder_, and Elemental_Profile_Set::SetContributionSoftmax().
Referenced by InitializeContributionsRandomlySoftmax(), ResidualJacobian_softmax(), SetContributionSoftmax(), and SolveLevenberg_Marquardt().
| void SourceSinkData::SetOMandSizeConstituents | ( | const string & | _omconstituent, |
| const string & | _sizeconstituent ) |
Sets the names of OM and particle size constituents.
| _omconstituent | Name of organic matter constituent |
| _sizeconstituent | Name of particle size constituent |
Definition at line 5597 of file sourcesinkdata.cpp.
References omconstituent_, and sizeconstituent_.
Referenced by Conductor::ExecuteMLR(), and MainWindow::LoadModel().
Sets the names of OM and particle size constituents from a vector.
| _omsizeconstituents | Vector with [0]=OM name, [1]=size name |
Definition at line 5603 of file sourcesinkdata.cpp.
References omconstituent_, and sizeconstituent_.
| bool SourceSinkData::SetOutputPath | ( | const string & | output_path | ) |
Set the output directory path.
Specifies the directory where analysis results and output files should be saved.
| output_path | Path to output directory |
Definition at line 5638 of file sourcesinkdata.cpp.
References outputpath_.
| void SourceSinkData::SetParameterEstimationMode | ( | estimation_mode | est_mode | ) |
Sets the estimation mode for parameter optimization.
Specifies which parameters will be optimized during inference:
| est_mode | Estimation mode to use |
Definition at line 5512 of file sourcesinkdata.cpp.
References parameter_estimation_mode_.
|
private |
Sets multiple parameter values from a vector.
Updates all parameters using values from the provided vector. Each parameter update triggers synchronization with the corresponding model component.
| values | Vector containing new parameter values |
Definition at line 2066 of file sourcesinkdata.cpp.
References SetParameterValue().
| bool SourceSinkData::SetParameterValue | ( | size_t | index, |
| double | value ) |
Sets a parameter value and updates corresponding model components.
Updates a parameter in the parameter vector and synchronizes the change with the appropriate model component (contributions, distribution parameters, or error terms). The parameter vector layout depends on the estimation mode.
Parameter Vector Layout (full mode: elemental_profile_and_contribution): [0 to n-2]: Contribution parameters (n-1 sources) [n-1 to end of element μ]: Element μ parameters [element μ to end of isotope μ]: Isotope μ parameters [isotope μ to end of element σ]: Element σ parameters [element σ to end of isotope σ]: Isotope σ parameters [end-1]: Error std dev for elements [end]: Error std dev for isotopes
| index | Parameter index in the parameters_ vector |
| value | New parameter value |
Definition at line 1905 of file sourcesinkdata.cpp.
References element_order_, elemental_profile_and_contribution, error_stdev_, error_stdev_isotope_, GetContributionVector(), GetElementDistribution(), GetSampleSet(), isotope_order_, numberofconstituents_, numberofisotopes_, numberofsourcesamplesets_, only_contributions, parameter_estimation_mode_, parameters_, samplesetsorder_, Elemental_Profile_Set::SetContribution(), ConcentrationSet::SetEstimatedMu(), ConcentrationSet::SetEstimatedSigma(), and source_elemental_profiles_based_on_source_data.
Referenced by Gradient(), GradientUpdate(), and SetParameterValue().
| void SourceSinkData::SetProgressReporter | ( | ProgressReporter * | _rtw | ) |
Sets the progress window for displaying optimization progress.
Assigns a progress window that will receive updates during long-running operations like MCMC sampling, bootstrap analysis, or batch processing.
| _rtw | Pointer to ProgressReporter object (nullptr to disable progress reporting) |
Definition at line 5522 of file sourcesinkdata.cpp.
References rtw_.
Referenced by Conductor::ExecuteDFA(), Conductor::ExecuteDFAM(), Conductor::ExecuteDFAOnevsRest(), Conductor::ExecuteErrorAnalysis(), Conductor::ExecuteLevenbergMarquardt(), Conductor::ExecuteLevenbergMarquardtBatch(), Conductor::ExecuteSDFA(), Conductor::ExecuteSDFAM(), Conductor::ExecuteSDFAOnevsRest(), and Conductor::ExecuteSourceVerify().
| bool SourceSinkData::SetSelectedTargetSample | ( | const string & | sample_name | ) |
Sets the currently selected target sample for analysis.
Specifies which sample from the target group will be used as the receptor in CMB calculations. Validates that the sample exists before setting.
| sample_name | Name of the target sample to analyze |
Definition at line 5646 of file sourcesinkdata.cpp.
References selected_target_sample_, and target_group_.
Referenced by Conductor::ExecuteOMSizeCorrect().
| bool SourceSinkData::SetTargetGroup | ( | const string & | targroup | ) |
Sets the target/sink group designation.
Specifies which group in the dataset represents the target samples (receptor sites to be unmixed via source apportionment).
| targroup | Name of the target group |
Definition at line 5501 of file sourcesinkdata.cpp.
References target_group_.
Referenced by MainWindow::LoadModel().
Retrieves the ordering of size and OM constituents.
Definition at line 5590 of file sourcesinkdata.cpp.
References size_om_order_.
| bool SourceSinkData::SolveLevenberg_Marquardt | ( | transformation | trans = transformation::linear | ) |
Solves for optimal source contributions using the Levenberg-Marquardt algorithm.
Iteratively optimizes source contributions to minimize the residual between predicted and observed elemental/isotopic compositions. The algorithm adaptively adjusts the damping parameter based on convergence behavior.
Convergence criteria (any of):
| trans | Parameterization method:
|
Definition at line 1404 of file sourcesinkdata.cpp.
References DefaultRandomSeed, GetContributionVector(), GetContributionVectorSoftmax(), InitializeContributionsRandomly(), InitializeContributionsRandomlySoftmax(), linear, OneStepLevenberg_Marquardt(), OneStepLevenberg_Marquardt_softmax(), ResidualVector(), rtw_, SetContribution(), SetContributionSoftmax(), and softmax.
Referenced by BootStrap(), BootStrap(), Conductor::ExecuteLevenbergMarquardt(), LM_Batch(), and VerifySource().
Retrieves the names of all source groups (excluding target).
Returns a list of source group names, which are the pollution/emission sources being apportioned in the CMB analysis.
Definition at line 2320 of file sourcesinkdata.cpp.
References target_group_.
Referenced by GenericForm::GenericForm(), and MCMC().
Performs stepwise discriminant analysis across all source groups.
Iteratively selects elements that best discriminate among all source groups using forward selection.
Definition at line 5328 of file sourcesinkdata.cpp.
References SourceSinkData(), DFA_P_Value(), DFA_Projected(), ExtractSpecificElements(), CMBVectorSet::FTest_p_value(), GetElementNames(), rtw_, and WilksLambda().
Performs stepwise discriminant analysis for one source vs all others.
Iteratively selects elements that best discriminate one source from all other sources combined using forward selection.
| source1 | Name of source group to test against others |
Definition at line 5393 of file sourcesinkdata.cpp.
References SourceSinkData(), DiscriminantFunctionAnalysis(), ExtractSpecificElements(), DFA_result::F_test_P_value, GetElementNames(), DFA_result::p_values, rtw_, and DFA_result::wilkslambda.
| vector< CMBVector > SourceSinkData::StepwiseDiscriminantFunctionAnalysis | ( | const string & | source1, |
| const string & | source2 ) |
Performs stepwise discriminant analysis between two specific sources.
Iteratively selects elements that best discriminate between two source groups using a forward selection procedure. At each step, adds the element that most improves group separation (lowest p-value).
| source1 | Name of first source group |
| source2 | Name of second source group |
Definition at line 5258 of file sourcesinkdata.cpp.
References SourceSinkData(), DiscriminantFunctionAnalysis(), DFA_result::eigen_vectors, ExtractSpecificElements(), DFA_result::F_test_P_value, GetElementNames(), DFA_result::p_values, rtw_, and DFA_result::wilkslambda.
Referenced by Conductor::ExecuteSDFA(), Conductor::ExecuteSDFAM(), and Conductor::ExecuteSDFAOnevsRest().
| Elemental_Profile SourceSinkData::t_TestPValue | ( | const string & | source1, |
| const string & | source2, | ||
| bool | use_log ) |
Computes t-test p-values for element-wise differences between two sources.
Performs independent two-sample t-tests for each element to assess whether concentrations differ significantly between two source groups. Lower p-values indicate stronger evidence that the sources differ for that element.
T-statistic: t = (μ₁ - μ₂) / √(σ₁²/n₁ + σ₂²/n₂)
| source1 | Name of first source group |
| source2 | Name of second source group |
| use_log | If true, perform test on log-transformed concentrations; if false, use linear-space concentrations |
Definition at line 3393 of file sourcesinkdata.cpp.
References Elemental_Profile::AppendElement(), ConcentrationSet::CalculateMean(), ConcentrationSet::CalculateMeanLog(), ConcentrationSet::CalculateStdDev(), ConcentrationSet::CalculateStdDevLog(), and GetElementNames().
Referenced by DifferentiationPower_P_value(), and Conductor::ExecuteEDP().
|
private |
Collects all source samples except those from a specified source group.
Creates a combined profile set containing samples from all source groups except the specified one and the target group. Useful for "one vs rest" comparisons.
| excluded_source | Name of the source group to exclude |
Definition at line 3174 of file sourcesinkdata.cpp.
References Elemental_Profile_Set::AppendProfile(), and target_group_.
Referenced by DiscriminantFunctionAnalysis().
| bool SourceSinkData::ToolsUsed | ( | const string & | tool_name | ) |
Checks if a specific analysis tool has been used.
Queries the tools_used list to determine if a particular analysis method or tool has been applied to this dataset.
| tool_name | Name of the tool to check (e.g., "MCMC", "Bootstrap") |
Definition at line 4794 of file sourcesinkdata.cpp.
References tools_used_.
Referenced by AddtoToolsUsed().
| QJsonArray SourceSinkData::ToolsUsedToJsonObject | ( | ) | const |
Exports the list of analysis tools used to a JSON array.
Serializes the names of all statistical/analytical tools that have been applied to this dataset (e.g., "MCMC", "Levenberg-Marquardt", "BoxCox").
Definition at line 2738 of file sourcesinkdata.cpp.
References tools_used_.
Referenced by MainWindow::buildProjectJson().
|
private |
Counts the total number of source samples across all source groups.
Sums the number of samples in all source groups, excluding the target group.
Definition at line 3136 of file sourcesinkdata.cpp.
References target_group_.
Referenced by DFA_P_Value().
|
private |
Computes total scatter matrix.
Calculates the overall covariance matrix treating all source samples as a single population. Represents total variability.
Formula: S_T = Σ Σ[(x_ij - μ_overall)(x_ij - μ_overall)ᵀ] / N
Relationship: S_T = S_W + S_B
Definition at line 4997 of file sourcesinkdata.cpp.
References GetElementNames(), MeanElementalContent(), and target_group_.
| CMBTimeSeriesSet SourceSinkData::VerifySource | ( | const string & | source_group, |
| bool | use_softmax, | ||
| bool | apply_om_size_correction ) |
Performs leave-one-out validation on a source group.
Tests source apportionment accuracy by iteratively treating each sample from a source group as an unknown target, solving the CMB model, and comparing estimated contributions against the known true source.
Ideal result: Sample shows ~100% contribution from its true source
| source_group | Name of source group to validate |
| use_softmax | If true, use softmax transformation for contributions |
| apply_om_size_correction | If true, apply OM and size corrections |
Definition at line 4106 of file sourcesinkdata.cpp.
References SourceSinkData(), CreateCorrectedDataset(), GetContributionVector(), GetElementInformation(), GetSampleSet(), InitializeParametersAndObservations(), linear, NegativeValueCheck(), numberofsourcesamplesets_, ReplaceSourceAsTarget(), rtw_, samplesetsorder_, CMBTimeSeriesSet::SetLabel(), softmax, SolveLevenberg_Marquardt(), and target_group_.
Referenced by Conductor::ExecuteSourceVerify().
|
private |
Computes Wilks' Lambda statistic for multivariate group separation.
Calculates Wilks' Lambda, a multivariate test statistic measuring the ratio of within-group to total variance.
Formula: Λ = |S_W| / |S_T| = |S_W| / |S_W + S_B|
Interpretation:
Definition at line 5038 of file sourcesinkdata.cpp.
References BetweenGroupCovarianceMatrix(), and WithinGroupCovarianceMatrix().
Referenced by DFA_P_Value(), DiscriminantFunctionAnalysis(), DiscriminantFunctionAnalysis(), and StepwiseDiscriminantFunctionAnalysis().
|
private |
Computes pooled within-group covariance matrix.
Calculates the weighted average of covariance matrices within each source group. Represents the "error" or within-group scatter in discriminant analysis.
Formula: S_W = Σ[(n_i - 1) × Σ_i] / Σ(n_i - 1)
Definition at line 4935 of file sourcesinkdata.cpp.
References GetElementNames(), and target_group_.
Referenced by DFA_eigvector(), and WilksLambda().
| bool SourceSinkData::WriteDataToFile | ( | QFile * | file | ) |
Writes elemental profile data to a text file.
Outputs all sample groups and their elemental profiles in tab-delimited text format for documentation or debugging purposes.
| file | Pointer to an open QFile for writing |
Definition at line 2856 of file sourcesinkdata.cpp.
Referenced by WriteToFile().
| bool SourceSinkData::WriteToFile | ( | QFile * | file | ) |
Writes dataset to a text file.
Public interface for writing elemental profile data to a file.
| file | Pointer to an open QFile for writing |
Definition at line 2873 of file sourcesinkdata.cpp.
References WriteDataToFile().
Definition at line 1892 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), Clear(), ConstituentOrder(), CreateCorrectedDataset(), ElementsToBeUsedInCMB(), operator=(), and PopulateConstituentOrders().
|
private |
Definition at line 1902 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), GradientUpdate(), and operator=().
|
private |
Definition at line 1872 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), AssignAllDistributions(), Clear(), CreateCorrectedDataset(), GetElementDistribution(), GetFittedDistribution(), operator=(), and PopulateElementDistributions().
|
private |
Definition at line 1871 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), AssignAllDistributions(), BuildSourceMeanMatrix_Isotopes(), Clear(), CountElements(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), CreateTracerDataset(), DiscriminantFunctionAnalysis(), DiscriminantFunctionAnalysis(), ElementInformationToJsonObject(), ElementsToBeUsedInCMB(), ExtractChemicalElements(), ExtractSpecificElements(), FirstOMConstituent(), FirstSizeConstituent(), GetElementInformation(), GetElementInformation(), IncludeExcludeAllElements(), IncludeExcludeElementsBasedOn(), InitializeParametersAndObservations(), IsotopesToBeUsedInCMB(), IsotopesWithUnusableBaseElement(), ObservedDataforSelectedSample_Isotope(), operator=(), PerformRegressionVsOMAndSize(), PopulateConstituentOrders(), PopulateElementInformation(), PredictTarget_Isotope_delta(), RandomlyEliminateSourceSamples(), ReadElementInformationfromJsonObject(), and ReplaceSourceAsTarget().
Definition at line 1893 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), BuildSourceMeanMatrix(), Clear(), CreateCorrectedDataset(), ElementOrder(), GetCalculatedElementMeans(), GetCalculatedElementMu(), GetCalculatedElementSigma(), GetEstimatedElementMean(), GetEstimatedElementMu(), GetEstimatedElementSigma(), IsotopeBaseMean(), LogLikelihoodSourceElementalDistributions(), MeanElementalContent(), NegativeValueCheck(), ObservedDataforSelectedSample(), operator=(), PopulateConstituentOrders(), PredictTarget(), PredictTarget_Isotope_delta(), ResidualJacobian(), ResidualJacobian_arma(), ResidualJacobian_softmax(), and SetParameterValue().
|
private |
Definition at line 1906 of file sourcesinkdata.h.
Referenced by Gradient().
|
private |
Definition at line 1904 of file sourcesinkdata.h.
Referenced by LogLikelihoodModelvsMeasured(), and SetParameterValue().
|
private |
Definition at line 1905 of file sourcesinkdata.h.
Referenced by LogLikelihoodModelvsMeasured_Isotope(), and SetParameterValue().
Definition at line 1894 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), BuildSourceMeanMatrix_Isotopes(), Clear(), CreateCorrectedDataset(), IsotopeOrder(), IsotopesToBeUsedInCMB(), ObservedDataforSelectedSample_Isotope(), ObservedDataforSelectedSample_Isotope_delta(), operator=(), PopulateConstituentOrders(), PredictTarget_Isotope_delta(), ResidualJacobian(), ResidualJacobian_arma(), ResidualJacobian_softmax(), and SetParameterValue().
|
private |
See LoadError().
Definition at line 1903 of file sourcesinkdata.h.
Referenced by LoadError(), and ReadFromFile().
|
private |
Definition at line 1875 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), Clear(), CreateCorrectedDataset(), ElementsToBeUsedInCMB(), GetElementDistributionSigmaParameter(), InitializeParametersAndObservations(), operator=(), PopulateConstituentOrders(), and SetParameterValue().
|
private |
Definition at line 1876 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), Clear(), CreateCorrectedDataset(), InitializeParametersAndObservations(), IsotopesToBeUsedInCMB(), operator=(), PredictTarget_Isotope_delta(), and SetParameterValue().
|
private |
Definition at line 1877 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), BootStrap(), BootStrap(), BuildSourceMeanMatrix(), BuildSourceMeanMatrix_Isotopes(), Clear(), CreateCorrectedDataset(), DFA_P_Value(), GetContributionVector(), GetContributionVectorSoftmax(), GetElementDistributionMuParameter(), GetElementDistributionSigmaParameter(), InitializeParametersAndObservations(), LM_Batch(), LogLikelihoodSourceElementalDistributions(), MCMC_Batch(), operator=(), PopulateElementInformation(), PredictTarget_Isotope_delta(), SetParameterValue(), and VerifySource().
|
private |
Definition at line 1880 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), Clear(), CreateCorrectedDataset(), InitializeParametersAndObservations(), observation(), ObservationsCount(), and operator=().
|
private |
Definition at line 1899 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), ExtractChemicalElements(), OMandSizeConstituents(), operator=(), PerformRegressionVsOMAndSize(), RandomlyEliminateSourceSamples(), ReplaceSourceAsTarget(), SetOMandSizeConstituents(), and SetOMandSizeConstituents().
|
private |
Definition at line 1911 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), GetOptions(), operator=(), OptionsToJsonObject(), and ReadOptionsfromJsonObject().
|
private |
Definition at line 1884 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), Clear(), CreateCorrectedDataset(), GetOutputPath(), operator=(), and SetOutputPath().
|
private |
Definition at line 1898 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), CreateCorrectedDataset(), GetObjectiveFunctionValue(), operator=(), ParameterEstimationMode(), SetParameterEstimationMode(), and SetParameterValue().
Definition at line 1881 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), Clear(), GetElementDistributionMuParameter(), GetElementDistributionSigmaParameter(), GetParameterValue(), GetParameterValue(), InitializeParametersAndObservations(), operator=(), parameter(), parameter(), Parameters(), ParametersCount(), and SetParameterValue().
|
private |
Definition at line 1901 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), ExtractChemicalElements(), operator=(), and PerformRegressionVsOMAndSize().
|
private |
Definition at line 1909 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), BootStrap(), BootStrap(), LM_Batch(), SetProgressReporter(), SolveLevenberg_Marquardt(), StepwiseDiscriminantFunctionAnalysis(), StepwiseDiscriminantFunctionAnalysis(), StepwiseDiscriminantFunctionAnalysis(), and VerifySource().
Definition at line 1891 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), BootStrap(), BootStrap(), BuildSourceMeanMatrix(), BuildSourceMeanMatrix_Isotopes(), Clear(), CreateCorrectedDataset(), GetContributionVector(), GetContributionVectorSoftmax(), GetSourceOrder(), InitializeContributionsRandomly(), InitializeContributionsRandomlySoftmax(), InitializeParametersAndObservations(), LM_Batch(), LogLikelihoodSourceElementalDistributions(), MCMC_Batch(), operator=(), PredictTarget_Isotope_delta(), SamplesetsOrder(), SetContribution(), SetContributionSoftmax(), SetParameterValue(), and VerifySource().
|
private |
Definition at line 1888 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), Clear(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), GetObservedElementalProfile(), GetObservedElementalProfile_Isotope(), InitializeParametersAndObservations(), LogLikelihoodModelvsMeasured(), LogLikelihoodModelvsMeasured_Isotope(), ObservedDataforSelectedSample(), ObservedDataforSelectedSample_Isotope(), ObservedDataforSelectedSample_Isotope_delta(), operator=(), ResidualVector(), ResidualVector_arma(), SelectedTargetSample(), and SetSelectedTargetSample().
Definition at line 1895 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), Clear(), CreateCorrectedDataset(), operator=(), PopulateConstituentOrders(), and SizeOMOrder().
|
private |
Definition at line 1900 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), ExtractChemicalElements(), OMandSizeConstituents(), operator=(), PerformRegressionVsOMAndSize(), RandomlyEliminateSourceSamples(), ReplaceSourceAsTarget(), SetOMandSizeConstituents(), and SetOMandSizeConstituents().
|
private |
Definition at line 1887 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), AllSourceSampleNames(), ANOVA(), BetweenGroupCovarianceMatrix(), BoxCoxTransformed(), BracketTest(), BracketTest(), Clear(), CreateCorrectedAndFilteredDataset(), CreateCorrectedDataset(), DFA_P_Value(), DFA_Projected(), DFAConfusionMatrix(), DifferentiationPower(), DifferentiationPower_P_value(), DifferentiationPower_Percentage(), DiscriminantFunctionAnalysis(), ExtractChemicalElements(), ExtractConcentrationSet(), ExtractSpecificElements(), GetCalculatedElementMeans(), GetCalculatedElementMu(), GetCalculatedElementSigma(), GetEstimatedElementMean(), GetEstimatedElementMu(), GetEstimatedElementSigma(), GetSourceProfiles(), GetTargetGroup(), GrandMean(), InitializeParametersAndObservations(), LM_Batch(), LumpAllProfileSets(), MCMC_Batch(), MeanElementalContent(), NegativeValueCheck(), operator=(), OutlierAnalysisForAll(), PopulateElementInformation(), RandomlyEliminateSourceSamples(), ReadFromFile(), ReplaceSourceAsTarget(), SetSelectedTargetSample(), SetTargetGroup(), SourceGroupNames(), TheRest(), TotalNumberofSourceSamples(), TotalScatterMatrix(), VerifySource(), and WithinGroupCovarianceMatrix().
|
private |
Definition at line 1910 of file sourcesinkdata.h.
Referenced by SourceSinkData(), SourceSinkData(), AddtoToolsUsed(), Clear(), operator=(), ToolsUsed(), and ToolsUsedToJsonObject().