A Bayesian-Inspired Framework for Parameter Estimation and Error Quantification ()
1. Introduction
Observations, phenomena, and processes are often quantitatively characterized by analyzing experimental or empirical data. One of the most widely used methods for fitting model parameters to data sets is the least squares method. However, this method has several limitations: it is sensitive to outliers—often caused by measurement errors—and assumes known weighting of the data points and uncorrelated residuals, which may not hold in practice.
In addition, unknown systematic errors may occur due to inadequate models; compare [1]. In this context, [2] famously stated that “All models are wrong, but some are useful,” highlighting the inevitable presence of unknown systematic errors and outliers in both models and measurement data. To address these challenges, various strategies have been developed:
Robust regression techniques aim at down-weighting, as found in [3]-[6] or eliminating outliers, see [7], while outlier detection methods, described in [8], seek to identify and correct such anomalies in the data.
Iteratively reweighted least squares (IRLS) is introduced in [9] and in the textbook from [10], and is now established as a standard method for regression models. This approach is particularly useful when the data weights are not known in advance but can be estimated from the residuals of a previous fit.
By means of a Bayesian framework prior knowledge can be introduced into the regression analysis; details can be found in [11].
The above mentioned approaches (IRLS, prior knowledge from Bayesian framework) are further developed in the present work to address unknown uncertainties and varying weighting factors during regression analysis. In our method, the weighting factors are represented by functions with adjustable parameters, and the model parameters are estimated simultaneously. The underlying theory is presented in the following section.
2. Theory
2.1. A Comparison of Frequentist and Bayesian Paradigms
In the field of data analysis, measurements are primarily evaluated using two distinct schools of thought: frequentist or classical statistics and Bayesian statistics. This section provides a comparative overview of these two fundamental approaches.
According to [12], classical statistics is characterized by the following principles:
At a given point
, frequent measurements
are carried out where
denotes the measurement series. Thereby, a probability distribution (e.g., a Gaussian distribution) for
can be estimated for each measurement point
.
In classical statistics, a distinction is made between the true value of the model parameter and its estimated value obtained from sample data. While the true model parameter is treated as an a-priori unknown fixed constant, the estimator (the specific value derived from regression analysis) is a random variable with a distribution induced by the sampling process. Consequently, a confidence interval is determined based on the sampling distribution of this estimator, providing a plausible range for the true parameter.
A central method in classical regression analysis is the determination of a curve
that approximates
measurement points
. Measurement uncertainties are considered by including weighting factors in the sum of squared residuals
:
(1)
where
is the weighting factor of the
-th measurement point and
are the parameters of the model function
. The fitting parameters are obtained by minimizing
, which represents the weighted classical least squares method. In contrast, Bayesian statistics interprets probabilities as measures of belief or uncertainty. In general, the probability
is the conditional probability of event
given that event
is true. Prior probabilities
for an event
express beliefs before observing data. This prior probability is updated by the likelihood
via Bayes’ theorem (see, e.g., [12] and [13]) and yields the posterior probability
, which represents updated beliefs after observing event
. The posterior probability is normalized by the evidence
(or marginal likelihood):
(2)
In this work, Bayes’ theorem is used to infer the model parameters
by determining the conditional probability
, where
are the observed data and
denotes the underlying model hypothesis. In classical statistics, model parameters are fixed, but unknown constants. In Bayesian statistics, in contrast, model parameters are described by probability density functions rather than being treated as fixed constants. Thus, the model curve is known within a credible interval. Whereas in classical statistics measurements are frequently repeated to determine the uncertainty of each measurement point, the measurement is assumed to be certain in conventional Bayesian statistics.
This paper will investigate the regression problem through a novel Bayesian approach employing a global minimization strategy. We find a measure for unknown systematic errors, regardless of whether they originate from the experiment or the model, by using the residuals in a Bayesian framework. This analysis will reveal that this method leads to a fundamental extension of the classical least-squares sum by introducing an additional significant term.
2.2. Determining Weighting Factors
The determination of weighting factors is a central topic in this study, as introduced above. In a common standard approach, often employed when repeated
measurements are available for each
, the weighting factor
for the data point
is determined as follows: Repeated measurements
produce a number of
values
at
, the sample variance
of these repeated measurements at
is calculated; the reciprocal of this variance is then used as
the weighting factor:
, see [10].
In the frequentist statistical approach it is implicitly assumed that the model is structurally perfect. The residuals, representing the deviations between the model and the measurements are solely dependent on the fluctuations in the data points, but do not account for systematic errors. In practice, it is often the case that different models describe the measurement data with varying degrees of accuracy, and it is usually not known a priori which model will be the most accurate. In addition to possibly occurring fluctuations in data points, unknown systematic errors may be caused by a too simple model, see [1]. These unknown systematic errors lead to significantly larger residuals than the variability of the data points alone would suggest. These considerations motivate us to assign lower weights to regions with higher residuals.
However, a more advanced regression analysis with observation weights not known a priori is known as iteratively reweighted least squares (IRLS) method [9]. The weights are iteratively optimized in each step. The regression is successful when the resulting parameter estimates do not differ within a certain threshold from those obtained in the previous iteration. This involves using the residuals from the weighted fit to re-estimate the variance (or standard deviation) function and update the weights accordingly. In practice, one or two iterations are usually sufficient to achieve stable estimates of the parameters. The IRLS method is a robust regression technique, but it has some limitations:
The method can be prone to convergency problems and may end up at a local minimum instead of the global minimum.
Since IRLS is primarily an optimization method, it also lacks a comprehensive statistical framework for determining the probability distributions of uncertainty parameters.
In order to resolve these limitations, we decided to develop a Bayesian informed extended least squares method. The weighting factors are modeled as functions dependent on a set of weight parameters
, which are optimized simultaneously with the primary model parameters
. This comes at the cost that the dimensionality of the optimization space is increased by the length of the vector
of the weight parameters. In contrast to the iteratively reweighted least squares (IRLS) method, our proposed procedure is straightforward and non-iterative. More details are provided in the following section.
2.3. The Extended Least Squares Method
The extended least squares method is derived by applying Bayes’ theorem [14] to jointly infer the model and the weight parameters. The parameter set
is composed of the primary model parameters
and the weight parameters
. The prior probability distribution
contains prior knowledge of the parameter set
, where
denotes the hypothesis space. Upon availability of a new measurement series, denoted as
, the prior distribution is updated via the likelihood function
. This likelihood quantifies how well the parameter vector
explains the observed data, i.e., it reflects the goodness of fit between model and measurements. The joint probability of the data and parameters is given by the product of the likelihood function and the prior distribution, i.e.
. The evidence
serves as a normalizing constant for this joint probability. The posterior probability distribution
is then obtained as:
(3)
which can be rewritten in logarithmic form:
(4)
Since the hypothesis space
of the model is assumed to be constant, the distribution
, named evidence, also remains constant, see also [12]. In the case of a uniform prior distribution, a so-called “flat” prior, compare [12], where all admissible parameter values are considered equally probable, the prior simplifies to:
. Under this assumption, Equation (3) reduces to Equation (5), implying that the posterior distribution
is proportional to the likelihood function
[15],
(5)
Assuming a flat prior distribution, where all parameter values have equal prior probabilities, we can directly compare the likelihood of different parameter sets with the observed data. This allows us to focus on evaluating the goodness-of-fit and determining the most plausible parameter values based on the given data,
(6)
In the following step, a model function
is defined which describes the data set
. Then, we define the likelihood as a Gaussian function
, where
,
and
are the measured
-value, the calculated regression value and the standard deviation at measurement point
, respectively:
(7)
The standard deviations
are a priori unknowns and must be replaced by the estimated values during regression. The calculated value at at each measurement point
is denoted as . In particular, we express the likelihood function at each measurement point
:
(8)
The regression values are computed from the model function at the positions
and depend on the primary model parameters
.
In this approximation, we assume that all individual observations are independent. This means that the likelihood function
for the full dataset
can be written as a product of the individual likelihoods
at each point:
(9)
In classical least squares regression, the
values usually reflect only the measurement uncertainty at each
, determined from repeated measurements in a frequentist framework. However, in this work, we take a different approach: we let
account not only for the measurement uncertainty of data point
, but also for discrepancies caused by an imperfect model. These additional contributions are derived from the residuals
.
The estimated standard deviations
are directly related to the classical weighting factors
through:
(10)
The weighting factor
, as employed in our framework, aligns with its definition in the classical least squares method, as discussed by Wolberg (2006) [16]. However, in our approach the standard deviations of the measurement points
are a priori uncertain.
Instead of assigning an individual standard deviation
to each measurement point
, we introduce a single function that depends on a reduced set of fitting parameters
. The individual variances
are thus approximated by model-based variances:
where
is the model prediction at
.
Alternatively, the calculated value can be replaced by the measured value
, yielding:
The parameters
are treated as random variables within the hypothesis space
. Here,
denotes the parameters of the model function, while
parameterizes the function
, which describes the (unknown) standard deviation associated with each data point. Both sets of parameters are estimated simultaneously within the Bayesian framework. It is worth noting that the fitted
term absorbs both measurement noise and model misspecification. These two components are in principle not separately identifiable from a single measurement series unless external information or replicated measurements are available.
The likelihood function
(11)
is modified to account for the parameter-dependent variances. Assuming independent normally distributed residuals, it takes the form:
(12)
A direct numerical evaluation of Equation (12) is often numerically unstable. This is because the product of exponential terms can rapidly tend towards zero for large negative exponents, potentially leading to severe numerical underflow. To circumvent this, the logarithm of the likelihood function provides a more stable and computationally feasible formulation:
(13)
Inserting Equation (13) into Bayes’ theorem, Equation (4) yields the following expression for the posterior distribution:
(14)
The posterior distribution for a flat prior is obtained by setting
in Equation (14):
(15)
In order to apply our method to applications the following workflow can be used:
The model function
is described by the parameters
within the hypothesis space
.
The weights
are approximated by the function for the inverse of the model based variances
with the parameters
, which are defined in the hypothesis space
.
The prior knowledge is considered by a prior probability distribution.
The probability distributions of
and
are determined by using Equation (14).
In the subsequent section, an objective function is derived from the posterior distribution given by Equation (15). This objective function serves as the basis for parameter estimation in the proposed method. Subsequently, it is compared to the classical objective function used in conventional least squares regression.
2.4. Objective Function: Bayesian Statistics versus Classical Least
Squares Method
Rearranging Equation (14) yields:
(16)
The objective function
is defined by multiplying both sides of Equation (16) by (−2), so that this objective function becomes closer to the classical least squares objective function. The Bayesian based problem of maximizing the log-posterior distribution is converted into a problem where the objective function
is minimized.
(17)
The final, simplified expression (the third line) is the formula that is numerically minimized to obtain the Maximum A Posteriori (MAP) estimates [17] for the parameters
.
For a non-informative or (flat) prior distribution, where the prior probability density
, its logarithm
becomes zero. Therefore, the last term in the last line of Equation (17) vanishes. The simplified objective function
thus reduces to (see also Equation (5)):
(18)
This objective function is equivalent to the negative log-likelihood of the model. Therefore, minimizing
is equivalent to finding the maximum likelihood estimate, which in this case also corresponds to the maximum a posteriori (MAP) solution [18].
The model parameters
and the weight parameters
of the function
are optimized by minimizing the objective function
.
Let us recall that the objective function
from the least squares method is given by
(19)
Therefore, compared with
(Equation (19)),
(Equation (18)) contains the additional term
This term penalizes high standard deviations
by increasing the value of the objective function. It is important to note that when each
is independent of the model parameters
and
(as typically assumed in classical weighted least squares, where uncertainties are fixed based on observed data only), this sum becomes a constant additive term in
. In such a case, minimizing
and
yields the identical optimized parameters
. Thus, our Bayesian informed extended least squares algorithm simplifies to the classical least squares solution in the case of weights that do not depend on model
or the weight parameters
.
This is precisely where the advantage of our method lies: the weights may depend on the parameters
of the weight function and on the parameters
of the model function and can be determined from the simultaneous optimization of
and
.
2.5. Determination of Fit Parameter Errors—The Covariance
Matrix
To determine the uncertainties of the fit parameters [19], the objective function
can be locally approximated by a second-order Taylor series expansion around its minimum. The minimum of the objective function
, Equation (17) is denoted as
, in which all first partial derivatives are zero. The parameter vector
includes both the model parameters
and the parameters
of the function
. The second-order Taylor series expansion can thus be written as:
(20)
where
is the Hessian matrix [11] with elements given by:
(21)
Consequently, the objective function
, when approximated by a second-order Taylor expansion around its minimum (cf. Equation (20)), forms an
-dimensional paraboloid in the parameter space.
The covariance matrix
between the element
of the vector
and the element
of the vector
is given by:
(22)
The off-diagonal elements
are frequently defined as
(see e.g., [16]).
The diagonal elements
of the covariance matrix
are denoted as the variances
:
(23)
The correlation between parameters is estimated from the 2nd order Taylor term according to [16]:
(24)
The correlation coefficient
describes the degree of correlation between two parameters. The values of
are between −1 to +1. If the value is about zero, the parameters are uncorrelated. For
close to 1 the parameters are completely correlated, in case of
close to −1, the parameters are completely anti-correlated. Values of exactly ±1 imply a perfect linear relationship.
2.6. Approximation of the Posterior Probability Distribution from
the Objective Function
The relationship between the posterior probability distribution from Bayes’ theorem and the objective function of the extended least squares method follows from the first line of Equation (17):
(25)
The posterior probability distribution
can be approximated by an
-dimensional Gaussian function. This is achieved by approximating the objective function
by a second-order Taylor series expansion.
(26)
and
(27)
The corresponding probability density function
in Equation (27) is represented by an
-dimensional Gaussian function. It is clear that the Gaussian function can only approximate the solution, since the probability distributions of variances
follow a scaled
-distribution (a special case of the Γ-distribution) and thus deviate from the Gaussian shape.
3. Results and Discussion
In this section, the probability densities of the parameters
are calculated based on the theory described above for several applications. To ensure full transparency and reproducibility, detailed calculations are provided for each example in the accompanying GitHub repository [20].
3.1. Example 1: Determination of the Standard Deviation
In this first example, we test the algorithm on a synthetic dataset of eight elements, indexed
. The dataset and detailed calculations are provided in the accompanying GitHub repository [20]. The noise-free values,
, are set to a constant mean of
. A normally distributed noise component,
, is then superimposed using a random number generator, yielding the “experimental” data
:
(28)
The true standard deviation of this noise is set to
for all data points. Consequently, the observed data
are drawn from a normal distribution
. The generated data are presented in Figure 1.
Figure 1. Synthetic data
with superimposed artificial noise (
). The green crosses represent the noise-free (true) values,
. The arrows illustrate the magnitude and sign of the residuals
.
Given the dataset depicted in Figure 1, it is assumed that the true (noise-free) value of each signal is
. The model function
is chosen. Since the arguments of this function always equal the constant 1, the model parameter vector
contains no adjustable parameters for this specific example (i.e., ).
The objective is to estimate the standard deviation
from the “true”, but a-priori unknown standard deviation
of the noise from the data. Within our Bayesian framework, this is achieved by determining the posterior probability distribution
for the estimated standard deviation
(cf. Equation (15)).
It is assumed that the prior distribution is the same for all
, and therefore the logarithm of the prior distribution vanishes in this function
. The probability density
is calculated for the unknown estimated standard deviation
in the hypothesis space
, with
and
:
with the evidence
as a normalization factor.
The posterior probability density
is plotted versus the parameter
as can be seen in Figure 2. The normalization constant
is computed numerically, so that the integral of the posterior probability density over all possible values of
equals 1. In this example,
.
Figure 2. Directly calculated probability density
as function of the parameter
.
The maximum of the probability density
can be found at
. This value
is the estimated standard deviation based on the Bayesian approach.
The directly calculated probability density
is now compared to the results obtained from classical statistics. The standard deviation
from classical statistics ([16]) follows from
(29)
This result
is identical to the value
obtained from the Bayesian analysis. Since in this case the average
is known and equals unity, all
degrees of freedom are maintained, and no degree of freedom is used to calculate the average. Consequently, the denominator of Equation (29) uses
instead of the typical
degrees of freedom. The inflection point on the left side of the maximum
of the probability density
curve is located at
, the inflection point on the right side of the maximum lies at
as depicted in Figure 2.
The “left error” of the estimated value
is determined to:
and its “right error” is calculated to:
. As the result of the Bayesian approach, the probability
between the two inflection points
and
(i.e. the integral over the probability density function
, blue area in Figure 2) is calculated to:
.
We approximate
by a truncated Taylor series at
as expansion point by considering the 2nd derivative, since the 1st derivative is zero at
. The resulting approximation of
is the Gaussian function depicted in Figure 3 (red curve). For comparison, the directly calculated probability density function is also shown in the figure as black curve. The probability
following from the directly calculated distribution (Figure 2) is compared to the probability
between the inflection points, in the case that the standard deviation is approximated by a Gaussian distribution (red curve in Figure 3).
Figure 3. Approximated probability density of the truncated Taylor series (red curve) in comparison with the originally calculated probability
as a function of
(black curve).
The error estimation via Bayesian statistics described above is now compared to the approximation in classical error estimation using the extended objective function, see also Equation (13):
The estimated error
of the standard deviation
is deduced from the inverse of the Hessian matrix
. In this example
is the only non-zero second derivative of the objective function and the estimated error follows as
. Comparing Gaussian
with the error
obtained from the Bayes’ treatment—for both inflection points, the left and the right one—shows that the values are rather different, however, in the same order of magnitude.
As a third error estimation, the error
of the estimated standard deviation
follows from the approximation suggested by Lane [21]:
(30)
For our example, this yields:
This estimated error
is compared to the values determined from the inflection points (
) and from the second derivative (
), highlighting the differences between these different methods of uncertainty estimation. The calculation using Maple version 18 [22] can be found in GitHub.
The classical Gaussian distribution is inherently a symmetric distribution with non-zero values in the negative
-range. However, the propability density must be zero for values of
since a negative standard deviation is not possible. This is the case for the probability density function used in our approach, which can be seen as an advantage compared to the classical usage of a Gaussian distribution.
3.2. Example 2: Determination of the Average and the Standard
Deviation
The same
values from example 1 are used as measurement points in example 2, see Figure 1. In contrast to example 1, where the model curve was known to be
, the model for this example is described by a constant but a priori unknown parameter,
. Both this value
and the standard deviation
are estimated simultaneously by analyzing the measurement points
.
The hypothesis space
is defined as
.
The posterior probability density
of the a priori unknown value and its unknown standard deviation
are determined from Equation (15):
In this example,
. The evidence
serves as a normalization factor, and its value is found to be
. The resulting probability density, which depends on both
and
, is presented in Figure 4. The calculation is done using Maple version 18 [22]. The Maple code can be found in the accompanying GitHub repository [20].
The maximum of the posterior probability density is reached at
and at a standard deviation
. These values are the maximum a posteriori (MAP) estimates for the parameters, as depicted in Figure 4.
The value
obtained using classical statistics is the sample mean:
Figure 4. Probability density
as a function of the average
and standard deviation
.
In this example, the standard deviation
from classical statistics is given by the sample standard deviation formula:
(31)
The use of
degrees of freedom in the denominator is necessary because the value of
was estimated from the data itself, using one degree of freedom.
The objective function
from Equation (18) applied to example 2 is
The Hessian matrix
of the objective function
(Equation (17)) is computed with respect to the parameters
and
:
The covariance matrix
, which is the inverse of the Hessian matrix
, is given by:
The error of the average is
; and the error of the standard deviation is
. The correlation
between the estimated average
and the estimated standard deviation
is then calculated as:
This value of
, being close to zero, indicates that no significant linear correlation exists between the two parameters.
In summary, the estimated average is
, and the standard deviation is
.
3.3. Example 3: Addressing Weighting Challenges in Polynomial
Fits (Model 1)
The regression of datasets with unknown uncertainties of the individual measurement points is a challenging problem. In our example 3, polynomial functions are used to fit data over a wide range. It is inherit in this problem that the values of the a-priori unknown weights of the data points can vary over several orders of magnitude. It illustrates how our extended least squares technique provides a robust uncertainty estimation even under conditions of strongly varying weighting factors. It becomes clear that constant weighting factors would not properly capture the regression problem.
The data set used in this third example are synthetically generated. We use the following linear model:
(32)
Here,
spans the range
with a step size of 5, resulting in
generated values. The measurement error
assumed follows a centered Gaussian distribution with a standard deviation
that deliberately depends on the expected measurement value, given by:
(33)
This choice for
intentionally introduces a heteroskedastic error structure (i.e., a variance of measurement errors that is not constant across all measurements), where uncertainties increase with the magnitude of the measured value. This is a characteristic often observed in real-world experimental data and is a crucial aspect because standard least squares methods often assume homoskedasticity (i.e., constant error variance across all measurements), which can lead to inefficient parameter estimates and unreliable uncertainty quantification when applied to such heteroskedastic data.
This generated set of
data pairs
is fitted using a linear function
, where
denotes the regression value at
:
(34)
As already mentioned a key aspect of our approach is that the parameters of the linear fit (
) and the parameters of the uncertainty model (
) are estimated simultaneously within a single optimization process. The standard deviations
of the measured data points
are modeled as a function of the fitted values
according to:
(35)
Here,
is the intercept and represents the estimated standard deviation at
. The parameter
is the slope and characterizes the linear increase of the estimated standard deviation as the absolute value of
increases. Both
and
are positive parameters, i.e.,
, which are obtained during the optimization process as described in Equation (18). The overall hypothesis space
for this fit is thus defined by:
and
. The formulations for
, Equation (34), and
, Equation (35), are denoted as model 1.
It is worth noting that the standard deviation parameter
from Equation (35) must be positive and does not go to zero. This ensures that both the weighting factors and the natural logarithm
of the standard deviation remain finite.
The parameters
(which define the models in Equations (34) and (35) are determined by minimizing the objective function
(Equation (18)), as summarized in Table 1. This function represents the negative logarithm of the joint posterior probability density of the parameters, making the minimization equivalent to finding MAP estimation. It is important to note that even though a linear regression model is used, the objective function
is nonlinear due to the simultaneous estimation of the uncertainty parameters. The estimated parameter values
,
,
, and
result from this optimization procedure, and their uncertainties are derived from the diagonal entries of the inverse Hessian matrix, Equation (23).
Table 1. Estimated parameter values and one-
uncertainties for model 1.
Parameter |
Value |
|
1.77 ± 0.50 |
|
0.468 ± 0.017 |
|
1.72 ± 0.42 |
|
0.087 ± 0.026 |
The fitted linear model (red dashed line) and the generated test data set (black dots) show good agreement, as illustrated in Figure 5.
Figure 5. The generated test dataset (black points) is compared to the fitted linear model (red dashed line) from model 1, which represents the most probable course of the data based on our analysis.
The correlations
between the model parameters are calculated by means of the covariance matrix
according to Equation (24) and are listed in Table 2.
Table 2. Correlation matrix
between model parameters
,
and the Gaussian uncertainties
,
of model 1.
|
|
|
|
|
|
1 |
−0.522 |
−0.043 |
0.031 |
|
−0.522 |
1 |
−0.068 |
−0.020 |
|
−0.043 |
−0.068 |
1 |
−0.647 |
|
0.031 |
−0.020 |
−0.647 |
1 |
The regression parameters for the intercept
and the slope
are significantly negatively correlated with each other (
), as are the uncertainty parameters
and
(
).
The uncertainty of the standard deviation curve,
is obtained by propagating the parameter uncertainties, which are derived from the inverse Hessian matrix [23]. In the Bayesian context of our analysis, this propagation provides the credible intervals for the model curve. This approach, while mathematically similar to error propagation in classical statistics, allows for a direct interpretation of the parameter uncertainties as probability distributions,
(36)
It is shown in Figure 6 that the determined residuals are consistent with the modeled standard deviation curve
, i.e. with the highest probability density for the errors (see red curves in Figure 6). The uncertainty of the highest probability density of the errors
is depicted by a red shaded regions.
Figure 6. The residuals of model 1 are plotted versus the independent variable
. The red line represents the most probable course of the modeled standard deviation
, which is the MAP estimation. The shaded red regions represent the credible interval (or
) for the standard deviation curve, illustrating its uncertainty.
The large relative uncertainty of the intercept parameter,
, combined with the strong anti-correlations between several model parameters, suggests that the four-parameter model is over-parameterized. This indicates a potential for overfitting, where the model is too complex for the given data. Consequently, while the model has a high explanatory power for the training data, this comes at the cost of a significant loss of predictive power for new, unseen data.
A simpler model with fewer optimization parameters may therefore be more appropriate. Since the uncertainty parameter
must be retained to prevent a singularity in the weighting coefficient
(Equation (10)) for
, the model’s intercept parameter,
, is the logical choice to be excluded. In example 4, we investigate the implications of this model deficiency by applying a fitting function without the constant intercept term to the same test data. This new fitting approach intentionally deviates from the created data set, introducing a known systematic error due to the model’s simplified form.
3.4. Example 4: Polynomial Fit with an Unknown Systematic Error
Due to Model Simplification (Model 2)
The effect of an unknown systematic error is examined in example 4 (model 2). For this purpose the test data from example 3 are used (black points in Equation (5)). The systematic error is caused by skipping the parameter
(see Table 3) of example 3. Thus, the following model function, Equation (37) is applied to the test data:
(37)
The Gaussian uncertainty
of the data points is estimated with the same equation as for example 3, i.e. Equation (38):
(38)
The hypothesis space
is defined as:
,
and
. The formulations for
, Equation (37), and
, Equation (38), are denoted as model 2.
The fit procedure described here results in the following values for the model parameters and their uncertainties (Table 3):
Table 3. Estimated parameter values and one-
uncertainties for model 2.
Parameter |
Value |
|
0.499 ± 0.015 |
|
2.55 ± 0.52 |
|
0.058 ± 0.027 |
The residuals are calculated as the difference of the values from model 2 with the fit parameters from Table 3 and the test data. The results are depicted in Figure 7. It is worth mentioning that the residuals are higher than those obtained in example 3 (compare Figure 6) in particular for small
-values. However, only one primary model parameter is engaged in this model (example 4), i.e. the slope
.
Figure 7. The residuals of model 1 are plotted versus
with an unknown systematic error due to model simplification and the course of the modeled standard deviation is represented by red pluses connected with a red line (the red regions represents the uncertainties
).
The residuals in Figure 7 are influenced by two components: the inherent noise of the measurement and a systematic error introduced by not considering a possible non-zero axis intercept within the model. As expected, the sum of the unweighted residual squares for model 2:
is higher than for model 1, where a value of 57.9 is obtained. Consequently, the curve of the calculated standard deviation
deviates more strongly from zero over the entire range for model 2 than for model 1, as shown in Figure 6 and Figure 7.
The comparison of model 1 and model 2 highlights a key challenge in model selection: choosing the most appropriate model. When choosing between models, a good strategy is to apply Occam’s razor, using the simplest possible model that fits the data adequately. This principle suggests that the three-parameter model 2 might be a better choice than the more complex four-parameter model 1, especially if the advantages of its simplicity, such as being less prone to overfitting, compensate for the introduced systematic error.
The correlations
between the model parameters are calculated by means of the covariance matrix
according to Equation (24) and are provided in Table 4.
Table 4. Correlation matrix
between the model parameter
and the Gaussian uncertainties
and
of model 2.
|
|
|
|
|
1 |
−0.086 |
0.036 |
|
−0.086 |
1 |
−0.681 |
|
0.036 |
−0.681 |
1 |
The regression parameter
shows no significant correlation with the uncertainty parameters
and
(
,
). This indicates that the values of
are largely independent of the uncertainty parameters. A strong negative correlation between
and
is still present, however, similar to model 1.
3.5. Example 5: Addressing the High Parameter Correlation of
Example 4 (Model 3)
The results of example 4 demonstrate that the uncertainty of the parameter
is in the same order of magnitude as the parameter itself. In addition a strong anti-correlation between
and
occurs,
. Thus, the number of fit parameters has to be further reduced. The same model function, Equation (39) as used above is again applied to the test data:
(39)
However, the Gaussian uncertainty
of the data points is now the same constant for all measuring points i.e.
(40)
The hypothesis space
is defined as:
and
.
The optimized fitting parameters are summarized in Table 5. The standard deviations
are constant for the whole measurement region, see Figure 8. Thus, the uncertainty of the standard deviation is also constant (red shaded regions in Figure 8).
Table 5. Estimated parameter values and one-
uncertainties for example 5.
Parameter |
Value |
|
0.497 ± 0.013 |
|
3.79 ± 0.42 |
The correlation coefficient
is now close to zero,
, i.e. there is no correlation between
and
(see Table 6).
Table 6. Correlation matrix
between the model parameter
and the gaussian uncertainty
of example 5.
|
|
|
|
1 |
4.61 × 10−10 |
|
4.61 × 10−10 |
1 |
The residuals and the course of the standard deviation for example 5 are plotted in Figure 8. Since both, the model function and the model of the Gaussian uncertainty are strongly simplified (the remaining parameters are
and
only), systematic errors occur. The strong simplification of the model to only two parameters (
and
) introduces systematic errors, leading to higher residuals. However, these drawbacks are acceptable as the primary objective, the reduction of parameter correlation, is successfully achieved. The result is a robust model in which the standard deviation is sufficiently described and the correlation between the parameters is negligibly small.
Figure 8. The residuals of example 5 are plotted against the independent variable
. The course of the modeled standard deviation is represented by red pluses connected with a dashed line, and the red regions represent the uncertainties
.
In classical statistics the weighting factors are calculated from a multitude of measurements. In our approach the weighting factors are estimated from the residuals. Thereby, measurement uncertainties and errors due to the arbitrary choice of the model are both taken into account.
3.6. Example 6: Microstructural Changes during the Heat
Treatment of Chromium Stainless Steels
As a final example, we demonstrate the application of our extended least squares method to a materials science problem. We examine the temperature-dependent change in dislocation density
in martensite during heating for the Böhler steel grade, N404 [24]. The dislocation density
in martensite during heat treatment is evaluated from in-situ X-ray diffraction data by means of a Rietveld method by using the Double-Voigt model [25] considering the peak broadening caused by the instrument itself and by lattice strain. The data for each heat treatment are monitored in a single in-situ experiment and each point of the dislocation density
characterized by time and temperature corresponds to a diffractogram. Details with respect to the evaluation of
can be found in [26].
Its chemical composition is provided in Table 7. To ensure full reproducibility, the complete Python implementation for model fitting is available in the accompanying GitHub repository [20].
The mechanical properties of this steel, particularly tensile strength and ductility, are strongly dependent on the dislocation density
, which is influenced by the final heat treatment. In-situ XRD measurements were conducted to investigate different heat treatments [26], from which the dislocation density
in martensite was determined, as shown in Figure 9.
Table 7. Chemical composition of the chromium stainless steel, showing mass fractions (wt%) of the main alloying elements. The remainder is iron (Fe).
Component |
C |
Si |
Mn |
Cr |
Mo |
Ni |
N |
Fe |
Mass fraction (wt%) |
0.04 |
0.40 |
0.40 |
15.4 |
0.90 |
5.30 |
0.04 |
bal. |
Figure 9. Experimentally determined and modeled dislocation density during the heating in a tempering process. Uncertainties (
) are estimated by the linear function yielding only positive values for the standard deviation.
In crystalline materials, the reduction of dislocation density during heat treatment is controlled by thermally activated mechanisms such as annihilation, which are described by Arrhenius-type behavior. As temperature increases, the mobility of dislocations rises exponentially, leading to a rapid decrease in dislocation density once a characteristic activation temperature is reached.
Such processes typically exhibit three regimes:
a low-temperature regime with negligible changes.
a transition region with a strong temperature dependence.
a high-temperature regime where the system approaches a saturated state.
The sigmoidal Boltzmann function was selected based on physical considerations of thermally activated processes governing dislocation annihilation.
The sigmoidal Boltzmann function is given by:
(41)
with
and
representing the initial and final dislocation density, respectively. The parameters
and
are the center temperature and temperature change. The slope
at the center temperature
is given by:
(42)
However, it should be noted that the underlying microstructural evolution may involve multiple mechanisms (e.g., recovery, rearrangement, and annihilation of dislocations), each characterized by different activation energies and kinetics. As a result, the actual process cannot be fully described by a single activation energy or a single rate-controlling mechanism.
The adopted sigmoidal function should therefore be interpreted as an effective, phenomenological description that captures the overall transition behavior. In particular, the parameter
can be understood as reflecting a distribution of activation energies or overlapping processes occurring over a finite temperature range.
The Boltzmann function seems to provide a physically motivated and sufficiently flexible approximation of the experimentally observed behavior.
The choice of the uncertainty function is primarily guided by statistical considerations. In particular, the residuals normalized by the standard error, i.e.,
, should be approximately Gaussian distributed with zero mean and unit variance. This requirement ensures the consistency of the underlying Gaussian likelihood assumption and avoids systematic over- or underestimation of the uncertainty.
In addition, the dislocation density must be a non-negative quantity. Therefore, the model for its uncertainty must ensure that the corresponding credible intervals do not extend into physically meaningless, negative values.
We evaluated several functions for the standard error
. A simple approach is equal weighting:
(43)
However, this function can yield unphysical, negative values for the dislocation density within the credible interval at high temperatures (e.g., 650˚C). As an alternative, we evaluated a function where the standard error is related to the square root of the dislocation density:
(44)
This approach also yielded possible negative values for
within the credible interval at high temperatures.
As a third alternative, a linear relationship between the standard error and the dislocation density was assumed. This function ensures that the credible interval for
remains positive:
(45)
where the densities
are positive within
, see Figure 9.
For this Gaussian uncertainty function
and the model parameters, the hypothesis space
is defined as:
,
,
,
,
, and
.
The model parameters, the parameters of the uncertainty function and their errors are summarized in Table 8. It should be mentioned that the uncertainty of the parameter
is in the range of the parameter itself. However, the Gaussian uncertainty function seems to be a reasonable choice as can be seen in Figure 9 by comparing the experimental data with the
lines of the Gaussian uncertainty function. The width of the red curves corresponds to the uncertainties of the Gaussian uncertainty functions
calculated from Equation (45).
Table 8. Estimated parameter values and one-
uncertainties for example 6.
Parameter |
Value |
|
(6.59 ± 0.06) 1014 |
|
(0.40 ± 0.04) 1014 |
|
543.2 ± 1.4 |
|
19.2 ± 1.3 |
|
(0.04 ± 0.05) 1014 |
|
0.078 ± 0.015 |
The errors from Table 8 are determined during the calculation of the covariance matrix
. Finally, the correlation
between the model parameters is calculated using Equation (24) from the covariance matrix
and is shown in Table 9.
Table 9. Correlation matrix
of the model and uncertainty parameters for example 6.
|
|
|
|
|
|
|
|
1.00 |
−0.06 |
−0.34 |
0.14 |
0.06 |
−0.09 |
|
−0.06 |
1.00 |
−0.10 |
−0.75 |
0.33 |
−0.31 |
|
−0.34 |
−0.10 |
1.00 |
−0.29 |
−0.13 |
0.12 |
|
0.14 |
−0.75 |
−0.29 |
1.00 |
−0.42 |
0.40 |
|
0.06 |
0.33 |
−0.13 |
−0.42 |
1.00 |
−0.92 |
|
−0.09 |
−0.31 |
0.12 |
0.40 |
−0.92 |
1.00 |
Some parameters in Table 9 exhibit notable correlations, the parameters
and
are anti-correlated with a value of −0.75, that of
and
with −0.29. In addition, the parameters of the uncertainty function
and
are also anti-correlated with a value of −0.92.
It is worth mentioning that the absolute error of
spans several orders of magnitude, ranging from low to high dislocation densities. This means that the choice of the uncertainty function requires care, and a linear function, Equation (45), seems to be appropriate in this case.
4. Conclusions
In this work, a Bayesian informed extended least squares algorithm is presented. It is possible to find an estimate for the combination of measurement uncertainty and a priori unknown systematic errors using this approach. The standard deviations of all measurement points can evolve during regression so that measurement points with large residuals are penalized.
This task is carried out by adding a term to the least squares method. In the limiting case of constant standard deviations of all measurement points, our approach transitions to the classical least squares method.
The theoretical framework presented in this work was applied to five model examples and one materials science problem, demonstrating the following key achievements:
Examples 1 and 2: A realistic non-symmetric probability density of the standard deviation and the average value follows from our extended least squares method, Figure 4.
Example 3: From a single measurement series, we obtain the course of highest probability and a realistic progression of the standard deviation, Figure 6. This statistical treatment is particularly useful when there is only one data set. In addition, experimental efforts can be reduced because of better model prediction.
Examples 4 and 5: Even in the case of inadequate models, where the model has a small number of fitting parameters, we obtain a realistic course of the standard deviation, Figure 7 and Figure 8. This optimization strategy allows for monitoring the residuals and the correlations between the parameters.
Example 6: The dislocation density
changes by several orders of magnitude during annealing of chromium stainless steel. With the presented method, realistic trends are obtained for the modeled dislocation density and its standard deviations.
The enhanced least squares method presented in this work is a powerful tool for simultaneously calculating model parameters and the standard deviations of model predictions. The method is broadly applicable to a wide range of optimization problems. It is particularly useful when dealing with limited measurement data and in cases where strong fluctuations in the weighting factors occur.
5. Outlook
The presented approach may give rise to further research and applications in various fields:
While our current approach assumes Gaussian-distributed residuals, it can be extended to handle non-Gaussian distributed residuals, such as Poisson or binomially distributed residuals.
The objective function proposed in this work allows for analytical solutions to the regression problems, as demonstrated in most of our examples. For applications involving large datasets, the method can be efficiently implemented using numerical algorithms, such as Monte Carlo methods, to address complex real-world problems.
Our approach provides a robust framework for optimizing data collection strategies. It can be utilized in experimental design to identify the most informative measurements, thereby facilitating more accurate and efficient parameter estimation.
Code and Data Availability
We have implemented the first five problem sets in [22] (examples 1 - 5) and problem set 6 is solved by a Python optimizer. The codes are publicly available on GitHub, and can be found via [20]. Using these codes, it is possible to reproduce the content of the tables and figures.
Author Contribution
Manfred Wiessner, Ernst Gamsjäger, and Benoît Loridant conceived the study and developed the software. The original draft of the manuscript was written by Manfred Wiessner, Ernst Gamsjäger, and Benoît Loridant. Martin Medebach contributed additional ideas. All authors critically reviewed the manuscript and approved the final version.