Sum all of the values in this dictionary, then return a new FloatDict of each key, divided by the total sum. The total for all values will be ~1.0. @return an IntDict with the original keys, mapped to their pct of the total
()
| 732 | * @return an IntDict with the original keys, mapped to their pct of the total |
| 733 | */ |
| 734 | public FloatDict getPercent() { |
| 735 | double sum = sum(); // a little more accuracy |
| 736 | FloatDict outgoing = new FloatDict(); |
| 737 | for (int i = 0; i < size(); i++) { |
| 738 | double percent = value(i) / sum; |
| 739 | outgoing.set(key(i), (float) percent); |
| 740 | } |
| 741 | return outgoing; |
| 742 | } |
| 743 | |
| 744 | |
| 745 | /** Returns a duplicate copy of this object. */ |