{'fraction_non_alphanumeric': 0.04914136312318022, 'fraction_numerical': 0.012597302275833383, 'mean_word_length': 3.7962382445141065, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A sequential test for the drift of a Brownian motion with a possibility to change a decision

We construct a Bayesian sequential test of two simple hypotheses about the value of the unobservable drift coefficient of a Brownian motion, with a possibility to change the initial decision at subsequent moments of time for some penalty. Such a testing procedure allows to correct the initial decision if it turns out to be wrong. The test is based on observation of the posterior mean process and makes the initial decision and, possibly, changes it later, when this process crosses certain thresholds. The solution of the problem is obtained by reducing it to joint optimal stopping and optimal switching problems.


Introduction
We consider a problem of sequential testing of two simple hypotheses about the value of the unknown drift coefficient of a Brownian motion. In usual sequential testing problems (see e.g. the seminal works [4,8,10] or the recent monographs [1,9]), a testing procedure must be terminated at some stopping time and a decision about the hypotheses must be made. In contrast, in the present paper we propose a new setting, where a testing procedure does not terminate and it is allowed to change the initial decision (for the price of paying some penalty) if, given later observations, it turns out that it is incorrect.
We will work in a Bayesian setting and assume that the drift coefficient has a known prior distribution on a set of two values. A decision rule consists of an initial decision (τ, d), where τ is the moment at which the decision is made and d is a two-valued function showing which hypothesis is accepted initially, and a sequence of stopping times τ n , at which the decision can be changed later. The goal is to minimize a penalty function which consists of the three parts: a penalty for the waiting time until the initial decision, a penalty for a wrong decision proportional to the time during which the corresponding wrong hypothesis is being accepted, and a penalty for each change of a decision.
This study was motivated by the paper [6], where a sequential multiple changepoint detection problem was considered. That problem consists in tracking of the value of the unobservable drift coefficient of a Brownian motion, which is modeled by a telegraph process (a two-state Markov process) switching between −1 and +1 at random times. In the present paper, we deal with a similar tracking procedure and a penalty function, but the difference is that the unobservable drift coefficient does not change. Among other results on multiple changepoint detection, one can mention the paper [3], where a tracking problem for a general two-state Markov process with a Brownian noise was considered, and the paper [2], which studied a tracking problem for a compound Poisson process.
We solve our problem by first representing it as a combination of an optimal stopping problem and an optimal switching problem (an optimal switching problem is an optimal control problem where the control process assumes only two values). The optimal stopping problem allows to find the initial stopping time, while the subsequent moments when the decision is changed are found from the optimal switching problem. Consequently, the value function of the optimal switching problem becomes the payoff function of the optimal stopping problem. Then both of the problems are solved by reducing them to free-boundary problems associated with the generator of the posterior mean process of the drift coefficient. We consider only the symmetric case (i.e. type I and type II errors are of the same importance), in which the solution turns out to be of the following structure. First an observer waits until the posterior mean process exists from some interval (−A, A) and at that moment of time makes the initial decision. Future changes of the decision occur when the posterior mean process crosses some thresholds −B and B. The constants A, B are found as unique solutions of certain equations.
The rest of the paper consists of the three sections: Section 2 describes the problem, Section 3 states the main theorem which provides the optimal decision rule, Section 4 contains its proof.

The model and the optimality criterion
Let (Ω, F, P) be a complete probability space. Suppose one can observe a process X t defined on this probability space by the relation where B t is a standard Brownian motion, µ > 0 is a known constant, and θ is a ±1valued random variable independent of B t . It is assumed that neither θ nor B t can be observed directly. The goal is to find out whether θ = 1 or θ = −1 by observing the process X t sequentially. Note that the case when the drift coefficient of X t can take on two arbitrary values µ 1 = µ 2 can be reduced to (1) by considering the process X t − 1 2 (µ 1 + µ 2 )t. We will assume that the prior distribution of θ is known and is characterized by the probability p = P(θ = 1). Recall that usual settings of sequential testing problems consist in that an observer must choose a stopping time τ of the (completed and right-continuous) filtration F X = (F X t ) t≥0 generated by X t , at which the observation is stopped, and an F X τ -measurable function d with values −1 or +1 that shows which of the two hypotheses is accepted at time τ . The choice of (τ, d) depends on a particular optimality criterion which combines penalties for type I and type II errors, and a penalty for observation duration. But, in any case, a test terminates at time τ .
In this paper we will focus on a setting where an observer can change a decision made initially at time τ and the testing procedure does not terminate.
By a decision rule we will call a triple δ = (τ 0 , d, T ), where τ 0 is an F X -stopping time, d is an F X τ 0 -measurable function which assumes values ±1, and T = (τ 1 , τ 2 . . .) is a sequence of F X -stopping times such that τ n ≤ τ n+1 for all n ≥ 0. At the moment τ 0 , the initial decision d is made. Later, if necessary, an observer can change the decision to the opposite one, and the moments of change are represented by the sequence T . Thus, if, for example, d = 1, then at τ 0 an observer decides that θ = 1 and at τ 1 switches the opinion to θ = −1; at τ 2 switches back to θ = 1, and so on. It may be the case that τ n = +∞ starting from some n; then the decision is changed only a finite number of times (the optimal rule we construct below will have this property with probability 1). With a given decision rule δ, associate the F X -adapted process D δ t which expresses the current decision at time t, and define the Bayesian risk function where c i > 0 are given constants. The problem that we consider consists in finding a decision rule δ * which minimizes Such a decision rule δ * will be called optimal.
One can give the following interpretation to the terms under the expectation in (2). The term c 0 τ 0 is a penalty for a delay until making the initial decision. The next term is a penalty for making a wrong decision, which is proportional to the time during which the wrong hypothesis is being accepted. The last term is a penalty for changing a decision, in the amount c 2 for each change. Note that the problem we consider is symmetric (i.e. type I and type II errors are penalized in the same way); in principle, an asymmetric setting can be studied as well.

The main result
To state the main result about the optimal decision rule, introduce the posterior mean process M t = E(θ | F X t ). As follows from known results, the process M t satisfies the stochastic differential equation where B t is a Brownian motion with respect to F X (an innovation process, see, e.g., Chapter 7 in [5]), which satisfies the equation Representation (3) can be obtained either directly from filtering theorems (see Theorem 9.1 in [5]) or from the known equation for the posterior probability process π t = P(θ = 1 | F X t ) (see Chapter VI in [7]) since M t = 2π t − 1. In the explicit form, M t can be expressed through the observable process X t as Introduce the two thresholds A, B ∈ (0, 1), which depend on the parameters µ, c 0 , c 1 , c 2 of the problem, and will define the switching boundaries for the optimal decision rule. The threshold B is defined as the solution of the equation and the threshold A is defined as the solution of the equation .
The next simple lemma shows that A and B are well-defined. Its proof is rather straightforward and is omitted.
The following theorem, being the main result of the paper, provides the optimal decision rule in an explicit form.
Main Theorem. The optimal decision rule δ * = (τ * 0 , d * , T * ) consists of the stopping time τ * 0 and the decision function d * defined by the formulas and the sequence of stopping times T * = (τ * n ) ∞ n=1 which on the event {d * = 1} are defined by the formulas and on the event {d = −1} by the formulas (where inf ∅ = +∞).
Example. Figure 1 illustrates how the optimal decision rule works. In this example, we take p = 0.5, µ = 1/3, c 0 = 2/3, c 1 = 1, c 2 = 3/2. The thresholds A, B can be found numerically, A ≈ 0.37, B ≈ 0.55. The simulated path on the left graph has θ = 1. The rule δ * first waits until the process M t exists from the interval (−A, A). Since in this example it exists through the lower boundary (at τ * 0 ), the initial decision is d * = −1 (incorrect). Then the rule waits until M t crosses the threshold B, and changes the decision to θ = 1 at τ * 1 .

Proof of the Main Theorem
Let us denote by P x and E x the probability measure and the expectation under the assumption P(θ = 1) = (x + 1)/2, so the posterior mean process M t starts from the value M 0 = x. It is easy to verify that and, by taking intermediate conditioning with respect to F X t in (2), we can see that we need to solve the problem (by "to solve" we mean to find δ at which the infimum is attained for a given x; in passing we will also find the function V * (x) in an explicit form). Observe that there exists the limit M ∞ := lim t→∞ M t = θ a.s. Hence the solution of problem (8) should be looked for only among decision rules δ such that D δ t has a finite number of jumps and D δ ∞ = θ (note that the rule δ * satisfies these conditions). In view of this, for a stopping time τ 0 denote by D(τ 0 ) the class of all F X -adapted càdlàg processes D t such that, with probability 1, they assume values ±1 after τ 0 , have a finite number of jumps, and satisfy the condition D ∞ = θ. Let U * (τ 0 ) be the value of the following optimal switching problem: Consequently, problem (8) can be written in the form Thus, to show that the decision rule δ * is optimal, it will be enough to show that τ * 0 delivers the infimum in the problem V * , and D δ * delivers the infimum in the problem U * (τ * 0 ). In order to do that, we are going to use a usual approach based on "guessing" a solution and then verifying it using Itô's formula. Since this approach does not show how to actually find the functions V * and U * , in the remark after the proof we provide heuristic arguments that can be used for that.
We will first deal with U * . Let B be the constant from (4). Introduce the "candidate" function U (x, y) x ∈ [−1, 1], y ∈ {−1, 1}, defined by (see Figure 2, which depicts the function U (x, y), as well as the function V (x) defined below, with the same parameters as in the example in the previous section).
We are going to show that U * (τ 0 ) = U (|M τ 0 |, 1). Let Lf denotes application of the generator of the process M t to a sufficiently smooth function f , i.e.
. By U ′ and ∆U denote, respectively, the derivative with respect to the first argument, and the difference with respect to the second argument of U , i.e.
From the above explicit construction (11)-(13), it is not difficult to check that U (x, y) has the following properties: Consider any process D ∈ D(τ 0 ) and let (τ n ) n≥1 be the sequence of the moments of its jumps after τ 0 . Property (U.1) allows to apply Itô's formula to the process U (M t , D t ), from which for any s > 0 we obtain  U (x, y). The parameters µ, c 0 , c 1 , c 2 are the same as in Figure 1.
Take the expectation E x ( · | F X τ 0 ) of the both sides of (14). By (U.2), the integrand in the stochastic integral is uniformly bounded, so its expectation is zero. Passing to the limit s → ∞ and using the equality D ∞ = M ∞ , which implies U (M s∨τ 0 , D s∨τ 0 ) → 0 as s → ∞, we obtain where to get the inequality we used property (U.3) for the first term under the expectation and (U.4) for the second term. Taking the infimum of the both sides of (15) over On the other hand, if the process D t is such that D τ 0 = sgn M τ 0 (let sgn 0 = 1, if necessary) and its jumps after τ 0 are identified with the sequence (τ n ) n≥1 defined as in (6)-(7) but with arbitrary τ 0 in place of τ * 0 , then we would have the equality in (15), as follows from (U.3) and (U.4). Together with (16), this implies that U * (τ 0 ) = U (M τ 0 , sgn M τ 0 ) = U (|M τ 0 |, 1) and the infimum in the definition of U * (τ 0 ) is attained at this process D t .
Let us now consider the problem V * . As follows from the above arguments, we can write it in the form It is clear that it is enough to take the infimum only over stopping times with finite expectation. Let A be the constant defined in (5), and put Introduce the "candidate" function V (x), x ∈ [−1, 1]: It is straightforward to check that V (x) has the following properties: Applying Iô's formula to the process V (M t ) and taking the expectation, for any stopping time τ 0 with E τ 0 < ∞ we obtain (Itô's formula can be applied in view of (V.1); the expectation of the stochastic integral, which appears in it, is zero in view of (V.2) and the finiteness of E τ 0 ).
The proof is complete.
Remark. The above proof does not explain how to find the functions V (x) and U (x, y).
Here we provide arguments which are based on well-known ideas from the optimal stopping theory and allow to do that. The reader is referred, e.g., to the monograph [7] for details. Since the process M t is Markov, we can expect that the optimal process D t for U * should depend only on current values of M t and D t− . Moreover, it is natural to assume that D t should switch from 1 to −1 when M t becomes close to −1, and switch from −1 to 1 when M t becomes close to 1. The symmetry of the problem suggests that there should be a threshold B such that the switching occurs when M t crosses the levels ±B. This means that the optimal sequence of stopping times T * is of the form (6)- (7). Consequently, in the set {(x, y) : x > −yB}, where x corresponds to the value of M t and y corresponds to the value of D t , one should continue using the current value of D t , while in the set {(x, y) : x ≤ −yB} switch to the opposite one. In what follows, we will call these sets the continuation set and the switching set, respectively.
Next we need to find B. Introduce the value function U (x, y) (cf. (9); it turns out to be the same function U (x, y) which appears in the proof): where the infimum is taken over all càdlàg processes D t which are adapted to the filtration generated by M t , take on values ±1, and have a finite number of jumps. In the switching set, we have U (x, y) = U (x, −y) + c 2 .
From the general theory (see Chapter III in [7]), we can expect that the value function U (x, y) in the continuation set solves the ODE Its general solution can be found explicitly: where K 1 and K 2 are constants. Since we have U (1, 1) = 0 (if x = 1, then M t = 1 for all t ≥ 0 and the optimal process D is D t ≡ 1), we get K 2 = −K 1 . To find K 1 and B, we can employ the continuous fit and smooth fit conditions, also known from the general theory, which state that at the boundary of the continuation set, i.e. at the points (x, y) with x = −yB, the value function satisfies the equations (here x = −B, y = 1; the pair x = B, y = −1 gives the same equations due to the symmetry of the problem). Solving these equations gives formulas (11)-(13) for U (x, y).
To find the function V (x) we use a similar approach. From the representation as a standard optimal stopping problem (17), we can expect that the optimal stopping time should be the first exit time of the process M t from some continuation set. Taking into account the original formulation of the problem as a sequential test, it is natural to assume that the initial decision should be made at a moment when the posterior mean becomes close to 1 or −1, i.e. the continuation set for V (x) should be an interval (−A, A). As follows from the general theory, V (x) in the continuation set satisfies the ODE LV (x) = −c 0 , which has the general solution Due to the symmetry of the problem, we have V (x) = V (−x), so K 3 = 0. Then the constants A and K 4 can be found from the continuous fit and smooth fit conditions at