Expected value of random variable that is defined by another Suppose I have a random variable:
\begin{equation}
X \sim
\begin{cases}
1 \text{ with probability } p \\
y \sim \mathit{unif}(1,k) \text{ with probability } 1 - p
\end{cases}
\end{equation}
Where $\mathit{unif}$ is the discrete uniform distribution. I am trying to compute the expected value $E[X].$ I think it should just be simply:
\begin{equation}
1 \cdot p + E[y] \cdot (1-p) = 1 \cdot p + (1 + k)/2 \cdot (1-p)
\end{equation}
But I am not sure if I am overlooking something.

Your random variable takes the value $1$ with probability $p+\frac{1-p}{k}$, and takes each value $j\in\{2, \dots, k\}$ with probability $\frac{1-p}{k}$. So the expectation is simply
$$ \begin{align*} EX
= & 1\times \big(p+\frac{1-p}{k}\big) + \sum_{j=2}^k j\times\frac{1-p}{k} \\ 
= & p+\frac{1-p}{k}\times \sum_{j=1}^k j \\
= & p+\frac{1-p}{k}\times\frac{k(k+1)}{2} \\
= & p+\frac{(1-p)(k+1)}{2}.
\end{align*}$$
