Need help understanding formula for probability that something good happens before something bad happens. My book says this.
Consider a sequence of independent trials, each of which can
be classified as good, bad, or neutral, which happen (on any given trial) with
probabilities $p, q,$ and $1 − p − q$, respectively. (We do not necessarily have
$q = 1 − p$ here, although that case is allowed.) Then the probability that
something good happens before something bad happens is $p/(p + q)$.
My question is, how did they derive this formula $p/(p+q)$ for probability that something good happens before something bad happens?
can someone show me a derivation/explain to me this?

Informally, you can ignore the neutral events, because if one happens you are back where you started.  You can then scale up the probabilities $p$ and $q$ so they sum to $1$, which gets the probability of something good being $\frac p{p+q}$ and the probability of something bad being $\frac q{p+q}$.  Note these sum to $1$ and have the proper ratio, which should convince you.
More formally, the chance of good before bad is a string of neutrals followed by a good and the chance of bad before good is a string of neutrals followed by a bad.  Again, the ratio has to be $\frac pq$ and the sum has to be $1$ because the chance of an infinite string of neutrals is $0$.  If you want, you can sum the geometric series and get the same result for more work.
