Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* This file is part of the repicea library.
*
* Copyright (C) 2009-2022 Mathieu Fortin for Rouge-Epicea
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed with the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* Please see the license at http://www.gnu.org/copyleft/lesser.html.
*/
package repicea.stats.model.glm.measerr;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.logging.Level;
import repicea.math.Matrix;
import repicea.math.SymmetricMatrix;
import repicea.stats.data.DataSet;
import repicea.stats.estimates.Estimate;
import repicea.stats.estimates.GaussianEstimate;
import repicea.stats.estimates.MonteCarloEstimate;
import repicea.stats.estimators.AbstractEstimator;
import repicea.stats.estimators.AbstractEstimator.EstimatorCompatibleModel;
import repicea.stats.model.glm.measerr.SIMEXModel.InternalGLM;
import repicea.util.REpiceaLogManager;
class SIMEXEstimator extends AbstractEstimator {
public static String LOGGER_NAME = "SIMEXEstimator";
class InternalWorker extends Thread {
final InternalGLM model;
final Map estimateMap;
final Map varianceMap;
EstimatorException estimatorException;
InternalWorker(int id, InternalGLM model, Map estimateMap, Map varianceMap) {
super("InternalWorker no " + id);
this.model = model;
this.estimateMap = estimateMap;
this.varianceMap = varianceMap;
start();
}
@Override
public void run() {
try {
while (!this.isInterrupted()) {
Object o = queue.takeFirst();
if (o.equals(finalToken)) {
break;
} else {
double factor = (Double) o;
model.getCompleteLogLikelihood().generateMeasurementError(factor);
if (refParms != null) {
model.setParameters(refParms);
}
model.doEstimation();
if (model.getEstimator().isConvergenceAchieved()) {
addRealizationToEstimate(estimateMap, varianceMap, factor, model);
if (factor == 0d) {
refParms = model.getEstimator().getParameterEstimates().getMean();
}
} else {
queue.addFirst(factor); // else we put the factor back into the map to make sure that this realization
// is going to converge at some point MF20221004
}
}
}
} catch (Exception e) {
estimatorException = new EstimatorException(e.getMessage());
SIMEXEstimator.this.interruptTasks();
}
}
}
private final Object finalToken = new Object();
private final BlockingDeque