Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void findEntityCount(List<Inputs> input) {
- // Find the smallest exponent based upon the natural log
- double smallest = Double.MAX_VALUE;
- for (Inputs entry : input) {
- double exp = Math.log(entry.raw);
- if (exp < smallest) {
- smallest = exp;
- }
- }
- // Calculate the scaling, note that this is closely related to finding the
- // mantissa of the input value, but subtracting one from the value helps
- // pack things a bit better
- long total = 0;
- double scaling = Math.pow(10, Math.abs(smallest) - 1);
- for (Inputs entry : input) {
- entry.count = (long)Math.ceil(entry.raw * scaling);
- total += entry.count;
- }
- // Use the initial total to find a multiplier that we can use to adjust
- // the initial counts to the final count for the simulation
- double multiplier = MAX_ENTITY_COUNT / total;
- for (Inputs entry : input) {
- entry.count *= multiplier;
- }
- }
Add Comment
Please, Sign In to add comment