Search in sources :

Example 11 with Transform

use of dr.util.Transform in project beast-mcmc by beast-dev.

the class TransformedMultivariateParameterParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    final Parameter parameter = (Parameter) xo.getChild(Parameter.class);
    Transform.MultivariableTransform transform = (Transform.MultivariableTransform) xo.getChild(Transform.MultivariableTransform.class);
    final boolean inverse = xo.getAttribute(INVERSE, false);
    TransformedMultivariateParameter transformedParameter = new TransformedMultivariateParameter(parameter, transform, inverse);
    if (xo.hasChildNamed(BOUNDS)) {
        Bounds<Double> bounds = ((Parameter) xo.getElementFirstChild(BOUNDS)).getBounds();
        transformedParameter.addBounds(bounds);
    } else {
        transformedParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, parameter.getDimension()));
    }
    return transformedParameter;
}
Also used : TransformedMultivariateParameter(dr.inference.model.TransformedMultivariateParameter) Parameter(dr.inference.model.Parameter) TransformedMultivariateParameter(dr.inference.model.TransformedMultivariateParameter) Transform(dr.util.Transform)

Example 12 with Transform

use of dr.util.Transform in project beast-mcmc by beast-dev.

the class MarkovRandomFieldMatrixParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String name = xo.getId();
    final int dim = xo.getIntegerAttribute(DIM);
    XMLObject cxo = xo.getChild(DIAGONAL);
    Parameter diagonalParameter = (Parameter) cxo.getChild(Parameter.class);
    Transform.ParsedTransform tmp = (Transform.ParsedTransform) cxo.getChild(Transform.ParsedTransform.class);
    Transform diagonalTransform = (tmp != null) ? tmp.transform : null;
    cxo = xo.getChild(OFF_DIAGONAL);
    Parameter offDiagonalParameter = (Parameter) cxo.getChild(Parameter.class);
    tmp = (Transform.ParsedTransform) cxo.getChild(Transform.ParsedTransform.class);
    Transform offDiagonalTransform = (tmp != null) ? tmp.transform : null;
    boolean asCorrelation = xo.getAttribute(AS_CORRELATION, false);
    if (diagonalParameter.getDimension() != 1 || offDiagonalParameter.getDimension() != 1) {
        throw new XMLParseException("Wrong parameter dimensions for GMRF");
    }
    cxo = xo.getChild(NUGGET);
    Parameter nuggetParameter = (Parameter) cxo.getChild(Parameter.class);
    return new MarkovRandomFieldMatrix(name, dim, diagonalParameter, offDiagonalParameter, nuggetParameter, asCorrelation, diagonalTransform, offDiagonalTransform);
}
Also used : Parameter(dr.inference.model.Parameter) Transform(dr.util.Transform) MarkovRandomFieldMatrix(dr.inference.model.MarkovRandomFieldMatrix)

Example 13 with Transform

use of dr.util.Transform in project beast-mcmc by beast-dev.

the class LoadingsTransformParser method parseXMLObject.

@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    MatrixParameterInterface matrix = (MatrixParameterInterface) xo.getChild(MatrixParameterInterface.class);
    int nRows = matrix.getRowDimension();
    int nCols = matrix.getColumnDimension();
    List<Transform> transforms = new ArrayList<Transform>();
    List<Integer> indices = null;
    if (xo.hasAttribute(INDICES)) {
        int[] tmp = xo.getIntegerArrayAttribute(INDICES);
        indices = new ArrayList<Integer>();
        for (int i : tmp) {
            indices.add(i - 1);
        }
    }
    for (int col = 0; col < nCols; ++col) {
        for (int row = 0; row < nRows; ++row) {
            if (noTransform(row, col, indices, nRows)) {
                transforms.add(Transform.NONE);
            } else {
                transforms.add(Transform.LOG);
            }
        }
    }
    return new Transform.Array(transforms, matrix);
}
Also used : MatrixParameterInterface(dr.inference.model.MatrixParameterInterface) ArrayList(java.util.ArrayList) Transform(dr.util.Transform)

Aggregations

Transform (dr.util.Transform)13 Parameter (dr.inference.model.Parameter)10 ArrayList (java.util.ArrayList)5 TreeModel (dr.evomodel.tree.TreeModel)2 GradientWrtParameterProvider (dr.inference.hmc.GradientWrtParameterProvider)2 TransformedMultivariateParameter (dr.inference.model.TransformedMultivariateParameter)2 TransformedParameter (dr.inference.model.TransformedParameter)2 AdaptationMode (dr.inference.operators.AdaptationMode)2 Util.parseTransform (dr.util.Transform.Util.parseTransform)2 DataType (dr.evolution.datatype.DataType)1 TwoStates (dr.evolution.datatype.TwoStates)1 BranchRates (dr.evolution.tree.BranchRates)1 TransformedTreeTraitProvider (dr.evolution.tree.TransformedTreeTraitProvider)1 TreeTraitProvider (dr.evolution.tree.TreeTraitProvider)1 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)1 BranchSpecificFixedEffects (dr.evomodel.branchratemodel.BranchSpecificFixedEffects)1 ContinuousBranchValueProvider (dr.evomodel.branchratemodel.ContinuousBranchValueProvider)1 CountableBranchCategoryProvider (dr.evomodel.branchratemodel.CountableBranchCategoryProvider)1 OldGMRFSkyrideLikelihood (dr.evomodel.coalescent.OldGMRFSkyrideLikelihood)1 OrderedLatentLiabilityLikelihood (dr.evomodel.continuous.OrderedLatentLiabilityLikelihood)1