All articles →

100 Exercises / Mathematical modeling / Mathematical Modeling 100 Exercises

Predicting the "next state" of equipment, customers, and inventory

Use Python and transition matrices to forecast equipment, customer, inventory, and sales-funnel states, then compare maintenance and reactivation policies.

State Transition Models for an Industrial Equipment Manufacturer: No.071–No.080

This article models equipment health, customer activity, spare-parts inventory, and sales-funnel stages as states. We use Python to estimate transition probabilities, project future states with Markov models, and compare maintenance and customer-reactivation policies.

About this material These notebooks were adapted from corporate training delivered by Surikobo or its representative, Hiroshi Wayama, and published with the participating companies’ permission. All data is fictional and does not describe actual companies or factories.

Introduction: Practical Challenges in Manufacturing Covered in This Article

Equipment manufacturers monitor the weekly health status of 60 delivered machines. Preventive maintenance on abnormal equipment reduces failures but incurs maintenance costs and downtime. Replacement-parts customers may be active, dormant, or churned, while sales opportunities move through several stages.

We model how cases move between states to forecast the future mix of states and evaluate policies.

Common situations on site

  • Only machines in normal condition are counted; deterioration from caution to abnormal is not tracked.
  • Sensor thresholds and maintenance actions are not linked.
  • Recovery probabilities under corrective repair and preventive maintenance are not compared.
  • Customer churn is recorded, but earlier signs of inactivity are not tracked.
  • The persistence of inventory shortages and surpluses into the following week is unknown.
  • Each stage of the sales funnel is managed as an independent KPI

Why is this issue so difficult to judge?

A state carries information from one time point to the next. The number of abnormal machines depends on new deterioration as well as recovery or failure among machines that were already abnormal.

Define mutually exclusive states and make every row of the transition matrix sum to one. A Markov model assumes that, given the current state, earlier history does not change the next-state probabilities. Expand the state definition if age or past maintenance matters.

Exercises in this article

No.ThemePractical Judgment
071State variableWhat to hold as a state
072Customer StatusHow to define active, dormant, and churned customers
073transition probabilityHow to estimate a transition matrix from observations
074Markov ModelHow to predict state composition several weeks ahead
075customer defectionHow much customer-reactivation measures reduce churn
076Facility ConditionChanging sensor values to normal, caution, or abnormal
077Breakdowns and MaintenanceHow do recovery and failure probabilities differ with and without maintenance?
078Stock StatusHow to measure the persistence of excess, adequacy, and deficiency
079Purchase funnelHow to predict future numbers at the negotiation stage
080Measure EvaluationHow to compare the cost of preventive maintenance and failure reduction

Preparing the Python environment

Run the cells from top to bottom in Jupyter Notebook. [IN: n] marks an input and [OUT: n] its corresponding output. Environment details show the original execution example; version and OS strings will differ on your machine.

No external data is used. Fix the random number seed and generate the state sequence and transition matrix using NumPy, pandas, and matplotlib.

Show environment setup
[IN: 1]
%matplotlib inline
%config InlineBackend.figure_format = 'svg'

import platform, sys
import matplotlib, matplotlib.pyplot as plt
from matplotlib import font_manager
import numpy as np, pandas as pd
from IPython.display import display

SEED = 42
rng = np.random.default_rng(SEED)
fonts = {f.name for f in font_manager.fontManager.ttflist}
plot_font = next(
    (f for f in ["Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP"] if f in fonts),
    "sans-serif",
)
plt.rcParams["font.family"] = plot_font
plt.rcParams["axes.unicode_minus"] = False
print(
    f"Python {sys.version.split()[0]} / NumPy {np.__version__} / pandas {pd.__version__} / matplotlib {matplotlib.__version__}"
)
print(f"font {plot_font} / seed {SEED} / {platform.platform()}")

# Show full text in table cells instead of truncating long descriptions.
pd.set_option("display.max_colwidth", None)
[OUT: 1]
Python 3.13.1 / NumPy 2.5.1 / pandas 3.0.3 / matplotlib 3.11.0
font Hiragino Sans / seed 42 / macOS-26.3-arm64-arm-64bit-Mach-O

Fictional data

Tracks 60 units for 52 weeks, transitioning between normal, caution, abnormal, and malfunction. In some cases of abnormalities, preventive maintenance is implemented to improve transition probability. At the same time, it generates 400 customer companies and 18 months of operating, dormant, or defection status.

Show fictional-data setup
[IN: 2]
# These data-generation settings are teaching assumptions, not estimates from a real factory.
eq_states = ["Normal", "Caution", "Abnormal", "Failure"]
P_eq = np.array(
    [
        [0.90, 0.08, 0.015, 0.005],
        [0.18, 0.65, 0.13, 0.04],
        [0.05, 0.20, 0.55, 0.20],
        [0.65, 0.05, 0, 0.30],
    ]
)
P_maint = np.array([0.75, 0.20, 0.04, 0.01])
eq_rows = []
for machine in range(60):
    state = "Normal"
    for week in range(52):
        action = state == "Abnormal" and rng.random() < 0.55
        probs = P_maint if action else P_eq[eq_states.index(state)]
        nxt = rng.choice(eq_states, p=probs)
        vib_mean = {"Normal": 1.2, "Caution": 2.1, "Abnormal": 3.2, "Failure": 4.5}[
            state
        ]
        eq_rows.append(
            {
                "machine": machine + 1,
                "week": week,
                "state": state,
                "next_state": nxt,
                "maintenance": action,
                "vibration": max(0, rng.normal(vib_mean, 0.22)),
            }
        )
        state = nxt
equipment = pd.DataFrame(eq_rows)

cust_states = ["Active", "Dormant", "Churned"]
P_cust = np.array([[0.87, 0.10, 0.03], [0.20, 0.63, 0.17], [0, 0, 1]])
cust_rows = []
for customer in range(400):
    state = "Active"
    for month in range(18):
        nxt = rng.choice(cust_states, p=P_cust[cust_states.index(state)])
        cust_rows.append(
            {
                "customer": customer + 1,
                "month": month,
                "state": state,
                "next_state": nxt,
            }
        )
        state = nxt
customers = pd.DataFrame(cust_rows)
print(
    f"Equipment transitions: {len(equipment):,} records / Customer transitions: {len(customers):,} records"
)
display(equipment.head(8).style.format({"vibration": "{:.2f}"}))
[OUT: 2]
Equipment transitions: 3,120 records / Customer transitions: 7,200 records
  machine week state next_state maintenance vibration
0 1 0 Normal Normal False 0.97
1 1 1 Normal Normal False 1.41
2 1 2 Normal Normal False 0.91
3 1 3 Normal Normal False 1.13
4 1 4 Normal Normal False 1.01
5 1 5 Normal Normal False 1.37
6 1 6 Normal Normal False 1.45
7 1 7 Normal Normal False 1.01
[IN: 3]
eq_share = pd.crosstab(
    equipment["week"], equipment["state"], normalize="index"
).reindex(columns=eq_states, fill_value=0)
cust_share = pd.crosstab(
    customers["month"], customers["state"], normalize="index"
).reindex(columns=cust_states, fill_value=0)
fig, axes = plt.subplots(1, 2, figsize=(11, 4.2))
eq_share.plot.area(ax=axes[0], stacked=True)
axes[0].set_title("Weekly Trends in Equipment Condition Configuration")
axes[0].set_xlabel("week")
axes[0].set_ylabel("Composition ratio")
axes[0].grid(True, alpha=0.3)
cust_share.plot.area(ax=axes[1], stacked=True)
axes[1].set_title("Monthly Trends in Customer Status Composition")
axes[1].set_xlabel("month")
axes[1].set_ylabel("Composition ratio")
axes[1].grid(True, alpha=0.3)
plt.tight_layout()
plt.show()
[OUT: 3]

svg


No.071: Understanding the Concept of State Variables

Practical context

State variables carry information from one time point to the next. Examples include equipment health and inventory classified as excess, adequate, or short.

Modeling approach

Let St∈{Normal,Caution,Abnormal,Failure}S_t\in\{\text{Normal},\text{Caution},\text{Abnormal},\text{Failure}\}. Assign exactly one state at each observation time, using mutually exclusive and exhaustive definitions.

Check with Python

[IN: 4]
sample = equipment.query("machine==1")
state_num = {"Normal": 0, "Caution": 1, "Abnormal": 2, "Failure": 3}
fig, ax = plt.subplots()
ax.step(sample["week"], sample["state"].map(state_num), where="post", color="#2c7fb8")
ax.set_yticks(range(4), ["normal", "Caution", "abnormal", "malfunction"])
ax.set_title("State of machine 1 over time")
ax.set_xlabel("week")
ax.set_ylabel("Facility Condition")
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()
print(sample["state"].value_counts().to_string())
[OUT: 4]

svg

state
Normal     47
Caution     5

Interpreting the results

A state sequence shows how long a machine remains in caution, deteriorates to abnormal, or recovers. Recording time spent in each state helps prioritize persistent abnormalities.


No.072: Modeling Customer Conditions

Practical context

Classifying replacement-parts customers as active, dormant, or churned helps manage early signs of sales decline and reactivation.

Modeling approach

Use observable rules: active customers have purchased recently, dormant customers have not purchased for a specified period, and churned customers have ended their contracts.

Check with Python

[IN: 5]
customer_counts = pd.crosstab(customers["month"], customers["state"]).reindex(
    columns=cust_states, fill_value=0
)
display(customer_counts.tail(8))
fig, ax = plt.subplots()
customer_counts.plot(ax=ax, marker="o")
ax.set_title("Trends in the Number of Companies by Customer Status")
ax.set_xlabel("month")
ax.set_ylabel("Number of customers (companies)")
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()
[OUT: 5]
state Active Dormant Churned
month
10 144 66 190
11 145 57 198
12 147 48 205
13 142 38 220
14 128 41 231
15 129 34 237
16 115 33 252
17 114 26 260

svg

Interpreting the results

Churn accumulates, and the number of active customers decreases. The number of dormant customers serves as a leading indicator of future churn and is subject to repurchase strategies.


No.073: Modeling State Transition Probability

Practical context

A transition probability describes how likely the next state is, given the current state. It lets us compare deterioration and recovery rates.

Modeling approach

Define pij=P(St+1=j∣St=i)p_{ij}=P(S_{t+1}=j\mid S_t=i). Divide each transition count by its row total and verify that every row sums to one.

Check with Python

[IN: 6]
no_action = equipment.query("not maintenance")
P_hat = pd.crosstab(
    no_action["state"], no_action["next_state"], normalize="index"
).reindex(index=eq_states, columns=eq_states, fill_value=0)
display(P_hat.style.format("{:.1%}"))
print("Row sums:", P_hat.sum(axis=1).round(6).to_dict())
fig, ax = plt.subplots()
im = ax.imshow(P_hat, cmap="Blues", vmin=0, vmax=1)
ax.set_xticks(range(4), ["normal", "Caution", "abnormal", "malfunction"])
ax.set_yticks(range(4), ["normal", "Caution", "abnormal", "malfunction"])
ax.set_title("Estimated transition probability of equipment condition")
ax.set_xlabel("Next week status")
ax.set_ylabel("Current Status")
ax.grid(False)
plt.colorbar(im, ax=ax, label="migration probability")
plt.tight_layout()
plt.show()
[OUT: 6]
next_state Normal Caution Abnormal Failure
state        
Normal 91.4% 6.4% 1.4% 0.7%
Caution 18.5% 65.6% 12.4% 3.5%
Abnormal 0.0% 20.0% 55.0% 25.0%
Failure 72.7% 0.0% 0.0% 27.3%
Row sums: {'Normal': 1.0, 'Caution': 1.0, 'Abnormal': 1.0, 'Failure': 1.0}

svg

Interpreting the results

The diagonal component represents continuation, the right side represents deterioration, and the left side represents recovery. Since the estimation error is large in the state with a small number of cases, confidence intervals and stratification are considered.


No.074: Understanding the Markov Model Concept

Practical context

Based on the current state configuration and transition matrix, you can predict the number of normal, cautionary, abnormal, and faulty units several weeks ahead.

Modeling approach

For a row vector of state probabilities πt\pi_t, the update is πt+k=πtPk\pi_{t+k}=\pi_tP^k. We assume the Markov property: conditional on the current state, earlier history provides no additional information about the next state. We also assume the transition matrix remains constant over the forecast horizon.

Check with Python

[IN: 7]
pi0 = np.array([0.80, 0.15, 0.04, 0.01])
forecasts = []
for k in range(27):
    forecasts.append(
        {
            "week": k,
            **dict(zip(eq_states, pi0 @ np.linalg.matrix_power(P_hat.to_numpy(), k))),
        }
    )
markov = pd.DataFrame(forecasts)
display(markov.iloc[::5].style.format({s: "{:.1%}" for s in eq_states}))
fig, ax = plt.subplots()
for s in eq_states:
    ax.plot(markov["week"], markov[s] * 60, label=s)
ax.set_title("Equipment condition prediction using the Markov model")
ax.set_xlabel("Upcoming weeks")
ax.set_ylabel("Expected Number of Units (units)")
ax.grid(True, alpha=0.3)
ax.legend()
plt.tight_layout()
plt.show()
[OUT: 7]
  week Normal Caution Abnormal Failure
0 0 80.0% 15.0% 4.0% 1.0%
5 5 72.4% 17.1% 6.7% 3.8%
10 10 71.6% 17.4% 7.0% 4.0%
15 15 71.5% 17.5% 7.0% 4.0%
20 20 71.5% 17.5% 7.0% 4.0%
25 25 71.5% 17.5% 7.0% 4.0%

svg

Interpreting the results

For this transition matrix, the state distribution approaches a stationary distribution. This convergence is not guaranteed for every Markov chain. If maintenance history or time spent in a state matters, expand the state space, for example with “first week in caution.”


No.075: Expressing Customer Churn as a State Transition

Practical context

By implementing measures for dormant customers, you can estimate the future number of customers if you increase the probability of reactivation and reduce the probability of churn.

Modeling approach

Raise the baseline and policy transition matrices to the 12th power to compare the state distribution of the initial 400 customers after 12 months.

Check with Python

[IN: 8]
P_base = P_cust.copy()
P_action = P_cust.copy()
P_action[1] = [0.32, 0.58, 0.10]
initial = np.array([1.0, 0, 0])
rows = []
for name, P in [("Current Status", P_base), ("dormancy reactivation", P_action)]:
    dist = initial @ np.linalg.matrix_power(P, 12)
    rows.append(
        {"policy": name, **{s: dist[i] * 400 for i, s in enumerate(cust_states)}}
    )
churn_eval = pd.DataFrame(rows)
display(churn_eval.style.format({s: "{:.1f} companies" for s in cust_states}))
fig, ax = plt.subplots()
x = np.arange(2)
ax.bar(x - 0.2, churn_eval["Active"], 0.4, label="operation")
ax.bar(x + 0.2, churn_eval["Churned"], 0.4, label="defection")
ax.set_xticks(x, churn_eval["policy"])
ax.set_title("Customer states after 12 months: reactivation policy")
ax.set_xlabel("policy")
ax.set_ylabel("Number of Expected Customers (Company)")
ax.grid(True, axis="y", alpha=0.3)
ax.legend()
plt.tight_layout()
plt.show()
[OUT: 8]
  policy Active Dormant Churned
0 Current Status 148.0 companies 48.3 companies 203.7 companies
1 dormancy reactivation 188.2 companies 50.1 companies 161.6 companies

svg

Interpreting the results

Increasing the return rate from dormant to active increases the number of active customers after 12 months and reduces churn. We will make decisions based on both the initiative cost and the additional gross profit.


No.076: Expressing Equipment Status as Normal, Caution, or Abnormal

Practical context

By converting continuous sensor values into actionable states, you can unify the rules for monitoring, re-measurement, and inspection.

Modeling approach

Vibration values are classified as normal v<1.8v<1.8, caution 1.8≤v<2.81.8\le v<2.8, or abnormal v≥2.8v\ge2.8. Thresholds are set to balance missed and false alarms.

Check with Python

[IN: 9]
equipment["sensor_state"] = pd.cut(
    equipment["vibration"],
    [-np.inf, 1.8, 2.8, np.inf],
    labels=["normal", "Caution", "abnormal"],
    right=False,
)
sensor_counts = pd.crosstab(equipment["state"], equipment["sensor_state"])
display(sensor_counts)
sample = equipment.query("machine==2")
fig, ax = plt.subplots()
ax.plot(sample["week"], sample["vibration"], marker="o", markersize=3)
ax.axhline(1.8, color="#f0a202", linestyle="--")
ax.axhline(2.8, color="#de2d26", linestyle="--")
ax.set_title("Machine 2: vibration and state thresholds")
ax.set_xlabel("week")
ax.set_ylabel("Vibration velocity (mm/s)")
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()
[OUT: 9]
sensor_state normal Caution abnormal
state
Abnormal 0 4 123
Caution 57 434 0
Failure 0 0 66
Normal 2425 11 0

svg

Interpreting the results

You can extract anomaly candidates based on thresholds. Compare sensor status with actual faults and inspection results, and update by equipment type.


No.077: Expressing Failure and Maintenance as State Transitions

Practical context

For machines currently in the abnormal state, compare recovery and failure probabilities with and without preventive maintenance.

Modeling approach

Estimate the next-week state probabilities conditional on an abnormal current state and whether maintenance was performed. Because of selection bias, experimental design is necessary to determine causal effects.

Check with Python

[IN: 10]
abn = equipment.query("state=='Abnormal'")
maint_transition = pd.crosstab(
    abn["maintenance"], abn["next_state"], normalize="index"
).reindex(index=[False, True], columns=eq_states, fill_value=0)
maint_transition.index = ["No conservation", "preventive maintenance"]
display(maint_transition.style.format("{:.1%}"))
fig, ax = plt.subplots()
maint_transition[["Normal", "Failure"]].plot.bar(ax=ax, color=["#2ca25f", "#de2d26"])
ax.set_title("Next week's status of abnormal equipment: maintenance status")
ax.set_xlabel("Maintenance policy")
ax.set_ylabel("Transition probability")
ax.grid(True, axis="y", alpha=0.3)
plt.xticks(rotation=0)
plt.tight_layout()
plt.show()
[OUT: 10]
next_state Normal Caution Abnormal Failure
No conservation 0.0% 20.0% 55.0% 25.0%
preventive maintenance 79.1% 19.4% 1.5% 0.0%

svg

Interpreting the results

Preventive maintenance increases the chances of recovery to normal and reduces the transition to failure. Maintenance costs, planned shutdowns, and failure losses are integrated in No.080.


No.078: Expressing inventory status as excess, adequacy, or shortage

Practical context

By converting inventory quantities into states, you can manage the probability of surplus or shortage continuing into the following week and the recovery to appropriate inventory.

Modeling approach

As an example definition, stock coverage below 5 days is short, 5–15 days is adequate, and above 15 days is excess. The code does not calculate coverage days; it generates state sequences directly from an assumed transition matrix.

Check with Python

[IN: 11]
inv_states = ["Short", "Adequate", "Excess"]
P_inv = np.array([[0.45, 0.50, 0.05], [0.12, 0.76, 0.12], [0.04, 0.42, 0.54]])
inv_rows = []
for item in range(100):
    s = "Adequate"
    for week in range(30):
        nxt = rng.choice(inv_states, p=P_inv[inv_states.index(s)])
        inv_rows.append((item, week, s, nxt))
        s = nxt
inventory = pd.DataFrame(inv_rows, columns=["item", "week", "state", "next_state"])
P_inv_hat = pd.crosstab(
    inventory["state"], inventory["next_state"], normalize="index"
).reindex(index=inv_states, columns=inv_states)
display(P_inv_hat.style.format("{:.1%}"))
share = pd.crosstab(inventory["week"], inventory["state"], normalize="index").reindex(
    columns=inv_states, fill_value=0
)
fig, ax = plt.subplots()
share.plot.area(ax=ax)
ax.set_title("Inventory Status of Replacement Parts")
ax.set_xlabel("week")
ax.set_ylabel("Composition ratio")
ax.grid(True, alpha=0.3)
plt.tight_layout()
plt.show()
[OUT: 11]
next_state Short Adequate Excess
state      
Short 40.4% 54.4% 5.1%
Adequate 12.1% 74.4% 13.5%
Excess 4.2% 40.4% 55.3%

svg

Interpreting the results

Items with a high probability of continuous shortage or excess are not temporary exceptions but subject to review of order points and lot settings.


No.079: Expressing the Purchase Funnel as a State Transition

Practical context

By modeling awareness, inquiries, proposals, won orders, and lost opportunities as states, you can predict future order volumes and bottlenecks.

Modeling approach

Treat orders won and orders lost as absorbing states, then repeatedly apply the transition matrix. The other stages may include backward transitions and periods with no progress.

Check with Python

[IN: 12]
f_states = ["cognition", "inquiry", "proposal", "Order received", "Lost bet"]
P_f = np.array(
    [
        [0.70, 0.18, 0, 0, 0.12],
        [0, 0.55, 0.30, 0, 0.15],
        [0, 0.05, 0.50, 0.28, 0.17],
        [0, 0, 0, 1, 0],
        [0, 0, 0, 0, 1],
    ]
)
initial = np.array([1000, 0, 0, 0, 0.0])
funnel = []
for k in range(9):
    funnel.append(
        {"Period": k, **dict(zip(f_states, initial @ np.linalg.matrix_power(P_f, k)))}
    )
funnel = pd.DataFrame(funnel)
display(funnel.style.format({s: "{:.1f}" for s in f_states}))
fig, ax = plt.subplots()
for s in f_states:
    ax.plot(funnel["Period"], funnel[s], marker="o", label=s)
ax.set_title("Forecasting the state transition of the purchase funnel")
ax.set_xlabel("Future Period")
ax.set_ylabel("Number of Expected Projects")
ax.grid(True, alpha=0.3)
ax.legend()
plt.tight_layout()
plt.show()
[OUT: 12]
  Period cognition inquiry proposal Order received Lost bet
0 0 1000.0 0.0 0.0 0.0 0.0
1 1 700.0 180.0 0.0 0.0 120.0
2 2 490.0 225.0 54.0 0.0 231.0
3 3 343.0 214.7 94.5 15.1 332.7
4 4 240.1 184.5 111.6 41.6 422.2
5 5 168.1 150.3 111.2 72.8 497.6
6 6 117.6 118.5 100.7 104.0 559.2
7 7 82.4 91.4 85.9 132.2 608.2
8 8 57.6 69.4 70.4 156.2 646.4

svg

Interpreting the results

Over time, opportunities accumulate in the won and lost states. Compare how a higher proposal-to-order transition probability changes the final number of orders.


No.080: Using State Transition Models for Policy Evaluation

Practical context

When the transition probability is changed during preventive maintenance, future failures, downtime losses, and maintenance costs are compared.

Modeling approach

Project 26 weeks using a baseline matrix estimated from records without preventive maintenance and a policy matrix with higher recovery probabilities. “Current” in the table denotes this no-preventive-maintenance baseline, not the opening policy that maintains abnormal machines with 55% probability. Approximate costs as cumulative machine-weeks in failure × ¥1.5 million plus additional maintenance cost; one machine failed for two weeks counts as two machine-weeks.

Check with Python

[IN: 13]
P_policy = P_hat.to_numpy().copy()
P_policy[1] = [0.30, 0.62, 0.07, 0.01]
P_policy[2] = [0.55, 0.30, 0.12, 0.03]
pi = np.array([0.80, 0.15, 0.04, 0.01])
rows = []
for name, P, maint_cost in [
    ("Current Status", P_hat.to_numpy(), 0),
    ("Strengthening preventive maintenance", P_policy, 6_500_000),
]:
    dist = pi.copy()
    failure_weeks = 0
    for _ in range(26):
        dist = dist @ P
        failure_weeks += dist[3] * 60
    loss = failure_weeks * 1_500_000 + maint_cost
    rows.append(
        {
            "policy": name,
            "Normal machines at week 26": dist[0] * 60,
            "Failed machines at week 26": dist[3] * 60,
            "Cumulative failed machine-weeks": failure_weeks,
            "Maintenance cost": maint_cost,
            "Total expected cost": loss,
        }
    )
policy = pd.DataFrame(rows)
display(
    policy.style.format(
        {
            "Normal machines at week 26": "{:.1f}",
            "Failed machines at week 26": "{:.1f}",
            "Cumulative failed machine-weeks": "{:.1f}",
            "Maintenance cost": "¥{:,.0f}",
            "Total expected cost": "¥{:,.0f}",
        }
    )
)
fig, axes = plt.subplots(1, 2, figsize=(11, 4.2))
axes[0].bar(
    policy["policy"], policy["Failed machines at week 26"], color="#de2d26"
)
axes[0].set_title("Expected machines in failure at week 26")
axes[0].set_xlabel("policy")
axes[0].set_ylabel("Expected machines in failure")
axes[0].grid(True, axis="y", alpha=0.3)
axes[1].bar(policy["policy"], policy["Total expected cost"] / 1e6, color="#2c7fb8")
axes[1].set_title("Total expected cost by policy")
axes[1].set_xlabel("policy")
axes[1].set_ylabel("Expected cost (million JPY / 26 weeks)")
axes[1].grid(True, axis="y", alpha=0.3)
plt.tight_layout()
plt.show()
print(
    f"Expected cost savings: ¥{policy.loc[0,'Total expected cost']-policy.loc[1,'Total expected cost']:,.0f}"
)
[OUT: 13]
  policy Normal machines at week 26 Failed machines at week 26 Cumulative failed machine-weeks Maintenance cost Total expected cost
0 Current Status 42.9 2.4 59.6 ¥0 ¥89,474,389
1 Strengthening preventive maintenance 48.4 0.7 17.8 ¥6,500,000 ¥33,155,592

svg

Expected cost savings: ¥56,318,797

Interpreting the results

Enhanced preventive maintenance increases maintenance costs but may reduce downtime weeks and total expected costs. Sensitivity analysis is performed on the estimation error of transition probabilities, and small-scale verification is conducted on-site.


Practical lessons

State variables are information carried over between time points. The transition matrix simultaneously represents deterioration, recovery, and continuation, and future configurations can be predicted using matrix powers. Equipment, customers, inventory, and sales can be handled with the same concept, but it is necessary to check state definitions, absorbing states, historical dependence, and policy selection bias.

Preparing for practical use

1. Standardize state definitions and determination times

Define observable rules for normal, cautionary, abnormal, operational, and dormant status.

2. Maintain history with individual ID

Use stable identifiers to link observations of each machine, customer, item, and opportunity across time.

3. Check the number of transitions and uncertainty

Treat estimates from rare states cautiously; report confidence intervals and define an update schedule.

4. Incorporate history dependencies into state

Abnormal continuation weeks, elapsed months for customers, and days after maintenance are added to the status as needed.

5. Causally verify the effectiveness of the measures

Considering biases in maintenance target selection, verification is conducted through comparison groups and phased introductions.

6. Connect to Costs and Constraints

Compare the costs of failures, customer churn, stockouts, and lost orders with the cost of each intervention.

Conclusion

No.071–080 represent equipment, customers, inventory, and purchasing funnels as state transitions, connecting transition probabilities, Markov predictions, and evaluations of maintenance and churn-prevention policies. It is important not only to see the current number of cases but also to see how quickly the condition worsens or recovers.

Support for businesses

At Surikobo, we support transition analysis of equipment states, customer churn, inventory status, sales funnel transitions, preventive maintenance, policy evaluation, and operational design of condition KPIs.

📩 Contact Us: www.surikobo.co.jp/contact Please feel free to consult us first.