  Given ideals $I,J$ of a noetherian local ring $(R, \mathfrak m)$ such that
$I+J$ is $\mathfrak m$-primary and a finitely generated module $M$, we
associate an invariant of $(M,R,I,J)$ called the $h$-function. Our results on
$h$-function allow extensions of the theories of Frobenius-Poincar\'e functions
and Hilbert-Kunz density functions from the known graded case to the local
case, answering a question of Trivedi. When $J$ is $\mathfrak m$-primary, we
describe the support of the corresponding density function in terms of other
invariants of $(R, I,J)$. We show that the support captures the $F$-threshold:
$c^J(I)$, under mild assumptions, extending results of Trivedi and Watanabe.
The $h$-function treats Hilbert-Samuel, Hilbert-Kunz multiplicity and
$F$-threshold on an equal footing. We develop the theory of $h$-functions in a
more general setting which yields a density function for $F$-signature. A key
to many results on $h$-function is a `convexity technique' that we introduce,
which in particular proves differentiability of Hilbert-Kunz density function
almost everywhere, thus contributing to another question of Trivedi.
