Search in sources :

Example 1 with ProductChainFrequencyModel

use of dr.evomodel.substmodel.ProductChainFrequencyModel in project beast-mcmc by beast-dev.

the class ProductChainFrequencyModelTest method testFrequencyModel.

public void testFrequencyModel() {
    FrequencyModel firstPosition = new FrequencyModel(Nucleotides.INSTANCE, freq1);
    FrequencyModel secondPosition = new FrequencyModel(Nucleotides.INSTANCE, freq2);
    FrequencyModel thirdPosition = new FrequencyModel(Nucleotides.INSTANCE, freq3);
    List<FrequencyModel> freqModels = new ArrayList<FrequencyModel>(3);
    freqModels.add(firstPosition);
    freqModels.add(secondPosition);
    freqModels.add(thirdPosition);
    ProductChainFrequencyModel pcFreqModel = new ProductChainFrequencyModel("freq", freqModels);
    double[] freqs = pcFreqModel.getFrequencies();
    System.out.println("Freq.length = " + freqs.length);
    int pos1 = 2;
    int pos2 = 1;
    int pos3 = 3;
    int index = computeIndex(pos1, pos2, pos3);
    System.out.println("Entry: " + new Vector(pcFreqModel.decomposeEntry(index)));
    System.out.println("Freq = " + freqs[index]);
    System.out.println("Freq = " + computeFreq(pos1, pos2, pos3));
    assertEquals(computeFreq(pos1, pos2, pos3), freqs[index]);
}
Also used : ProductChainFrequencyModel(dr.evomodel.substmodel.ProductChainFrequencyModel) FrequencyModel(dr.evomodel.substmodel.FrequencyModel) ArrayList(java.util.ArrayList) ProductChainFrequencyModel(dr.evomodel.substmodel.ProductChainFrequencyModel) Vector(dr.math.matrixAlgebra.Vector)

Aggregations

FrequencyModel (dr.evomodel.substmodel.FrequencyModel)1 ProductChainFrequencyModel (dr.evomodel.substmodel.ProductChainFrequencyModel)1 Vector (dr.math.matrixAlgebra.Vector)1 ArrayList (java.util.ArrayList)1