...
This commit is contained in:
@@ -412,7 +412,13 @@ protected:
|
||||
tukey_weight = r.array() * r.array();
|
||||
};
|
||||
|
||||
auto gastwirth_est = [](Eigen::VectorXd const& resi) {
|
||||
auto gastwirth_est = [](Eigen::VectorXd const& r) {
|
||||
// auto gastwirth_est = [](Eigen::VectorXd const& resi) {
|
||||
auto resi = r;
|
||||
std::nth_element(resi.begin(), resi.begin() + resi.size() / 2, resi.end());
|
||||
double md = resi(resi.size() / 2);
|
||||
resi = resi.array() - md;
|
||||
|
||||
// Gastwirth’s estimation: 0.3*Q(1/3) + 0.4*Q(1/2) + 0.3*Q(2/3)
|
||||
|
||||
Eigen::ArrayXd arr = resi.cwiseAbs();
|
||||
@@ -434,6 +440,7 @@ protected:
|
||||
|
||||
Eigen::MatrixXd X(2 * numberOfPoints(), n_coeffs);
|
||||
Eigen::VectorXd y(2 * numberOfPoints()), beta = Eigen::VectorXd::Zero(n_coeffs), new_beta(n_coeffs);
|
||||
Eigen::VectorXd model;
|
||||
|
||||
Eigen::RowVectorXd row(n_coeffs);
|
||||
double tgY, sinY, cosY, rcosY, cosX, sinX, cosPhi = std::cos(pcm_data.siteLatitude),
|
||||
@@ -490,6 +497,16 @@ protected:
|
||||
|
||||
double scale;
|
||||
|
||||
Eigen::MatrixXd WX;
|
||||
Eigen::VectorXd Wy;
|
||||
|
||||
// initial parameters estimation (least squares)
|
||||
beta = X.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(y);
|
||||
model = X * beta;
|
||||
resi = y - model;
|
||||
|
||||
resi = y;
|
||||
|
||||
for (result.final_iter = 1; result.final_iter <= comp_params.max_iter; ++result.final_iter) {
|
||||
scale = gastwirth_est(resi);
|
||||
|
||||
@@ -501,13 +518,18 @@ protected:
|
||||
|
||||
new_beta = XtWX.ldlt().solve(XtWy);
|
||||
|
||||
// WX = weights.asDiagonal() * X;
|
||||
// Wy = weights.asDiagonal() * y;
|
||||
// new_beta = WX.bdcSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(Wy);
|
||||
|
||||
if ((new_beta - beta).norm() < comp_params.tolerance) {
|
||||
break;
|
||||
}
|
||||
|
||||
beta = new_beta;
|
||||
|
||||
resi = y - X * beta;
|
||||
model = X * beta;
|
||||
resi = y - model;
|
||||
}
|
||||
|
||||
pcm_data.geomCoefficients.zeroPointX = new_beta(0);
|
||||
@@ -522,7 +544,6 @@ protected:
|
||||
pcm_data.geomCoefficients.forkFlexure = new_beta(8);
|
||||
}
|
||||
|
||||
Eigen::VectorXd model = X * new_beta;
|
||||
result.model_colon = {model.begin(), model.begin() + numberOfPoints()};
|
||||
result.model_colat = {model.begin() + numberOfPoints(), model.end()};
|
||||
result.colon_res.resize(numberOfPoints());
|
||||
|
||||
Reference in New Issue
Block a user