Search in sources :

Example 1 with CorrelationSymmetricMatrix

use of dr.inference.model.CorrelationSymmetricMatrix in project beast-mcmc by beast-dev.

the class CorrelationSymmetricMatrixTest method getMatrix.

private CorrelationSymmetricMatrix getMatrix(CorrelationSymmetricMatrix.Type type) {
    Parameter diagonals = new Parameter.Default(new double[] { 1.0, 2.0, 3.0, 4.0 });
    Parameter offDiagonals = new Parameter.Default(new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 });
    return new CorrelationSymmetricMatrix(diagonals, offDiagonals, type);
}
Also used : Parameter(dr.inference.model.Parameter) CorrelationSymmetricMatrix(dr.inference.model.CorrelationSymmetricMatrix)

Example 2 with CorrelationSymmetricMatrix

use of dr.inference.model.CorrelationSymmetricMatrix in project beast-mcmc by beast-dev.

the class CorrelationSymmetricMatrixTest method testGetParameterValue.

public void testGetParameterValue() {
    CorrelationSymmetricMatrix matrix = getMatrix(CorrelationSymmetricMatrix.Type.AS_CORRELATION);
    double value = matrix.getParameterValue(0, 0);
    assertEquals(value, 1.0);
    double top = matrix.getParameterValue(2, 1);
    double bottom = matrix.getParameterValue(1, 2);
    assertEquals(top, bottom);
    double test = 4.0 * Math.sqrt(2 * 3);
    assertEquals(top, test);
}
Also used : CorrelationSymmetricMatrix(dr.inference.model.CorrelationSymmetricMatrix)

Example 3 with CorrelationSymmetricMatrix

use of dr.inference.model.CorrelationSymmetricMatrix in project beast-mcmc by beast-dev.

the class CorrelationSymmetricMatrixTest method testGetParameterAsMatrix.

public void testGetParameterAsMatrix() {
    CorrelationSymmetricMatrix matrix = getMatrix(CorrelationSymmetricMatrix.Type.AS_IS);
    double[][] M = matrix.getParameterAsMatrix();
    System.out.println(new Matrix(M));
    double sum = 0.0;
    for (double x : M[0]) {
        sum += x;
    }
    assertEquals(sum, 7.0);
}
Also used : CorrelationSymmetricMatrix(dr.inference.model.CorrelationSymmetricMatrix) Matrix(dr.math.matrixAlgebra.Matrix) CorrelationSymmetricMatrix(dr.inference.model.CorrelationSymmetricMatrix)

Example 4 with CorrelationSymmetricMatrix

use of dr.inference.model.CorrelationSymmetricMatrix in project beast-mcmc by beast-dev.

the class CorrelationSymmetricMatrixTest method testGetAttributeValue.

public void testGetAttributeValue() {
    CorrelationSymmetricMatrix matrix = getMatrix(CorrelationSymmetricMatrix.Type.AS_CORRELATION);
    double[] values = matrix.getAttributeValue();
    assertEquals(values.length, matrix.getRowDimension() * matrix.getColumnDimension());
}
Also used : CorrelationSymmetricMatrix(dr.inference.model.CorrelationSymmetricMatrix)

Example 5 with CorrelationSymmetricMatrix

use of dr.inference.model.CorrelationSymmetricMatrix in project beast-mcmc by beast-dev.

the class CorrelationSymmetricMatrixParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Parameter diagonals = (Parameter) xo.getElementFirstChild(DIAGONAL);
    Parameter offDiagonals = (Parameter) xo.getElementFirstChild(OFF_DIAGONAL);
    if (offDiagonals.getDimension() != (diagonals.getDimension() * (diagonals.getDimension() - 1) / 2)) {
        throw new XMLParseException("Invalid parameter dimensions in `" + xo.getId() + "'");
    }
    return new CorrelationSymmetricMatrix(diagonals, offDiagonals);
}
Also used : Parameter(dr.inference.model.Parameter) CorrelationSymmetricMatrix(dr.inference.model.CorrelationSymmetricMatrix)

Aggregations

CorrelationSymmetricMatrix (dr.inference.model.CorrelationSymmetricMatrix)5 Parameter (dr.inference.model.Parameter)2 Matrix (dr.math.matrixAlgebra.Matrix)1