| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.evomodel.coalescent; |
| 27 |
|
| 28 |
import dr.inference.model.Statistic; |
| 29 |
|
| 30 |
public class GMRFPopSizeStatistic extends Statistic.Abstract{ |
| 31 |
|
| 32 |
private GMRFSkyrideLikelihood gsl; |
| 33 |
private double[] time; |
| 34 |
|
| 35 |
public GMRFPopSizeStatistic(double[] time, GMRFSkyrideLikelihood gsl){ |
| 36 |
super("Popsize"); |
| 37 |
this.gsl = gsl; |
| 38 |
this.time = time; |
| 39 |
} |
| 40 |
|
| 41 |
public String getDimensionName(int i){ |
| 42 |
return getStatisticName() + Double.toString(time[i]); |
| 43 |
} |
| 44 |
|
| 45 |
public int getDimension() { |
| 46 |
return time.length; |
| 47 |
} |
| 48 |
|
| 49 |
public double getStatisticValue(int dim) { |
| 50 |
double[] coalescentHeights = gsl.getCoalescentIntervalHeights(); |
| 51 |
double[] popSizes = gsl.getPopSizeParameter().getParameterValues(); |
| 52 |
|
| 53 |
assert popSizes.length == coalescentHeights.length; |
| 54 |
|
| 55 |
for(int i = 0; i < coalescentHeights.length; i++){ |
| 56 |
if(time[dim] < coalescentHeights[i]){ |
| 57 |
return popSizes[i]; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
return Double.NaN; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
} |