Java List Create createNormativeTroopAllocation( List probs)

Here you can find the source of createNormativeTroopAllocation( List probs)

Description

Creates a troop allocation where 100% of troops are allocated against the group or location with the highest probability.

License

Open Source License

Parameter

Parameter Description
probs a parameter

Declaration

public static List<Integer> createNormativeTroopAllocation(
        List<Integer> probs) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**/*  w  ww. j  av  a 2 s  .  co m*/
     * Creates a troop allocation where 100% of troops are allocated against the group or location with the highest probability.
     * 
     * @param probs
     * @return
     */
    public static List<Integer> createNormativeTroopAllocation(
            List<Integer> probs) {
        if (probs != null && !probs.isEmpty()) {
            ArrayList<Integer> I = new ArrayList<Integer>(probs.size());
            int maxProb = Integer.MIN_VALUE;
            int maxProbIndex = 0;
            int i = 0;
            for (Integer prob : probs) {
                if (prob > maxProb) {
                    maxProb = prob;
                    maxProbIndex = i;
                }
                i++;
            }
            for (i = 0; i < probs.size(); i++) {
                if (i == maxProbIndex) {
                    I.add(100);
                } else {
                    I.add(0);
                }
            }
            return I;
        }
        return null;
    }
}

Related

  1. createMultiParamMessage(String aPrefix, String aSuffix, List aParams)
  2. createMultiSelectionValue(List values)
  3. createMutableList(Collection collection)
  4. createNewList(Class type)
  5. createNormalDistributionByBootstrapping( List values1, List values2, final List sums1, final List sums2)
  6. createNullElementList(int size)
  7. createNullList(int numberOfElements)
  8. CreateObjectList(Object... values)
  9. createOneElementList(T element)