We consider the question of randomness of the probability $\Omega_U[X]$ that an optimal Turing machine $U$ halts and outputs a string in a fixed set $X$. The main results are as follows: - $\prob U X$ is random whenever $X$ is $\Sigma^0_n$-complete or $\Pi^0_n$-complete for some $n\geq2$. - However, for $n\geq2$, $\prob U X$ is not $n$-random when $X$ is $\Sigma^0_n$ or $\Pi^0_n$. Nevertheless, there exists $\Delta^0_{n+1}$ sets such that $\prob U X$ is $n$-random. - There are $\Delta^0_2$ sets $X$ such that $\prob U X$ is rational. Also, for every $n\geq1$, there exists a set $X$ which is $\Delta^0_{n+1}$ and $\Sigma^0_n$-hard such that $\prob U X$ is not random. We also look at the range of $\Omega_U$ as an operator. We prove that the set $\{\prob U X:X\subseteq\words\}$ is a finite union of closed intervals. It follows that for any optimal machine $U$ and any sufficiently small real $r$, there is a set $X\subseteq \words$ recursive in $\emptyset'\oplus r$, such that $\prob{U}{X}=r$. The same questions are also considered in the context of infinite computations, and lead to similar results.