Returns the best option and the payoff under maximumLikelihood strategy

@param payoffMatrix
@param eventProbabilities
@return
185658
public static Map.Entry<Object, Object> maximumLikelihood(DataTable2D payoffMatrix, AssociativeArray eventProbabilities) {
        if(payoffMatrix.isValid()==false) {
            throw new IllegalArgumentException("The payoff matrix does not have a rectangular format.");
        }
        
        Map.Entry<Object, Object> eventEntry = MapMethods.selectMaxKeyValue(eventProbabilities);
        
        Object mostProbableEvent = eventEntry.getKey();
        //Double mostProbableEventProbability = Dataset.toDouble(eventEntry.getValue());
        
        return MapMethods.selectMaxKeyValue(payoffMatrix.get(mostProbableEvent));
    }
225371
function(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, options)
    {
        // Can you split?
        if ((playerCards[0] == playerCards[1]) && (playerCards.length == 2) && (handCount < options.maxSplitHands))
        {
            // Split unless 4s, 5s, and 10s
            if ((playerCards[0] != 4) && (playerCards[0] != 5) && (playerCards[0] != 10))
            {
                return "split";
            }
        }

        // Double
        if (((playerCards.length == 2) && ((handCount == 1) || options.doubleAfterSplit)) &&
                ((handValue.total >= options.doubleRange[0]) && (handValue.total <= options.doubleRange[1])))
        {
            // Only on 9-11
            if ((handValue.total == 9) && (dealerCard < 7) && (dealerCard != 1))
            {
                return "double";
            }
            if ((handValue.total == 10) && (dealerCard < 10) && (dealerCard != 1))
            {
                return "double";
            }
            if (handValue.total == 11)
            {
                return "double";
            }
        }

        // Hit and stand
        if (handValue.soft)
        {
            // Hit until you get to 17, 18 against dealer 9-Ace
            if ((handValue.total < 18) || ((handValue.total == 18) && ((dealerCard >= 9) || (dealerCard == 1))))
            {
                return "hit";
            }
        }

        if (handValue.total <= 11)
        {
            return "hit";
        }
        else if (handValue.total >= 17)
        {
            return "stand";
        }
        else
        {
            // Hit on 7 or above, else stand
            return ((dealerCard >= 7) || (dealerCard == 1)) ? "hit" : "stand";
        }
    }
317879
public static List<ByteBuffer> maxComponents(List<ByteBuffer> maxSeen, Composite candidate, CellNameType comparator)
    {
        // For a cell name, no reason to look more than the clustering prefix
        // (and comparing the collection element would actually crash)
        int size = Math.min(candidate.size(), comparator.clusteringPrefixSize());

        if (maxSeen.isEmpty())
            return getComponents(candidate, size);

        // In most case maxSeen is big enough to hold the result so update it in place in those cases
        maxSeen = maybeGrow(maxSeen, size);

        for (int i = 0; i < size; i++)
            maxSeen.set(i, max(maxSeen.get(i), candidate.get(i), comparator.subtype(i)));

        return maxSeen;
    }
365400
public static double max(double[][] matrix) {
        double m = Double.NEGATIVE_INFINITY;

        for (double[] x : matrix) {
            for (double y : x) {
                if (m < y) {
                    m = y;
                }
            }
        }

        return m;
    }
732331
@Override
	protected DoubleMatrix1D getUb() {
		if (this.limitedUb == null) {
			if (super.getUb() == null) {
				this.limitedUb = F1.make(getC().size(), maxUBValue);
			} else {
				this.limitedUb = F1.make(super.getUb().size());
				for (int i = 0; i < super.getUb().size(); i++) {
					double ubi = super.getUb().getQuick(i);
					if (maxUBValue < ubi) {
						log.warn("the " + i +"-th upper bound was limited form "+ubi+" to the value of maxUBValue: " + maxUBValue);
						limitedUb.setQuick(i, maxUBValue);
					} else {
						limitedUb.setQuick(i, ubi);
					}
				}
			}
		}
		return limitedUb;
	}
221749
public static Map.Entry<Object, Object> maxMin(DataTable2D payoffMatrix) {
        if(payoffMatrix.isValid()==false) {
            throw new IllegalArgumentException("The payoff matrix does not have a rectangular format.");
        }
        AssociativeArray minPayoffs = new AssociativeArray();
        
        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 currentMinPayoffOption = minPayoffs.getDouble(option);
                if(currentMinPayoffOption==null || payoff<currentMinPayoffOption) {
                    minPayoffs.put(option, payoff);
                }
            }
        }
        
        Map.Entry<Object, Object> entry = MapMethods.selectMaxKeyValue(minPayoffs);
        return entry;
    }
785080
def pull(self, i):
        '''
        
        '''

        if self.live:
            if len(self.payouts[i]) > 0:
                return self.payouts[i].pop()
            else:
                return None
        else:
            if np.random.rand() < self.probs[i]:
                return self.payouts[i]
            else:
                return 0.0
711679
def est_payouts(self):
        '''
        
        '''

        if len(self.choices) < 1:
            print('slots: No trials run so far.')
            return None
        else:
            return self.wins/(self.pulls+0.1)
508930
def rargmax(x, eps=1e-8):
    
    idxs = np.where(abs(x - np.max(x, axis=0)) < eps)[0]
    return np.random.choice(idxs)
1346949
public static Map.Entry<Object, Object> savage(DataTable2D payoffMatrix) {
        if(payoffMatrix.isValid()==false) {
            throw new IllegalArgumentException("The payoff matrix does not have a rectangular format.");
        }
        
        //Deep clone the payoffMatrix to avoid modifying its original values
        DataTable2D regretMatrix = new DataTable2D();
        
        for(Map.Entry<Object, AssociativeArray> entry : payoffMatrix.entrySet()) {
            Object event = entry.getKey();
            AssociativeArray optionList = entry.getValue();
            double maxI = Descriptives.max(optionList.toFlatDataCollection());
            
            for(Map.Entry<Object, Object> entry2 : optionList.entrySet()) {
                Object option = entry2.getKey();
                Double payoff = TypeInference.toDouble(entry2.getValue());
                
                //regretMatrix.internalData.get(event).internalData.put(option, payoff-maxI);
                regretMatrix.put2d(event, option, payoff-maxI);
            }
        }
        
        return maxMin(regretMatrix);
    }
35113
@Override
	public RandomVariable getForward(AnalyticModel model, double fixingTime, double paymentOffset)
	{
		if(model==null) {
			throw new IllegalArgumentException(this.getName() + ": model==null");
		}
		DiscountCurveInterface referenceDiscountCurveForForwards = model.getDiscountCurve(referenceDiscountCurveForForwardsName); // do not use discountCurveName here (usually this is an OIS curve)
		if(referenceDiscountCurveForForwards==null) {
			throw new IllegalArgumentException(this.getName() + ": referenceDiscountCurveForForwards " + referenceDiscountCurveForForwardsName + " not found in the model:\n" + model.toString());
		}
		if(Double.isNaN(paymentOffset) || paymentOffset<=0.0) {
			throw new IllegalArgumentException(this.getName() + ": Requesting forward with paymentOffset " + paymentOffset + " not allowed.");
		}

		double daycount = paymentOffset * daycountScaling;
		return referenceDiscountCurveForForwards.getDiscountFactor(model, fixingTime+periodOffset).div(referenceDiscountCurveForForwards.getDiscountFactor(model, fixingTime+paymentOffset+periodOffset)).sub(1.0).div(daycount);
	}
1060679
public DoubleVector[] chooseSeeds(int numCentroids, Matrix dataPoints) {
        int[] centroids = new int[numCentroids];
        // Select the first centroid randomly.
        DoubleVector[] centers = new DoubleVector[numCentroids];
        int centroidIndex = (int) Math.round(
                Math.random()*(dataPoints.rows()-1));
        centers[0] = dataPoints.getRowVector(centroidIndex);

        // Compute the distance each data point has with the first centroid.
        double[] distances = new double[dataPoints.rows()];
        computeDistances(distances, false, dataPoints, centers[0]);

        // For each of the remaining centroids, select one of the data points,
        // p, with probability
        // p(dist(p, last_centroid)^2/sum_p(dist(p, last_centroid)^2))
        // This is an attempt to pick the data point which is furthest away from
        // the previously selected data point.
        for (int i = 1; i < numCentroids; ++i) {
            double sum = distanceSum(distances);
            double probability = Math.random();
            centroidIndex = chooseWithProbability(distances, sum, probability);
            centers[i] = dataPoints.getRowVector(centroidIndex);
            computeDistances(distances, true, dataPoints, centers[i]);
        }

        return centers;
    }
218494
public static IFilter getFilter(long numElements, double maxFalsePosProbability, boolean offheap)
    {
        assert maxFalsePosProbability <= 1.0 : "Invalid probability";
        if (maxFalsePosProbability == 1.0)
            return new AlwaysPresentFilter();
        int bucketsPerElement = BloomCalculations.maxBucketsPerElement(numElements);
        BloomCalculations.BloomSpecification spec = BloomCalculations.computeBloomSpec(bucketsPerElement, maxFalsePosProbability);
        return createFilter(spec.K, numElements, spec.bucketsPerElement, offheap);
    }
302167
public double[] getSentenceProbabilities() {
    double[] sentProbArray = new double[sentProbs.size()];
    for (int i = 0; i < sentProbArray.length; i++) {
      sentProbArray[i] = ((Double) sentProbs.get(i)).doubleValue();
    }
    return sentProbArray;
  }
1241969
public JaccardIndex<K, VV, EV> setMaximumScore(int numerator, int denominator) {
		Preconditions.checkArgument(numerator >= 0, "Maximum score numerator must be non-negative");
		Preconditions.checkArgument(denominator > 0, "Maximum score denominator must be greater than zero");
		Preconditions.checkArgument(numerator <= denominator, "Maximum score fraction must be less than or equal to one");

		this.unboundedScores = false;
		this.maximumScoreNumerator = numerator;
		this.maximumScoreDenominator = denominator;

		return this;
	}
1348015
public static <S extends Solution<?>> void tradeoffUtility(List<S> solutionsList) {
    // Reset scalarization values from previous iterations
    for (S solution : solutionsList) {
      setScalarizationValue(solution, 0.0);
    }

    for (int cur = 0; cur < solutionsList.size() - 1; cur++) {
      S current = solutionsList.get(cur);
      for (int oth = cur + 1; oth < solutionsList.size(); oth++) {
        S other = solutionsList.get(oth);
        double numerator = 0.0;
        double denominator = 0.0;
        for (int i = 0; i < current.getNumberOfObjectives(); i++) {
          if (current.getObjective(i) > other.getObjective(i)) {
            numerator = Math.max(numerator, current.getObjective(i) - other.getObjective(i));
          } else if (current.getObjective(i) < other.getObjective(i)) {
            denominator = Math.max(denominator, other.getObjective(i) - current.getObjective(i));
          }
        }
        // Neither solution Pareto dominates the other
        if (numerator != 0.0 && denominator != 0.0) {
          setScalarizationValue(current, Math.max(getScalarizationValue(current), numerator / denominator));
          // Tradeoff utility is symmetric
          setScalarizationValue(other, Math.max(getScalarizationValue(other), denominator / numerator));
        }
      }
    }
  }
411565
@Override
    public int getAvailablePermits() {
        int minPermits = Integer.MAX_VALUE;
        for (PoolLimitDeterminationStrategy strategy : strategies) {
            int availablePermits = strategy.getAvailablePermits();
            minPermits = Math.min(minPermits, availablePermits);
        }
        return minPermits; // If will atleast be one strategy (invariant in constructor) and hence this should be the value provided by that strategy.
    }