Eg the first one:
f = [12, 199, 3125, 29616, 175426, 662401, 1608671, 2477850, 2441350,
1580290, 709625, 235426, 60899, 12643, 2126, 296, 41, 4, 0, 0]
x = 0:(length(counts)-1)
using StatsBase
μ, σ = mean_and_std(x, Weights(f); corrected = false)