/* * MultivariateNormalGibbsOperator.java * * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard * * This file is part of BEAST. * See the NOTICE file distributed with this work for additional * information regarding copyright ownership and licensing. * * BEAST 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 2 * of the License, or (at your option) any later version. * * BEAST is distributed in 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. * * You should have received a copy of the GNU Lesser General Public * License along with BEAST; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA */ package dr.inference.operators; import dr.inference.distribution.MultivariateDistributionLikelihood; import dr.inference.distribution.MultivariateNormalDistributionModel; import dr.inference.model.MatrixParameter; import dr.inference.model.Parameter; import dr.math.distributions.MultivariateNormalDistribution; import dr.math.matrixAlgebra.IllegalDimension; import dr.math.matrixAlgebra.Matrix; import dr.math.matrixAlgebra.Vector; import dr.util.Attribute; import java.util.List; /** @author Max Tolkoff */ public class MultivariateNormalGibbsOperator extends SimpleMCMCOperator implements GibbsOperator { private Matrix priorPrecision; private Vector priorMean; private MatrixParameter likelihoodPrecision; private Parameter likelihoodMean; private MultivariateDistributionLikelihood likelihood; private int dim; public static final String MVN_GIBBS="multivariateNormalGibbsOperator"; public MultivariateNormalGibbsOperator(MultivariateDistributionLikelihood likelihood, MultivariateDistributionLikelihood prior, Double weight) throws IllegalDimension { MultivariateNormalDistribution tempPrior=(MultivariateNormalDistribution) prior.getDistribution(); this.priorMean=new Vector(tempPrior.getMean()); this.priorPrecision=new Matrix(tempPrior.getScaleMatrix()); MultivariateNormalDistributionModel tempLikelihood=(MultivariateNormalDistributionModel) likelihood.getDistribution(); this.likelihoodMean=tempLikelihood.getMeanParameter(); this.likelihoodPrecision=tempLikelihood.getPrecisionMatrixParameter(); this.likelihood=likelihood; this.dim=likelihoodMean.getValues().length; // if(dataTemp.contains(MatrixParameter.class)) // {System.err.print("Well, at least you know it's there...\n");} // else{System.err.print("Nope, you screwed up\n");} setWeight(weight); } private void setParameterValue(Parameter set, double[] value){ set.setDimension(value.length); for(int i=0; i> dataList = likelihood.getDataList(); for(Attribute d: dataList){ for(int i=0; i