Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For the following calculation, why $E[Z_1^2] = \pi/4$ ? In general, how to calculate $E[Z^2]$ ? Thanks much.

3 down vote

Let's also elaborate on Ross Millikan's answer, adapted to the case f(x)=1−x2−−−−−√, 0≤x≤1. Suppose that $(X1,Y1),(X2,Y2),\ldots$is a sequence of independent uniform vectors on $[0,1]\times [0,1]$, so that for each $i$, $X_i$ and $Y_i$ are independent uniform $[0,1]$ random variables. Define $Z_i$ as follows: $Z_i=1$ if $X_i^2+Y_i^2 \le 1$, $Z_i=0$ if $X_i^2+Y_i^2 > 1$, so the $Z_i$ are independent and identically distributed random variables, with mean $\mu$ given by $ \mu = E[Z_1] =P[X_1^2+Y_1^2 \le 1]=P[(X_1,Y_1) \in \{(x,y) \in [0,1]^2 : x^2+y^2 \le 1\}] = \pi/4$, where the last equality follows from $P[(X1,Y1)\in A]=\text{area}A (A \subset [0,1]^2)$.

By the strong law of large numbers, the average Zˉn=∑ni=1Zin converges, with probability 1, to the expectation μ as n→∞. That is, with probability 1, Zˉn→π/4 as n→∞.

To get a probabilistic error bound, note first that the $Z_i$ have variance $\sigma^2$ given by $\sigma^2=\text{Var}[Z_1]=E[Z_1^2]−E^2[Z_1]=\pi /4−(\pi /4)^2=\pi /4 (1−\pi /4)<10/59$.

share|cite|improve this question
Could you please edit your question to make it clearer? – Niel de Beaudrap May 26 '11 at 16:09

Elaborating on my (second, according to date) answer from Approximating $\pi$ using Monte Carlo integration.

Suppose that $(X_1,Y_1)$ is a uniform vector on $[0,1] \times [0,1]$, so that $X_1$ and $Y_1$ are independent uniform$[0,1]$ random variables. Define $Z_1$ as follows: $Z_1 = 1$ if $X_1^2 + Y_1^2 \leq 1$, $Z_1 = 0$ if $X_1^2 + Y_1^2 > 1$. Then, $$ {\rm E}[Z_1] = 1 \cdot {\rm P}[X_1^2 + Y_1^2 \leq 1] + 0 \cdot {\rm P}[X_1^2 + Y_1^2 > 1] = {\rm P}[X_1^2 + Y_1^2 \leq 1]. $$ Similarly, $$ {\rm E}[Z_1^2] = 1^2 \cdot {\rm P}[X_1^2 + Y_1^2 \leq 1] + 0^2 \cdot {\rm P}[X_1^2 + Y_1^2 > 1] = {\rm P}[X_1^2 + Y_1^2 \leq 1]. $$ Hence, ${\rm E}[Z_1^2] = {\rm E}[Z_1] $. Next, note that $X_1^2 + Y_1^2 \leq 1$ if and only if $(X_1,Y_1)$ belongs to the set $A \subset [0,1]^2$ defined by $$ A = \lbrace (x,y) \in [0,1]^2 : x^2+y^2 \leq 1\rbrace. $$ Thus, $$ {\rm E}[Z_1^2] = {\rm P}[X_1^2 + Y_1^2 \leq 1] = {\rm P}\big[(X_1,Y_1) \in A]. $$ However, ${\rm P}[(X_1,Y_1) \in A] = {\rm area}A$, and ${\rm area}A = \pi/4$ (recall that the area of a disc of radius $1$ is $\pi$); hence ${\rm E}[Z_1^2] = \pi/4$.

share|cite|improve this answer

It is simply because Z square is equal to Z here. notice that Z square is equal to 1 iff Z is equal to 1 and Z square is equal to 0 iff Z is null.

share|cite|improve this answer

An expectation operator is a basically integration. Provided you know the p.d.f. of a random variable $Z$, $f(z)$, $$E(Z)=\int z f(z) dz$$ and $$E(Z^{2})=\int z^2 f(z) dz $$ over the support (the interval of z in which $f(z)$ is positive) of $z$.

share|cite|improve this answer
Check your answer for typographical errors: you have two different definitions for $E(Z)$. – Dilip Sarwate Aug 6 '12 at 2:58
Sorry, but I don't see how this answer has any relevance to the question. – Nate Eldredge Aug 6 '12 at 14:49
Sorry, I missreaded the question. I thought the question only goes in the first line. Nevertheless, the question is hard to understand anyway. He said "in general, how to calculate $E[Z^{2}]$." So I provided the solution to the question. – Ikuyasu Aug 7 '12 at 2:00
@Ikuyasu The account from which the question was posted does not exist anymore, so it is unlikely you will get any clarification (at least not from the original user). – Austin Mohr Aug 7 '12 at 2:01
It's pretty old post and somebody seemed to have gave a nice answer anyway. – Ikuyasu Aug 7 '12 at 19:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.