This came up in a game theory crafting exercise.
Imagine a character has 195 hit points.
You can shoot at them and there are three results:
Critical - 100 damage - 40% of shots
Body - 50 damage - 40%
Miss -0 damage - 20%
The gun shoots 1 bullet per second.
Besides running through thousands of different simulations and averaging the result, is there a way to get the average time to kill using a formula? The point would be to compare hundreds of guns with different damage numbers and different hit percentages potentially.
EDIT for solutions - I initially thought a weighted average damage per bullet (which is 60) would solve for this. But I was wrong.
In the particular situation posited there is a possibility of the targeted character receiving $0,50,100,150$ or $200+$ damage points. Because the character initially has $195$ "hit points", once the damage exceeds that it's "game over".
In discrete probability we call this an absorbing Markov chain. You have a distribution of probabilities for the accumulated damage points at each time step. The relationship between probabilities at time $t$ and time $t+1$ is given by multiplying by a probability transition matrix.
The damage points at time $t=0$ is known to be zero, so labeling the "damage points" states as multiples $0,1,2,3$ of $50$ points together with a terminal state of $200$ or more damage points, we have an initial vector:
$$ v_0 = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 \end{pmatrix} $$
at time $t=0$, and subsequent probability distribution vectors:
$$ v_t = v_0 P^t $$
for times $t= 1,2,3,\ldots$, where $P$ is the probability transition matrix:
$$ P = \begin{bmatrix} 0.2 & 0.4 & 0.4 & 0.0 & 0.0 \\ 0.0 & 0.2 & 0.4 & 0.4 & 0.0 \\ 0.0 & 0.0 & 0.2 & 0.4 & 0.4 \\ 0.0 & 0.0 & 0.0 & 0.2 & 0.8 \\ 0.0 & 0.0 & 0.0 & 0.0 & 1.0 \end{bmatrix} $$
If we write $P$ in block form that highlights that the final state is "absorbing" (once the character receives $200$ damage points, no further change in states occurs):
$$ P = \begin{bmatrix} Q & R \\ 0 & 1 \end{bmatrix} $$
then the "fundamental matrix" $N = (I-Q)^{-1}$ allows us to compute the expected number of steps to reach the absorbing state from each of the transient states:
$$ N \vec{1} $$
Here $\vec{1}$ is a column vector of all ones, and the entries of $N \vec{1}$ give the expected number of steps starting from a corresponding transient state to reach the absorbing state:
$$ N = \begin{bmatrix} 1.25 & 0.625 & 0.9375 & 0.78125 \\ 0.00 & 1.25 & 0.625 & 0.9375 \\ 0.00 & 0.00 & 1.25 & 0.625 \\ 0.00 & 0.00 & 0.00 & 1.25 \end{bmatrix} $$
$$ N \vec{1} = \begin{pmatrix} 3.59375 \\ 2.8125 \\ 1.875 \\ 1.25 \end{pmatrix} $$
As a reality check let's consider the final entry's value of $1.25$. If the targeted character has already received $150$ damage points when shooting begins, the chance of surviving one more step (second) is $0.2$ (Miss!). Any hit (Body or Critical) means that step is the last. So the expected number of steps is:
$$ 1 + 0.2 + 0.2^2 + \ldots = \frac{1}{1 - 0.8} = \frac{5}{4} = 1.25 $$
Thus the standard computation sketched above tells us that the expected number of steps to take out the targeted character, starting from the undamaged (195 hit points) state, is $3.59375$.