| 1 | /* |
| 2 | * MarkovRewardCoreTest.java |
| 3 | * |
| 4 | * Copyright (c) 2002-2014 Alexei Drummond, Andrew Rambaut and Marc Suchard |
| 5 | * |
| 6 | * This file is part of BEAST. |
| 7 | * See the NOTICE file distributed with this work for additional |
| 8 | * information regarding copyright ownership and licensing. |
| 9 | * |
| 10 | * BEAST is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU Lesser General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 |
| 13 | * of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * BEAST is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU Lesser General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Lesser General Public |
| 21 | * License along with BEAST; if not, write to the |
| 22 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 23 | * Boston, MA 02110-1301 USA |
| 24 | */ |
| 25 | |
| 26 | package test.dr.math; |
| 27 | |
| 28 | import dr.inference.markovjumps.SericolaSeriesMarkovReward; |
| 29 | |
| 30 | /** |
| 31 | * Created by msuchard on 4/19/14. |
| 32 | */ |
| 33 | public class MarkovRewardCoreTest extends MathTestCase { |
| 34 | |
| 35 | private double[] Q3 = new double[]{ |
| 36 | -1, 1, 0, |
| 37 | 0.5, -1, 0.5, |
| 38 | 0, 1, -1 |
| 39 | }; |
| 40 | |
| 41 | private double[] a3 = new double[]{0, 1, 2}; |
| 42 | |
| 43 | // public void testMarkovCore3() { |
| 44 | // SericolaSeriesMarkovReward core = new SericolaSeriesMarkovReward(Q3, a3, 3); |
| 45 | // double[] W1 = core.computeCdf(1.0 - 1E-12, 1.0); |
| 46 | // double[] P1 = core.computePdf(1.0 - 1E-12, 1.0); |
| 47 | // |
| 48 | // double[] W2 = core.computeCdf(2.0 - 1E-12, 1.0); |
| 49 | // double[] W3 = core.computeCdf(100 - 1E-12, 100); |
| 50 | // } |
| 51 | |
| 52 | |
| 53 | private double[] Q2 = new double[]{-3.1, 3.1, 1.1, -1.1}; |
| 54 | private double[] a2 = new double[]{0.0, 1.0}; |
| 55 | |
| 56 | public void testMarkovCore2() { |
| 57 | SericolaSeriesMarkovReward core = new SericolaSeriesMarkovReward(Q2, a2, 2); |
| 58 | // double[] W1 = core.computeCdf(1.0 - 1E-12, 1.0); |
| 59 | // double[] P1 = core.computePdf(1.0 - 1E-12, 1.0); |
| 60 | |
| 61 | for (double x = 0.1; x < 4.0; x += 0.1) { |
| 62 | double[] P = core.computePdf(x, 4.0); |
| 63 | System.err.println(x + ", " + P[3]); |
| 64 | } |
| 65 | |
| 66 | // double[] W3 = core.computeCdf(10 - 1E-12, 10); |
| 67 | } |
| 68 | } |