1function Prob = getProb(self, node, state)
2% PROB = GETPROB(NODE, STATE)
3% Steady-state marginal state probability at a node, estimated as
the
4% time-weighted fraction of
the simulated trajectory spent in STATE. Fully
5% JSON-mediated (via sample()). Mirrors
the Python-native getProb().
7% If STATE
is omitted,
the model
's current state for the node is used. Returns
8% 0 if the state is not observed during the simulation.
13if GlobalConstants.DummyMode
18sampleResult = self.sample(node, 0);
19if isempty(sampleResult) || ~isstruct(sampleResult) || isempty(sampleResult.t)
25stateMatrix = sampleResult.state;
27if nt < 2 || isempty(stateMatrix)
32sn = self.model.getStruct;
39 isf = sn.nodeToStateful(nodeIdx);
40 if iscell(sn.state) && numel(sn.state) >= isf && ~isempty(sn.state{isf})
41 state = sn.state{isf};
43 state = zeros(1, size(stateMatrix, 2));
47L = min(numel(target), size(stateMatrix, 2));
59 if all(abs(stateMatrix(ti, 1:L) - target) < 1e-10)
60 timeInState = timeInState + dt;
63Prob = timeInState / total;