@Test public void testLaplace() { logger.info("laplace"); DataTable2D payoffMatrix = generatePayoffMatrix(); Map.Entry<Object, Object> expResult = new AbstractMap.SimpleEntry<>("A2", 475.0); Map.Entry<Object, Object> result = DecisionCriteria.laplace(payoffMatrix); assertEquals(expResult, result); }
public static Map.Entry<Object, Object> laplace(DataTable2D payoffMatrix) { if(payoffMatrix.isValid()==false) { throw new IllegalArgumentException("The payoff matrix does not have a rectangular format."); } AssociativeArray optionAverages = new AssociativeArray(); int numberOfEvents = payoffMatrix.size(); for(Map.Entry<Object, AssociativeArray> entry : payoffMatrix.entrySet()) { AssociativeArray optionList = entry.getValue(); for(Map.Entry<Object, Object> entry2 : optionList.entrySet()) { Object option = entry2.getKey(); Double payoff = TypeInference.toDouble(entry2.getValue()); Double value = optionAverages.getDouble(option); if(value==null) { value=0.0; } optionAverages.put(option, value + payoff/numberOfEvents); } } Map.Entry<Object, Object> entry = MapMethods.selectMaxKeyValue(optionAverages); return entry; }
DecisionCriteria { public static Map.Entry<Object, Object> laplace(DataTable2D payoffMatrix) { if(payoffMatrix.isValid()==false) { throw new IllegalArgumentException("The payoff matrix does not have a rectangular format."); } AssociativeArray optionAverages = new AssociativeArray(); int numberOfEvents = payoffMatrix.size(); for(Map.Entry<Object, AssociativeArray> entry : payoffMatrix.entrySet()) { AssociativeArray optionList = entry.getValue(); for(Map.Entry<Object, Object> entry2 : optionList.entrySet()) { Object option = entry2.getKey(); Double payoff = TypeInference.toDouble(entry2.getValue()); Double value = optionAverages.getDouble(option); if(value==null) { value=0.0; } optionAverages.put(option, value + payoff/numberOfEvents); } } Map.Entry<Object, Object> entry = MapMethods.selectMaxKeyValue(optionAverages); return entry; } }
DecisionCriteria { public static Map.Entry<Object, Object> laplace(DataTable2D payoffMatrix) { if(payoffMatrix.isValid()==false) { throw new IllegalArgumentException("The payoff matrix does not have a rectangular format."); } AssociativeArray optionAverages = new AssociativeArray(); int numberOfEvents = payoffMatrix.size(); for(Map.Entry<Object, AssociativeArray> entry : payoffMatrix.entrySet()) { AssociativeArray optionList = entry.getValue(); for(Map.Entry<Object, Object> entry2 : optionList.entrySet()) { Object option = entry2.getKey(); Double payoff = TypeInference.toDouble(entry2.getValue()); Double value = optionAverages.getDouble(option); if(value==null) { value=0.0; } optionAverages.put(option, value + payoff/numberOfEvents); } } Map.Entry<Object, Object> entry = MapMethods.selectMaxKeyValue(optionAverages); return entry; }  }
DecisionCriteria { public static Map.Entry<Object, Object> laplace(DataTable2D payoffMatrix) { if(payoffMatrix.isValid()==false) { throw new IllegalArgumentException("The payoff matrix does not have a rectangular format."); } AssociativeArray optionAverages = new AssociativeArray(); int numberOfEvents = payoffMatrix.size(); for(Map.Entry<Object, AssociativeArray> entry : payoffMatrix.entrySet()) { AssociativeArray optionList = entry.getValue(); for(Map.Entry<Object, Object> entry2 : optionList.entrySet()) { Object option = entry2.getKey(); Double payoff = TypeInference.toDouble(entry2.getValue()); Double value = optionAverages.getDouble(option); if(value==null) { value=0.0; } optionAverages.put(option, value + payoff/numberOfEvents); } } Map.Entry<Object, Object> entry = MapMethods.selectMaxKeyValue(optionAverages); return entry; }  static Map.Entry<Object, Object> maxMin(DataTable2D payoffMatrix); static Map.Entry<Object, Object> maxMax(DataTable2D payoffMatrix); static Map.Entry<Object, Object> savage(DataTable2D payoffMatrix); static Map.Entry<Object, Object> laplace(DataTable2D payoffMatrix); static Map.Entry<Object, Object> hurwiczAlpha(DataTable2D payoffMatrix, double alpha); static Map.Entry<Object, Object> maximumLikelihood(DataTable2D payoffMatrix, AssociativeArray eventProbabilities); static Map.Entry<Object, Object> bayes(DataTable2D payoffMatrix, AssociativeArray eventProbabilities); }
DecisionCriteria { public static Map.Entry<Object, Object> laplace(DataTable2D payoffMatrix) { if(payoffMatrix.isValid()==false) { throw new IllegalArgumentException("The payoff matrix does not have a rectangular format."); } AssociativeArray optionAverages = new AssociativeArray(); int numberOfEvents = payoffMatrix.size(); for(Map.Entry<Object, AssociativeArray> entry : payoffMatrix.entrySet()) { AssociativeArray optionList = entry.getValue(); for(Map.Entry<Object, Object> entry2 : optionList.entrySet()) { Object option = entry2.getKey(); Double payoff = TypeInference.toDouble(entry2.getValue()); Double value = optionAverages.getDouble(option); if(value==null) { value=0.0; } optionAverages.put(option, value + payoff/numberOfEvents); } } Map.Entry<Object, Object> entry = MapMethods.selectMaxKeyValue(optionAverages); return entry; }  static Map.Entry<Object, Object> maxMin(DataTable2D payoffMatrix); static Map.Entry<Object, Object> maxMax(DataTable2D payoffMatrix); static Map.Entry<Object, Object> savage(DataTable2D payoffMatrix); static Map.Entry<Object, Object> laplace(DataTable2D payoffMatrix); static Map.Entry<Object, Object> hurwiczAlpha(DataTable2D payoffMatrix, double alpha); static Map.Entry<Object, Object> maximumLikelihood(DataTable2D payoffMatrix, AssociativeArray eventProbabilities); static Map.Entry<Object, Object> bayes(DataTable2D payoffMatrix, AssociativeArray eventProbabilities);  }