*3.3. Prediction of Failure and Machine Repair Times*

In the paper, we analyze the system describing the shift on which a failure occurs. Additionally, the repair time [37] required for failure removal is analyzed. Let (Ω, F , *P*) be a probabilistic space: Ω—sample space (set of elementary events, outcomes), field F is a family of sample space Ω (set of all subsets of sample space Ω), *P*—probability measure (function that assigns each element from field F the probability, the value between 0 and 1), *N*—a set of natural numbers, *R*—a set of real numbers, *S* = {*s*1,*s*2, ... ,*sk*}—a set of possible shifts, *k* ∈ *N*, *k* < ∞—the number of possible shifts.

**Definition 1.** *A family* {*Xt*}*t*∈*<sup>N</sup> of random variables Xt* : Ω → *S for any t* ∈ *N is called a stochastic process with discrete time* [38,39].

At any *t* ∈ *N* time, the system can take one of the possible states denoted as *Xt*(ω) = *xt* ∈ *S* and *P*(*Xt*(ω) = *si*) = *pi*(*t*) value means the probability that the system is in a state *si* ∈ *S*,1 ≤ *i* ≤ *k* at a moment *t* ∈ *N*, and *k <sup>i</sup>*=<sup>1</sup> *pi*(*t*) = 1.

**Definition 2.** *A stochastic process* {*Xt*}*t*∈*<sup>N</sup> with a discrete time is called a Markov chain* [38,39]*. If for each n* ∈ *N , moments t*1,*t*2, ... ,*tn* ∈ *N satisfying the condition t*<sup>1</sup> < *t*<sup>2</sup> < ... < *tn and any x*1, *x*2, ... , *xn* ∈ *S*, *the equality*:

$$P(X\_{t\_n} = \mathbf{x}\_n | X\_{t\_{n-1}} = \mathbf{x}\_{n-1}, \ X\_{t\_{n-2}} = \mathbf{x}\_{n-2}, \ \dots, \ X\_{t\_1} = \mathbf{x}\_1) = P(X\_{t\_n} = \mathbf{x}\_n | X\_{t\_{n-1}} = \mathbf{x}\_{n-1}), \tag{7}$$

*holds.*

Below we assume *tn* = *n* ∈ *N*. If {*Xt*}*t*∈*<sup>N</sup>* is a heterogeneous Markov chain, then for any *t* ∈ *N* and 1 ≤ *i*, *j* ≤ *k*, the value:

$$P(\mathbf{X}\_t = s\_j | \mathbf{X}\_{t-1} = s\_i) = p\_{ij}(t), \tag{8}$$

is the transition probability from *si* state at the moment *t* − 1 to *sj* state at moment *t*. From Markov property (7), the conditional probability distribution of the future process state depends only on the current state at moment *t*, regardless of the past. The matrix *P*(*t*) = *pij*(*t*) <sup>1</sup>≤*i*,*j*≤*<sup>k</sup>* is called the transition probabilities matrix at the moment *t* and the elements of the *P*(*t*) matrix satisfy the condition *k <sup>j</sup>*=<sup>1</sup> *pij*(*t*) = 1 for *t* ∈ *N* and 1 ≤ *i* ≤ *k*.

**Definition 3.** *The Markov chain* {*Xt*}*t*∈*<sup>N</sup> is homogeneous, if the probabilities of transition pij*(*t*) *do not depend on the moment t* ∈ *N*.

Thus, if for a homogeneous Markov chain [39,40] the matrix *P* = *pij* <sup>1</sup>≤*i*,*j*≤*<sup>k</sup>* satisfies the condition *k <sup>j</sup>*=<sup>1</sup> *pij* = 1, 1 ≤ *i* ≤ *k*, then it is known as the one-step transition probability matrix. From the above, for a homogeneous Markov chain, the transition probability from *si* state at *t* moment to the *sj* state at *t* + *n* moment is calculated as follows [38,40]:

$$P\{X\_{t+n} = s\_j | X\_t = s\_i\} = p\_{ij}^{\quad (n)}\tag{9}$$

where ) *p* (*n*) *ij* \* 1≤*i*,*j*≤*k* = *Pn*, *n* ∈ *N* is the transition probability matrix in *n* steps.

**Definition 4.** *If* {*Xt*}*t*∈*<sup>N</sup> is a homogeneous Markov chain and there is a distribution* π = (π1, π2, ... , π*k*) *where* π*<sup>i</sup>* ≥ 0*,* 1 ≤ *i* ≤ *k and k <sup>i</sup>*=<sup>1</sup> π*<sup>i</sup>* = 1 *satisfying the equation*:

$$
\pi P = \pi \tag{10}
$$

*then the distribution* π *is called the stationary distribution of the homogeneous Markov chain.*

This property means that if at some *n* ∈ *N* moment the chain reaches a stationary distribution, then for each subsequent moment greater than *n*, the distribution will remain the same. To determine the stationary distribution, we solve Equation (10).

Let {*xt*}0≤*t*≤*<sup>n</sup>* be the realization of Markov chain, where *ni* = #{*t* : *xt* = *si*, 0 ≤ *t* ≤ *n*} is the number of moments for which the system was in *si* state, 1 ≤ *i* ≤ *k* and *k <sup>i</sup>*=<sup>1</sup> *ni* = *n*. The value *nij* = # ' *t* : *xt* = *si*, *xt*+<sup>1</sup> = *sj*, 0 ≤ *t* ≤ *n* − 1 ( represents the number of transitions from the state *si* to the state *sj* for 1 ≤ *i*, *j* ≤ *k* and *k <sup>j</sup>*=<sup>1</sup> *nij* = *ni*. We calculate the estimator of transition probability from *si* state to *sj* state as *<sup>p</sup>*ˆ*ij* <sup>=</sup> *nij ni* for 1 ≤ *i*, *j* ≤ *k*.

In this work, the goodness of fit test is used to verify Markov property χ<sup>2</sup> [40,41]. At the significance level α ∈ (0, 1), we create a working hypothesis: *H*<sup>0</sup> : *P*(*Xt* = *x*|*Xt*−<sup>1</sup> = *y*, *Xt*−<sup>2</sup> = *z*) = *P*(*Xt* = *x*|*Xt*−<sup>1</sup> = *y*) (the chain {*Xt*}*t*∈*<sup>N</sup>* meets Markov property) and an alternative hypothesis: *H*<sup>1</sup> : *P*(*Xt* = *x*|*Xt*−<sup>1</sup> = *y*, *Xt*−<sup>2</sup> = *z*) - *P*(*Xt* = *x*|*Xt*−<sup>1</sup> = *y*) (the chain {*Xt*}*t*∈*<sup>N</sup>* does not meet Markov property), where *x*, *y*, *z* ∈ *S*.

To verify the hypothesis *H*0, we calculate the test statistics:

$$\chi^2\_{\varepsilon} = \sum\_{i=1}^k \sum\_{j=1}^k \sum\_{j=1}^k \frac{\left(n\_{ij\upsilon} - n\_{ij}\mathfrak{p}\_{j\upsilon}\right)^2}{n\_{ij}\hat{p}\_{j\upsilon}},\tag{11}$$

which has a χ<sup>2</sup> distribution with *k*<sup>3</sup> degrees of freedom and *nijv* = # ' *t* : *xt* = *si*, *xt*+<sup>1</sup> = *sj*, *xt*+<sup>2</sup> = *sv*, 0 ≤ *t* ≤ *n* − 2 ( is the number of transitions from state *si* to state *sj* and next to state *sv* for 1 <sup>≤</sup> *<sup>i</sup>*, *<sup>j</sup>*, *<sup>v</sup>* <sup>≤</sup> *<sup>k</sup>*. The critical value is a quantile of order 1 <sup>−</sup> <sup>α</sup> for <sup>χ</sup><sup>2</sup> distribution with *k*<sup>3</sup> degrees of freedom. We denote as χ<sup>2</sup> - <sup>1</sup> <sup>−</sup> <sup>α</sup>, *<sup>k</sup>*<sup>3</sup> . If χ<sup>2</sup> *<sup>e</sup>* < χ<sup>2</sup> - <sup>1</sup> <sup>−</sup> <sup>α</sup>, *<sup>k</sup>*<sup>3</sup> , then at the significance level α, there are no grounds for rejecting the working hypothesis *H*0. So, we can assume that the chain {*Xt*}*t*∈*<sup>N</sup>* meets Markov property. When <sup>χ</sup><sup>2</sup> *<sup>e</sup>* <sup>≥</sup> <sup>χ</sup><sup>2</sup> - <sup>1</sup> <sup>−</sup> <sup>α</sup>, *<sup>k</sup>*<sup>3</sup> , then at the significance level α we reject the working hypothesis *H*<sup>0</sup> in favor of the alternative hypothesis. Thus, the chain {*Xt*}*t*∈*<sup>N</sup>* does not meet Markov property.

An ARIMA model, which usually correlates historical values in a time series, is applied to forecast the repair time. The behavior of the considered time series can be predicted (i.e., forecast with appropriate probability) based on current observation and historical data (dataset). Let {*rtt*}*t*∈*<sup>N</sup>* denote the sequence of times needed to repair a plant. Because the times needed do remove the failures can take only positive values, the variance-stabilizing transformation

$$
\varepsilon\_t = \ln(rt\_t) \tag{12}
$$

can be applied.

The series {ε*t*}*t*∈*<sup>N</sup>* is identified using *ARIMA*(*p*,*r*, *q*) models, *p*,*r*, *q* ∈ *N* (auto-regressive integrated moving average) [42–45]. In this paper, the logarithm of repair time is modelled as follows:

$$
\Delta^r \varepsilon\_t = a\_0 + a\_1 \Delta^r \varepsilon\_{t-1} + \dots + a\_p \Delta^r \varepsilon\_{t-p} + \varepsilon\_t - \theta\_1 \varepsilon\_{t-1} - \dots - \theta\_q \varepsilon\_{t-q} \tag{13}
$$

where {*t*}*t*∈*<sup>N</sup>* is a sequence of independent random variables with distribution *N* - 0, σ<sup>2</sup> . To estimate the integration degree, Augmented Dickey-Fuller (ADF) and the Kwiatkowski-Phillips-Schmidt-Shin (KPSS) [42,46,47] tests are applied.

The Markov chains and ARIMA models are implemented to determine the values of elements of sets *FTMl* and *TBMl*. The analysis of historical machine failure data leads to determining important failure parameters, which can subsequently help establish buffer time periods in the predictive production scheduling method.
