Assuming you have a map with numeric values, you can find the standard deviation of all keys in the map with the following code:
index.ts339 chars18 lines
This code iterates through all the keys in the map, keeping track of the sum of the keys, the sum of the squared keys, and the count of keys. It then calculates the mean, variance, and standard deviation using the formulas:
index.ts96 chars4 lines
Finally, the standard deviation is logged to the console.
gistlibby LogSnag