import numpy as np
import plotly.graph_objects as go
# Define the states and transition rates
= ['1', '2', '3', 'Absorbing']
states = np.array([
rate_matrix -4, 4, 0, 0],
[4, -7, 2, 1],
[2, 3, -5, 0],
[0, 0, 0, 0]
[
])
# Create a heatmap for the transition rate matrix
= go.Figure(data=go.Heatmap(
fig =rate_matrix,
z=states,
x=states,
y= False,
hoverongaps ='Viridis'))
colorscale
fig.update_layout(='CTMC Transition Rate Matrix',
title='To State',
xaxis_title='From State'
yaxis_title
)
fig.show()
2024-05-04
Phase-Type Distributions: A Comprehensive Tutorial
Read Kuiper et al. (2023)
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:
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
= np.array([0.9, 0.0, 0.1, 0.0])
pi_0
# Time points to evaluate
= np.linspace(0, 15, 100)
times = np.array([pi_0.dot(expm(rate_matrix * t)) for t in times])
probabilities
# Plotting
= go.Figure()
fig for i, state in enumerate(states):
=times, y=probabilities[:, i], mode='lines', name=f'State {state}'))
fig.add_trace(go.Scatter(x
fig.update_layout(='Transient Probabilities Over Time',
title='Time',
xaxis_title='Probability',
yaxis_title='State'
legend_title
) 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
= np.array([pi_0.dot(expm(rate_matrix * t))[-1] for t in times])
absorption_probabilities
# Plotting
= go.Figure()
fig =times, y=absorption_probabilities, mode='lines', name='Absorption Probability'))
fig.add_trace(go.Scatter(x
fig.update_layout(='Probability of Absorption Over Time',
title='Time',
xaxis_title='Probability'
yaxis_title
) 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.