How to write down formally number of occurrences?
Solution 1:
-
If you are willing to use the "Iverson bracket notation", popularized by Knuth and others, you can say $$C(x) = \sum_{i=1}^n [s_i = x]$$
Here $[\ldots]$ are the Iverson brackets. $[P]$ is defined to be 1 if $P$ is true, and 0 if it is false.
-
People do sometimes use the Kronecker delta for this: $\delta_{ij}$ is defined to be 1 if $i=j$ and 0 if $i\ne j$, so you would have:
$$C(x) = \sum_{i=1}^n \delta_{xs_i}$$ or $$C(x) = \sum_{i=1}^n \delta(x, s_i)$$
but I think the Iverson bracket is more straightforward.
-
Most straightforward would be to write
Let $C(x)$ be the number of elements of $s_1,\ldots,s_n$ that are equal to $x$. Then…
The idea that this is somehow less "formal" than something involving a bunch of funny symbols is a common misapprehension.
Solution 2:
It's also not quite correct. How about $|\{i\in\{1,\ldots,n\}\colon s_i=a\}|$ in the numerator? If you view the sequence $S$ as a function $S\colon\{1,\ldots,n\}\to A$, $i\mapsto s_i$, then you might even write $|S^{-1}(a)|$ for the numerator. And the denominator should simply be $n$ (which you implicitly defined for $S$). As $S$ is not (primarily) a set, $|S|$ looks strange.
Solution 3:
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