Estimator for conditional expectation w.r.t an event I try to estimate a conditional expectation of the form $\mathbb{E}(X \vert B)$ where $X$ is a random variable on a probability space $(\Omega, \mathcal{A}, \mathbb{P})$ and $B \in \mathcal{A}$. The problem is I don't know the distribution of $X$ and also I don't know the value of $\mathbb{P}(B)$ (but I assume $\mathbb{P}(B) > 0$). I can only generate realizations of $X$ via a "black box" and for each realization I can check numerically if $B$ is realized or not.
My attempt to estimate $\mathbb{E}(X \vert B)$ is to generate $N$ outcomes $\omega_i \in \Omega$ and compute the estimator
\begin{equation}
\Big(\frac{1}{N} \sum_{i=1}^N \mathbf{1}_{\omega_i \in B} \Big)^{-1} \Big( \frac{1}{N} \sum_{i=1}^N X(\omega_i) \mathbf{1}_{\omega_i \in B} \Big),
\end{equation}
which is inspired by the formula $\mathbb{E}(X \vert B) = \mathbb{P}(B)^{-1} \mathbb{E}(X \mathbf{1}_B)$. This estimator is consistent, but I can't tell if it's a good one because I fail to derive a confidence interval. Is there another estimator more suitable for the estimation of $\mathbb{E}(X \vert B)$? And is it possible to quantify/bound the error? Thanks.
 A: You provided a good estimator, but if you want to get a confidence interval you should always reach for the limit distribution (especially if you don't know the true underlying distribution of $X$ and connection with event $B$)
Just apply the CLT (Central limit theorem) for your estimator.
$\textbf{Theorem}$(CLT): Consider i.i.d sample $X_1, \dots, X_n$ with mean $\mathbb{E}X = \mu$ and variance $\mathbb{D}(X) = \sigma^2$, then
$$
 \dfrac{\sum\limits_{i=1}^n (X_i - \mu)}{\sqrt{n} \sigma} \xrightarrow{w} 
\mathcal{N}(0,1) 
$$
where $w$ -- denotes weak convergence (which is enough for you asymptotically at least since weak convergence implies that if $Z_n = \dfrac{\sum\limits_{i=1}^n (X_i - \mu)}{\sqrt{n} \sigma}$, than for any interval $(a,b)$ it is true 
$$
\mathbb{P}(Z_n\in(a,b)) \rightarrow \mathbb{P}(\gamma \in (a,b)), \, \gamma \sim \mathcal{N}(0,1)
$$
So for nominator apply the central limit theorem to get confidence interval 
for $\mathbb{E}(X\cdot 1_B)$
$$
 \dfrac{\sum_i X_i 1_B(i) - \mathbb{E}(X\cdot 1_B)}{\sqrt{n} \mathbb{D}(X\cdot1_B)} \xrightarrow{w} \mathcal{N}(0,1)
$$
(since you don't know the variance of $X\cdot 1_B$ you can substitute it with empirical variance). The denominator in your case almost surely converges to $\mathbb{P}(B)$. So you can renorm your estimator up to $\sqrt{n}$ term to get convergence to normal distribution and therefore make a confidence interval (at least asymptotical).
