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
()
| 776 | * @return a FloatDict with the original keys, mapped to their pct of the total |
| 777 | */ |
| 778 | public FloatDict getPercent() { |
| 779 | double sum = sum(); |
| 780 | FloatDict outgoing = new FloatDict(); |
| 781 | for (int i = 0; i < size(); i++) { |
| 782 | double percent = value(i) / sum; |
| 783 | outgoing.set(key(i), (float) percent); |
| 784 | } |
| 785 | return outgoing; |
| 786 | } |
| 787 | |
| 788 | |
| 789 | /** Returns a duplicate copy of this object. */ |