2024-05-04

Author

Witek ten Hove

Phase-Type Distributions: A Comprehensive Tutorial

Read Kuiper et al. (2023)

Slides

Tutorial on Phase-Type Distributions

Chapter 1: Introduction to Phase-Type (PH) Distributions

Phase-Type distributions are an essential tool in stochastic modeling, allowing for the representation of a vast array of processes. They are defined by a continuous-time Markov chain (CTMC) that includes one absorbing state, making them flexible for modeling time until absorption in systems.

Python Example: CTMC Visualization

We’ll start by visualizing a simple CTMC that can be represented as a Phase-Type distribution. Here’s how you can set up a basic model in Python using the Plotly library:

import numpy as np
import plotly.graph_objects as go

# Define the states and transition rates
states = ['1', '2', '3', 'Absorbing']
rate_matrix = np.array([
    [-4, 4, 0, 0],
    [4, -7, 2, 1],
    [2, 3, -5, 0],
    [0, 0, 0, 0]
])

# Create a heatmap for the transition rate matrix
fig = go.Figure(data=go.Heatmap(
        z=rate_matrix,
        x=states,
        y=states,
        hoverongaps = False,
        colorscale='Viridis'))

fig.update_layout(
    title='CTMC Transition Rate Matrix',
    xaxis_title='To State',
    yaxis_title='From State'
)

fig.show()

Chapter 2: Transient Analysis in CTMCs

Transient analysis involves calculating state probabilities over time, which is crucial for understanding system dynamics before reaching absorption.

Python Example: Computing Transient Probabilities

Let’s calculate and plot the transient probabilities for our CTMC model using Python:

from scipy.linalg import expm
import plotly.graph_objects as go

# Initial state probabilities
pi_0 = np.array([0.9, 0.0, 0.1, 0.0])

# Time points to evaluate
times = np.linspace(0, 15, 100)
probabilities = np.array([pi_0.dot(expm(rate_matrix * t)) for t in times])

# Plotting
fig = go.Figure()
for i, state in enumerate(states):
    fig.add_trace(go.Scatter(x=times, y=probabilities[:, i], mode='lines', name=f'State {state}'))

fig.update_layout(
    title='Transient Probabilities Over Time',
    xaxis_title='Time',
    yaxis_title='Probability',
    legend_title='State'
)
fig.show()

Chapter 3: Understanding Absorption in PH Distributions

A fundamental property of PH distributions is the time until the process is absorbed into the terminal state. This concept is critical for applications like network traffic modeling and job completion times in queueing networks.

Python Example: Plotting Absorption Probabilities

We will visualize the probability of being absorbed over time:

# Modify the previous probabilities calculation for only the absorbing state
absorption_probabilities = np.array([pi_0.dot(expm(rate_matrix * t))[-1] for t in times])

# Plotting
fig = go.Figure()
fig.add_trace(go.Scatter(x=times, y=absorption_probabilities, mode='lines', name='Absorption Probability'))

fig.update_layout(
    title='Probability of Absorption Over Time',
    xaxis_title='Time',
    yaxis_title='Probability'
)
fig.show()

This tutorial is designed to provide an introductory overview. For a deeper dive into each concept, including more complex models and their applications, please refer to detailed academic resources or specific case studies in your field of interest.

References

Kuiper, Alex, Michel Mandjes, Jeroen de Mast, and Ruben Brokkelkamp. 2023. “A Flexible and Optimal Approach for Appointment Scheduling in Healthcare.” Decision Sciences 54 (1): 85–100. https://doi.org/https://doi.org/10.1111/deci.12517.