Given the QAOA circuit $U(\vec\gamma, \vec\beta)$, associated to some cost hamiltonian $H_C$, and evolving the state $|0\rangle^{\otimes n}$ into $|\vec\gamma, \vec\beta\rangle = U(\vec\gamma, \vec\beta)|0\rangle^{\otimes n}$, there is a difference in calculating the expectation value $$\langle H_C \rangle = \langle \vec\gamma, \vec\beta| H_C | \vec\gamma, \vec\beta \rangle $$ and calculating the value as shown in Qiskit Textbook by measuring observable $\sigma^z$ instead of $H_C$ (repeating the measure $N$ times), obtaining $N$ bitstring and calculating manually, classically, the "mean cost" which is a formula similar to $$ \text{cost}_{H_C} = \sum_{i=1}^N H_C(i\text{-th bitstring})/N$$ where $H_C(\text{bitstring})$ is an abuse of notation indicating the cost associated to a single bitstring, a single sample measured by this circuit.
For $N$ as large as you want, is $\langle H_C \rangle = \text{cost}_{H_C}$? Is there a proof for this?