TITLE: How to write down formally number of occurrences?
QUESTION [18 upvotes]: I want to write the following sentence formally:

The sequence $S$ contains elements of the set $A$. The probability value $P(a)$ for an element $a$ is defined as the number of its occurrences in the sequence $S$, divided by the count of all its elements.

I can write it the following manner:
$$ S = (s_1, s_2, ..., s_n) : s_i \in A.$$
$$ P(a) := {{ \left| \lbrace i \in \lbrace 1, 2, ..., n \rbrace : s_{i} = a \rbrace \right| } \over {n}}, \text{ given } n > 0\text{ and }a \in A. $$
It's, however, quite long and rather not elegant. Is there a simpler way to write this?

Edit:
There's always a solution, which involves breaking the formula to smaller parts:
$$ \text{Let } C(x) = \left| \lbrace i \in \lbrace 1, 2, ..., n \rbrace : s_i = x \rbrace \right|.$$
$$ P(a) := {C(a) \over n}. $$
It's more readable, but it's still not what I'm searching for...

REPLY [3 votes]: Using the number symbol "#",
$$ 
\DeclareMathOperator*{\countif}{\#}
P(a) := \dfrac{\countif\limits_{i=1}^{n} (s_i=a)}{n}, \text{ given } n > 0\text{ and }a \in A. 
$$
See John Fox, Applied Regression Analysis and Generalized Linear Models (3rd edition), Section 21.2.3