| 1 |
package dr.inference.trace; |
| 2 |
|
| 3 |
import java.util.List; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
public class TraceTypeUtils { |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
public static boolean allDiscrete(TraceList[] traceLists, List<String> traceNames) { |
| 19 |
for (TraceList traceList : traceLists) { |
| 20 |
for (String traceName : traceNames) { |
| 21 |
int index = traceList.getTraceIndex(traceName); |
| 22 |
TraceDistribution td = traceList.getCorrelationStatistics(index); |
| 23 |
if (td == null) return false; |
| 24 |
if (! td.getTraceType().isDiscrete()) return false; |
| 25 |
} |
| 26 |
} |
| 27 |
return true; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
public static boolean allCategorical(TraceList[] traceLists, List<String> traceNames) { |
| 39 |
for (TraceList traceList : traceLists) { |
| 40 |
for (String traceName : traceNames) { |
| 41 |
int index = traceList.getTraceIndex(traceName); |
| 42 |
TraceDistribution td = traceList.getCorrelationStatistics(index); |
| 43 |
if (td == null) return false; |
| 44 |
if (! td.getTraceType().isCategorical()) return false; |
| 45 |
} |
| 46 |
} |
| 47 |
return true; |
| 48 |
} |
| 49 |
|
| 50 |
public static boolean anyCategorical(List<TraceList> traceLists, List<String> traceNames) { |
| 51 |
for (TraceList traceList : traceLists) { |
| 52 |
if (traceNames == null) { |
| 53 |
for (int i = 0; i < traceList.getTraceCount(); i++) { |
| 54 |
TraceDistribution td = traceList.getCorrelationStatistics(i); |
| 55 |
if (td != null && ! td.getTraceType().isCategorical()) |
| 56 |
return true; |
| 57 |
} |
| 58 |
} else { |
| 59 |
for (String traceName : traceNames) { |
| 60 |
int index = traceList.getTraceIndex(traceName); |
| 61 |
TraceDistribution td = traceList.getCorrelationStatistics(index); |
| 62 |
if (td != null && ! td.getTraceType().isCategorical()) |
| 63 |
return true; |
| 64 |
} |
| 65 |
} |
| 66 |
} |
| 67 |
return false; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
public static boolean allNumeric(TraceList[] traceLists, List<String> traceNames) { |
| 80 |
for (TraceList traceList : traceLists) { |
| 81 |
for (String traceName : traceNames) { |
| 82 |
int index = traceList.getTraceIndex(traceName); |
| 83 |
TraceDistribution td = traceList.getCorrelationStatistics(index); |
| 84 |
if (td == null) return false; |
| 85 |
if (! td.getTraceType().isNumber()) return false; |
| 86 |
} |
| 87 |
} |
| 88 |
return true; |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
public static boolean anyNumeric(List<TraceList> traceLists, List<String> traceNames) { |
| 93 |
for (TraceList traceList : traceLists) { |
| 94 |
if (traceNames == null) { |
| 95 |
for (int i = 0; i < traceList.getTraceCount(); i++) { |
| 96 |
TraceDistribution td = traceList.getCorrelationStatistics(i); |
| 97 |
if (td != null && ! td.getTraceType().isNumber()) |
| 98 |
return true; |
| 99 |
} |
| 100 |
} else { |
| 101 |
for (String traceName : traceNames) { |
| 102 |
int index = traceList.getTraceIndex(traceName); |
| 103 |
TraceDistribution td = traceList.getCorrelationStatistics(index); |
| 104 |
if (td != null && ! td.getTraceType().isNumber()) |
| 105 |
return true; |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
return false; |
| 110 |
} |
| 111 |
|
| 112 |
} |