We obtain averages of specific functions defined over (isomorphism classes) of some type of finite abelian groups. These averages are concerned with miscellaneous questions about the pℓ-ranks of these groups. We apply a classical heuristic principle to deduce from the averages precise predictions for the behavior of class groups of number fields and of Tate–Shafarevich groups of elliptic curves. Furthermore, the computations of these averages, which comes with an algebraic aspect, can also be reinterpreted with a combinatorial point of view. This allows us to recover and to obtain some combinatorial identities and to propose for them a natural algebraic context.