I have $N$ sets of a set of discrete probabilities indexed by $i$. Denote the probabilities by $p_{j}^{(i)}$ where $1\leqslant i\leqslant N$, $% 1\leqslant j\leqslant n_{i}$ so that for each $i$ $$\sum_{j=1}^{n_{i}}p_{j}^{(i)}=1$$ $$0<p_{j}^{(i)}\leqslant 1 $$ Sample from each of the $N$ distributions, obtaining $k_{i}$ with probability $p_{k}^{(i)}$ and define the random variable $X_{i}$ by $$X_{i}=U_{i}p_{k_{i}}^{(i)}+\sum_{j=1}^{k_{i}-1}p_{k_{i}}^{(i)}$$ where $U_{i}$ is a random variable sampled from the uniform distribution on $% \left[0,1\right]$. Then the $X_{i}$ are uniformly distributed on $\left[0,1\right] $. Choose a sub interval $\left[x,y\right] $ of $\left[ 0,1% \right] $, i.e. $0\leqslant x<y\leqslant 1$, and let $M\left(x,y\right) $ be the number of $X_{i}$ in $\left[ x,y\right] $. Then because the $X_{i}$ are uniformly distributed on $\left[ 0,1\right] $, the expected value of $M$ is $E\left(M\right)=N\left(y-x\right) $.
I want to know the variance of $M$, can anyone help?
I don't really follow the construction of $X_i$, but assuming, as you say, that each $X_i$ is uniform in $[0, 1]$, they are iid, and you draw $N$ of them, then $$M(x, y) \sim \text{Binomial}(N, y-x)$$ Thus $E[M(x, y)] = N(y-x)$ and $\text{Var}(M(x, y)) = N(y-x)(1-(y-x))$