Expected value of rolling dice until getting a $3$ I am having trouble with this question with regards to random variables and calculating expected values:

Suppose I keep tossing a fair six-sided dice until I roll a $3$. Let $X$ be the number of times I roll the dice. What is the value of $E[X]$?

So for this problem I was thinking that the answer would just be $1$. Here is my thought behind it. 
For each turn there is a $1/6$ chance of hitting a three. If I keep rolling and rolling I will eventually hit a $3$. So the math works out to be $(1/6)*6$ which is equal to $1$. Does this logic make sense? I am a bit confused with how exactly I would go about picking the values for $P(X=x)$ and how to calculate expected value. Some insight would be very helpful. 
 A: What you describing is a Geometric distribution with probability of success $1/6$.
The probability function is $$P(X=k)=(1-p)^{k-1}p$$ where X is a random variable that corresponds to the number of trials in an experiment until the first success.
So the the mean value is by the definition (but it can be proved quite easily) $$E(X)=1/p=1/(1/6)=6$$
You can find more here
A: A solution without calculus:
$E[x]$ is simply the sum of the number of rolls times the probability that this number of rolls have occurred. If exactly $n$ rolls occur before one stops, then one must roll something other than $3$ $n-1$ times, and then a $3$ $1$ time. The probability of this happening is
$$
\left(\frac{5}{6}\right)^{n-1}\cdot\left(\frac{1}{6}\right)
$$
And thus we want to compute
$$
E[x]=\frac{1}{6}\cdot \sum_{n=1}^{\infty} n\left(\frac{5}{6}\right)^{n-1}
$$
So
$$
\frac{5}{6}E[x]=\frac{1}{6}\cdot \sum_{n=1}^{\infty} n\left(\frac{5}{6}\right)^n=\frac{1}{6}\sum_{n=2}^{\infty} (n-1)\left(\frac{5}{6}\right)^{n-1}=\frac{1}{6}\sum_{n=2}^{\infty}n\left(\frac{5}{6}\right)^{n-1}-\frac{1}{6}\sum_{n=2}^{\infty}\left(\frac{5}{6}\right)^{n-1}
$$
$$
=E[x]-\frac{1}{6}-\frac{1}{6}\cdot \frac{5}{6}\cdot\frac{1}{1-\frac{5}{6}}=E[x]-\frac{1}{6}-\frac{5}{6}=E[x]-1
$$
But then $\frac{1}{6}E[x]=1$, so $E[x]=6$.
A: No, this logic doesn't make sense; but, let's see if we can clear that up!
For a fixed number $k$, let's think about the event $\{X=k\}$.  If we can find the probabilities of each of these events (for $k=1,2,3,\ldots$), then
$$
\mathbb{E}[X]=\sum_{k=1}^{\infty}kP(X=k).
$$
What does it mean to say that $X=k$?  It means that the first $k-1$ rolls of the dice gave a number other than $3$, and that the $k$th roll gave exactly $3$. Thus
$$
P(X=k)=\left(\frac{5}{6}\right)^{k-1}\cdot\frac{1}{6}.
$$
So, we find that.
$$
\mathbb{E}[X]=\frac{1}{6}\sum_{k=1}^{\infty}k\left(\frac{5}{6}\right)^{k-1}
$$
Now, this must be simplified... but that's not so bad, if you remember some stuff about sequences and series.  First, remember that
$$
\sum_{k=0}^{\infty}x^k=\frac{1}{1-x},\qquad \lvert x\rvert<1.
$$
Differentiating each side of this, we find
$$
\frac{1}{(1-x)^2}=\frac{d}{dx}\left[\frac{1}{1-x}\right]=\frac{d}{dx}\left[\sum_{k=0}^{\infty}x^k\right]=\sum_{k=1}^{\infty}kx^{k-1},\qquad \lvert x\rvert<1.
$$
In particular, taking $x=\frac{5}{6}$ yields
$$
\mathbb{E}[X]=\frac{1}{6}\sum_{k=1}^{\infty}k\left(\frac{5}{6}\right)^{k-1}=\frac{1}{6}\cdot\frac{1}{(1-\frac{5}{6})^2}=6.
$$
A: Just to note, in general, for a geometric distribution of the random variable $X$ with probability of success $p$, $\mathbb{E}[X] = \frac{1}{p}$.  Why?  Well, evidently, since achieving the desired event in $n$ rolls is $p(1-p)^{n-1}$, we get
$$
\mathbb{E}[X] = \displaystyle\sum\limits_{n=1}^{\infty}np(1-p)^{n-1}
$$
Replacing $1-p$ with $q$ and multiplying, we get
$$
\mathbb{E}[X] = \displaystyle\sum\limits_{n=1}^{\infty}nq^{n-1} - \displaystyle\sum\limits_{n=1}^{\infty}nq^{n}
$$
One could solve each of these separately, but I've seen a nicer way before: essentially, we do the following: 
$$
\mathbb{E}[X] = 1 + \displaystyle\sum\limits_{n=1}^{\infty}(n+1) q^{n} - \displaystyle\sum\limits_{n=1}^{\infty}nq^{n}
$$
$$
= 1 + \displaystyle\sum\limits_{n=1}^{\infty} q^{n}
$$
Now, noting that $\displaystyle\sum\limits_{n=1}^{\infty} q^{n} = \frac{q}{1-q}$, we get
$$ 
\mathbb{E}[X] = 1 + \frac{q}{1-q} = \frac{1}{1-q} = \frac{1}{p}
$$
and thus are done.
A: You have 2 possibilities when you roll. Either you roll 3 with 1/6 probability or you roll something else with 5/6 probability. If you roll 3 you stop there, if you roll something else you have to roll about E(X) times more to get to the desired result. Therefore,
E(X) = 1/6*1+5/6*(E(X)+1) from here E(X)=6. A simple solution using recursion.
