KTBNInference.makeInference

KTBNInference.makeInference(nbTimeSlices)

Run the interface algorithm over nbTimeSlices slices (0..nbTimeSlices-1) and cache, for every targeted base, its marginal at every slice. Idempotent, and called lazily by posterior()/posteriors() (with the last horizon) whenever their cache is out of date. Observations and interventions at slices nbTimeSlices or later are ignored.

Parameters:

nbTimeSlices (int) – the horizon: number of time slices to compute

Raises:
Return type:

None

Example

import pyagrum as gum
import pyagrum.ktbn as ktbn

model = ktbn.KTBN.fromBN(gum.fastBN("X0->X1"))
model.cpt("X", 0).fillWith([0.5, 0.5])
model.cpt("X", 1).fillWith([0.9, 0.1, 0.2, 0.8])  # P(X[t] | X[t-1])
ie = ktbn.KTBNInference(model)
ie.makeInference(10)  # slices 0..9
len(ie.posteriors("X"))
# 10
print(ie.posterior("X", 9))
#
#   X[9]             │
# 0        │1        │
# ─────────│─────────│
#  0.6599  │ 0.3401  │

Class

KTBNInference