If $X$ (which is not measurable) equals a measurable function $Y$ on a set $A$ having $\mu\left(A^{c}\right)=0,$ then $\int X d \mu \equiv \int Y d \mu .[$ It is trivial that the value $\int X d \mu$ is independent of the choice of $Y$ and $A .]$
I quoted this sentence from the book Probability for Statisticians in the chapter of Lebesgue Integral. Our teacher explains that (if I understand correctly) this paragraph simply means if we ignore the null set, which doesn't really matter in the Lebesgue setting, even if we are given a nonmeasurable function, as long as it equals to the measurable function $X$ on $A$, we can still obtain the Lebesgue integral. It is hard for me to picture what is a non-measurable function and how can a non-measurable function equals to a measurable function on a set. Could someone please give me an example?
Consider the real line $X$ with the sigma algebra of Borel sets and the Lebesgue measure. Let $C$ be the Cantor set. It is known that not every subset of $C$ is Borel set. [The class of all Borel sets has cardinality $c$ whereas the power set of $C$ has cardinality $2^{c}$]. Now let $X=I_C$ and $Y=I_E$ where $E$ is a subset of $C$ which is not a Borel set. Then $X=Y$ on $C^{c}$ and $\mu (C)=0$. $X$ is Borel measurable and $Y$ is not. Also, $X$ and $Y$ are both Lebesgue measurable and $\int X d \mu=\int Y d\mu=0$.