# Probability that a device turns off in n seconds

At zero time a device is on, and can be turned on or off at any time. Let $$p_1, p_2, \dots$$ the probabilities that the device is off at times $$1, 2, \dots$$.

What is the probability that the device will be turned off for the first time at time $$n$$?

EDIT:

I think that it can be solved just by: $$(1-p_1)\times(1-p_2)\times \dots \times p_n$$

But I am not sure how to arrive this conclusion, as it seems to be backed on independent events, but I cannot be sure about the independence here.

The question concerns a sample space $$\Omega$$ of sequences of observations of the light made at times $$1, 2, 3, \ldots.$$ For it to be answerable, we have to suppose that the switch can be flipped no more than once in any interval $$(n-1,n]$$ (for otherwise the observations do not determine when the switch is flipped).

$$\Omega$$ therefore can be identified with the set of all binary sequences

$$\Omega = \{\omega\mid \omega:\mathbb{N}\to \{0,1\}\}$$

where $$\omega(0)=1$$ indicates the light is on at time $$0$$ and generally at any time $$n,$$ $$\omega(n)=1$$ if and only if the light is on at time $$n.$$

Let $$\mathcal{P}_i = \{\omega\mid \omega(i)=0\}$$ be the set where the light is off at time $$i.$$ The problem supposes every $$\mathcal{P}_i$$ is an event for $$i=0,1,2,\ldots$$ and the associated probabilities of these events are

$$\Pr(\mathcal{P}_i)=p_i.$$

Any answer therefore boils down to representing the set

$$\mathcal{E}_n = \text{The light was first turned off in the interval }(n-1,n]$$

in terms of the events $$\mathcal{P}_i.$$

We can try to figure this out recursively. Begin with $$n=1:$$ $$\mathcal{E}_1$$ is the event the light is not on at time $$1.$$ It is identical to $$\mathcal{P}_1,$$

$$\mathcal{E}_1 = \mathcal{P}_1.$$

When $$n=2,$$ $$\mathcal{E}_2$$ is the event "the light is not on at time $$2$$ but the light was still on at time $$1.$$" In set notation, using overbars to denote complements (with respect to $$\Omega$$),

$$\mathcal{E}_2 = \mathcal{P}_2\cap \bar{\mathcal{P}_1}.$$

It consists of all sequences of the form $$110\ldots\,.$$

Because it is difficult to see how the chance of this intersection is determined by any of the specified probabilities $$p_i,$$ let's look for a counterexample. Evidently, we can focus on the first three times $$0,1,2.$$

Consider, then, the family of probability functions $$\mathbb{P}_\alpha$$ given by this table:

$$\begin{array}{} \omega & \mathbb{P}_\alpha \\ \hline 111\ldots & \alpha(1-p_1)\\ 110\ldots & (1-\alpha)(1-p_1)\\ 101\ldots & p_1 - p_2 + (1-\alpha)(1-p_1)\\ 100\ldots & p_2 - (1-\alpha)(1-p_1) \end{array}$$

The left hand column indicates the four events corresponding to the state of the light at times $$0,1,$$ and $$2$$ while the right hand column gives their probabilities.

For this to be a valid probability function, none of the chances can be negative. This forces $$\alpha$$ to lie between $$0$$ and $$1$$ (to make the first two chances non-negative) and

$$\frac{p_2-p_1}{1-p_1}\le \alpha \le \frac{p_2}{1-p_1}$$

(to make the last two chances non-negative). For instance, when $$p_1=p_2=1/2,$$ we must have $$0\le \alpha \le 1.$$ This demonstrates such probability families exist.

Now since $$\mathcal{P}_1 = \{100\ldots, 101\ldots\}$$ and $$\mathcal{P}_2 = \{100\ldots, 110\ldots\},$$ the axioms of probability give

$$\mathbb{P}_\alpha(\mathcal{P}_1) = \mathbb{P}_\alpha(100\ldots) + \mathbb{P}_\alpha(101\ldots) = p_1$$

and

$$\mathbb{P}_\alpha(\mathcal{P}_2) = \mathbb{P}_\alpha(100\ldots) + \mathbb{P}_\alpha(110\ldots) = p_2,$$

showing that these probability functions satisfy all the requirements of the problem. However,

$$\mathbb{P}_\alpha(\mathcal{E}_2) = \mathbb{P}_\alpha(\mathcal{P}_2 \cap \bar{\mathcal{P}_1}) = \mathbb{P}_\alpha(110\ldots) = (1-\alpha)(1-p_1).$$

This looks like it can vary with $$\alpha.$$ Indeed, taking the example $$p_1=p_2=1/2,$$ these probabilities are

$$(1-\alpha)(1-1/2) = (1-\alpha)/2,$$

which (as we saw above) can be any value from $$(1-0)/2=1/2$$ down to $$(1-1)/2=0.$$

This proves the question does not generally have a unique answer. In fact, the restrictions on $$\alpha$$ only imply

$$p_2 - p_1 \le \Pr(\mathcal{E}_2) \le p_2.$$

Similar inequalities must apply to the chances of all the other events $$\mathcal{E}_3,$$ $$\mathcal{E}_4,$$ etc.

• @Galen Your comment intimates that this family is some kind of device or modification of the question. However, it's an essential part of the problem and therefore ought to appear in any correct answer, because it partly characterizes the extent to which the problem (and therefore its answer) is indeterminate. (It is a full characterization for the cases where $n$ is limited to $2.$)
– whuber
Jul 6, 2021 at 14:41
• Thank you for your great answer! I will need a little more time to (hopefully) fully understand it, as you guess this is not my field. If I understood it right, my solution may or may not works. Do I get it right? I am surprised of such a thing, but not that surprised: I made some simulations and in many cases I found the right results, and in other cases wrong results. It was inexplicable to me as the only difference in the code was the starting list of zeros and ones. Jul 6, 2021 at 15:31
• That sounds about right. Your formula is the kind that arises when you assume the events $\mathcal{P}_i$ are independent, which suggests there may be (special) situations where it gives the correct answer.
– whuber
Jul 6, 2021 at 17:32
• That context helps. We can characterize the $p_i$ as the marginal probabilities of the sequence if we view that sequence as being one realization of a binary time series process. Since, in that question, you ask about the autocorrelation, you are implicitly assuming that process is second order stationary (otherwise the correlation has little meaning apart from helping to describe your one particular sequence--but then what would probabilities even mean?). That, in turn, implies all the $p_i$ are the same. (This does not imply independence, though.)
– whuber
Jul 6, 2021 at 23:16
• The moral is correct. My assertion that stationarity of covariance implies constancy of marginal means was incorrect. However, constancy of the $p_i$ does not imply constancy of the ACF. Although the $p_i$ determine the variances (as $p_i(1-p_i)$), they do not determine the covariances.
– whuber
Jul 7, 2021 at 18:17

To answer this question and confirm the answer that is proposed in the OP, I would first propose to slightly rephrase it as :

"A device is initially on and experiences a sequence of events $$1, 2, \ldots$$ which can turn it off. Each binary trigger event occurs with an independent probability given by a Bernouilli trial parameterized by respectively $$p_1, p_2, \ldots$$. What is the probability that the device is turned off for the first time at the $$n^\text{th}$$ event?"

First, if $$n=1$$, the answer is simply $$p_1$$, that's easy and that special case can be put to side.

For $$n>1$$, the final answer follows by stating that this happens at event $$n$$ if and only if (1) the switch was not triggered off at events $$1, 2, \ldots, n-1$$ and (2) that the switch is triggered off at event $$n$$.

For the first part, note that in general at a given event $$k, given that the switch is still on, the probability that the switch is not triggered off at this event $$k$$ is equal to $$1-p_k$$. In particular, the probability that the switch was not triggered off at event $$1$$ is $$1-p_1$$. Given that the switch was not triggered off at event $$1$$, the probability that it is not triggered at event $$2$$ is $$1-p_2$$, and so on.

For the second part, the probability that the switch is triggered off at event $$n$$ is simply $$p_n$$.

Since all draws are independent, probabilities are multiplied and the probability that the switch is triggered off for the first time at event $$n$$ is equal to:

$$(1 - p_1) \times (1 - p_2) \times \ldots \times (1 - p_{n-1}) \times p_n$$

which confirms the intuition in the OP.

What may be confusing at first in the OP is the fact that the problem is set up as a temporal sequence and that we may need to consider the probability space of all "trajectories" of trigger events. Yet the problem is simpler as one asks in the OP the probability that event $$n$$ is triggered for the first time, and thus that all previous events are not triggered, and thus irrespective of a sequence (as would be explored in other answers).

• Thanks for your contribution. It adds clarity (+1), although solves a slightly different problem. In my problem, $p_n$ means the probability that the device is off at time $n$, and no matter what was the last step in which the switch was triggered off (it could be in any time $m\leq n$). Jul 13, 2021 at 16:39
• thanks, I understand now the OP. to me the answer is the same - just the probabilities are interpreted differently - either it is the probability of triggering the switch (changing its state from ON to OFF), or that of setting it to OFF. since you ask for the first time is is set OFF, the states before are ON and the answer is the same. do you want me to rephrase my answer according to that interpretation of the probability? Jul 20, 2021 at 12:46
• Please, excuse me for the delay (I was away form home and without my PC). I would appreciate that. However, I must say that I think that whuber is right and that this is not always the right solution. I empirically found that (by making numerical experiments), and I was confused because I could not find mistakes in that simple code (that sometimes worked and sometimes didn't, depending of the lists of ones and zeros that I randomly created). Aug 2, 2021 at 15:18
• i understand now that the probabilities are not that of the independent events but that that you will observe marginally. still, i believe there is a solution by retrieving the switch probabilities from the observed one (may be not unique) - could you provide with your simulation code in the OP? this would be very useful to provide a solution Aug 4, 2021 at 13:02