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 a FloatDict with the original keys, mapped to their pct of the total
()
| 817 | * @return a FloatDict with the original keys, mapped to their pct of the total |
| 818 | */ |
| 819 | public FloatDict getPercent() { |
| 820 | double sum = sum(); |
| 821 | FloatDict outgoing = new FloatDict(); |
| 822 | for (int i = 0; i < size(); i++) { |
| 823 | double percent = value(i) / sum; |
| 824 | outgoing.set(key(i), (float) percent); |
| 825 | } |
| 826 | return outgoing; |
| 827 | } |
| 828 | |
| 829 | |
| 830 | /** Returns a duplicate copy of this object. */ |