ctbn.computeCIMFromStats

pyagrum.ctbn.computeCIMFromStats(X, M, T)

Computes a CIM (Conditional Intensity Matrix) using stats from a trajectory. Variables in the tensor are not copied but directly used in the result to avoid memory issues.

Parameters:
  • X (str) – Name of the variable to compute CIM for.

  • M (pyagrum.Tensor) – Tensor containing the number of transitions for each pair of X’s states.

  • T (pyagrum.Tensor) – Tensor containing the time spent to transition from every state of X.

Returns:

The resulting tensor, X’s CIM.

Return type:

pyagrum.Tensor

Example

import pyagrum.ctbn as ct

data = {
  0: [
    (0.0, "A", "a0"),
    (0.0, "B", "b0"),
    (1.0, "A", "a0"),
    (2.0, "B", "b0"),
    (3.0, "A", "a1"),
    (4.0, "A", "a0"),
    (4.0, "B", "b1"),
  ]
}
T, M = ct.Trajectory(data).computeStats("A", [])
cim = ct.computeCIMFromStats("A", M, T)
print(cim)
#
#       ║  A#j              │
# A#i   ║a0       │a1       │
# ──────║─────────│─────────│
# a0    ║ -0.5000 │ 0.5000  │
# a1    ║ 0.5000  │ -0.5000 │