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." ) ; } //http://orms.pef.czu.cz/text/game-theory/DecisionTheory.html AssociativeArray optionAverages = new AssociativeArray ( ) ; int numberOfEvents = payoffMatrix . size ( ) ; for ( Map . Entry < Object , AssociativeArray > entry : payoffMatrix . entrySet ( ) ) { //Object event = entry.getKey(); 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 ; }
Returns the best option and the payoff under laplace strategy