expected number of defective robots Factory produced $n$ robots. Every of robot is defective with probablity $q$.
If robot is defective then tester detect it with probablity $p$. We assume that tester detected $Z$ defective robots.
Let $X$ - number of defective robots.
Compute $E(X | Z = z)$a
So, my idea is:
$X_i = 1$ with probablity $q$ - robot is defective
$X_i = 0$ with probablity $1-q$ - robot is not defective
$$E(X | Z = z) = \sum_{k=1}^{n}Pr(X_i=1|Z=z)\cdot 1$$
$$Pr(X_1=1|Z=z)$$ - how to compute it ? Could u help me please ? 
Ok, you suggest $P(Z)$. It seems to me that you meaned $P(Z=z)$.
$$P(X_i=1|Z=z) = \frac{P(Z=z|X_i=1)P(X_i=1)}{P(Z=z)} $$ 
$$P(Z=z)= P(Z=z|X_i=1\wedge test\ detected )P(X_i=1) + P(Z=z|X_i=1\wedge test\ not\ deteced)P(X_i=1)$$
But it will be terrible expression..
 A: I would have thought that you have 


*

*$\displaystyle P(X=x)={n \choose x}q^x(1-q)^{n-x}$ for $0 \le x \le n$

*$\displaystyle P(Z=z|X=x) = {x \choose z}p^z(1-p)^{x-z}$ for $0 \le z \le x$

*$\displaystyle P(X=x,Z=z) = {n \choose x}q^x(1-q)^{n-x}{x \choose z}p^z(1-p)^{x-z}$ for $0 \le z \le x \le n$

*$\displaystyle P(Z=z) = \sum_{y=z}^n P(X=y,Z=z)$ for $0 \le z \le n$

*$\displaystyle P(X=x|Z=z) = \frac{P(X=x,Z=z)}{P(Z=z)} = \frac{P(X=x,Z=z)}{\displaystyle \sum_{y=z}^n P(X=y,Z=z)} $ for $0 \le z \le x \le n$


which written out and then with some terms cancelled might be
$$\dfrac{\displaystyle{n \choose x}q^x(1-q)^{n-x}{x \choose z}p^z(1-p)^{x-z}}{\displaystyle \sum_{y=z}^n {n \choose y}q^y(1-q)^{n-y}{y \choose z}p^z(1-p)^{y-z}} = 
\dfrac{\displaystyle \dfrac{\left(\dfrac{q}{1-q}(1-p) \right)^{x}}{(n-x)!(x-z)!}  }{\displaystyle \sum_{y=z}^n \dfrac{\left(\dfrac{q}{1-q}(1-p) \right)^{y}}{(n-y)!(y-z)!}}$$ 
A: Using
$$P(X_1=1|Z=z)= \frac{P(Z=z | X_1=1)P(X_1=1)}{P(Z=z)}$$
Now, $P(Z_i = 1) = q \, p= a$ , so $Z=\sum Z_i$ is a binomial $B_{n,a}(z) $:
$$P(Z=z) = {n \choose z} a^z (1-a)^{n-z}$$
Further $$P(Z=z | X_1=1) = P(Z=z \cap Z_1=1 | X_1=1) + P(Z=z \cap Z_1=0 | X_1=1)=\\
=p B_{n-1,a}(z-1) + (1-p)  B_{n-1,a}(z)\\
$$
Hence $$P(X_1=1|Z=z)=q \frac{p{n-1 \choose z-1} a^{z-1} (1-a)^{n-z}+
(1-p){n-1 \choose z} a^{z} (1-a)^{n-1-z}}{{n \choose z} a^z (1-a)^{n-z}}=\\
=qp \frac{z}{n a} + q(1-p)\frac{n-z}{n(1-a)}=\\
=\frac{z}{n}+\frac{(n-z)}{n}\frac{(q-q\,p)}{1-q p}$$
Hence $$E(\sum X_i|Z=z)=n P(X_1=1|Z=z) = z+ (n-z)\frac{(q-q\,p)}{1-q p} $$
