I'm trying to devise a hypothesis test for failure rate data of machines. The gist is that there are some machines in a factory that run all the time. They fail from time to time and are promptly repaired when they do. Now, a "fix" is deployed to some of the machines (treatment group) and we want to see if it improves (decreases) their failure rate. This is similar to another question I asked a while ago: Hypothesis test for machine failure rates. However, I didn't get an answer back then. What has changed now is that I have taken a stab at it myself and ask the community to please take a look and see if its utterly stupid; what blind spots there might be and what might have been done differently. Next, I will describe the hypothesis test I devised:
I assume that the time to repair for the machines is negligible compared to the time to failure in general. I also assume that the exponential distribution is a reasonable assumption for the inter-arrival time of failure events (this is a reasonable assumption since we're doing the test on failure rates and constant failure rates imply the exponential distribution).
Let's say we see $n_1$ downtime events in the first group with total run time (machine hours): $t$ and $n_2$ downtime events in the second group with total run time: $s$. The failure rate of the first group becomes: $\frac{n_1}{t}$ and that of the second group becomes $\frac{n_2}{s}$. So, the difference in failure rate between the two groups becomes:
$$d = \frac{n_1}{t}-\frac{n_2}{s}\tag{1}$$
Now, we want to get the p-value. The null hypothesis is that the two groups have the same failure rate and any $d$ (failure rate difference) we see is statistical noise. So, the null hypothesis assumes a unified failure rate across the two groups of:
$$λ_m=(n_1+n_2)/(t+s)$$
Now, given $t$ and $s$ and $\lambda_m$, the number of failures we expect in those intervals; ($N_1$ and $N_2$ respectively) are Poisson distributed with parameters $λ_m t$ and $λ_m s$ (under the null hypothesis). The difference in two rates we will see will be: $\delta=(N_1/t−N_2/s)$ under the null hypothesis.
So to reject the null, we just get the probability that $\delta > d$ and this becomes the p-value. This can be calculated with simulation or through the double summation (across $N_1$ and $N_2$). Both approaches are implemented here: https://github.com/ryu577/stochproc/blob/master/stochproc/hypothesis/rate.py