92 const std::vector<double>& probs,
const std::vector<double>& t) {
93 const std::size_t E = arcs.size(), nt = t.size();
96 out.
Fhold.assign(nt, 0.0);
97 std::vector<std::size_t> live;
98 for (std::size_t h = 0; h < E; ++h)
99 if (!arcs[h].disabled) live.push_back(h);
100 if (nt == 0 || live.empty())
return out;
101 if (!probs.empty()) {
102 if (probs.size() != E)
103 throw InputError(
"smp_stage_cif: the kernel probabilities need one entry per arc");
104 for (std::size_t h : live) {
106 for (std::size_t j = 0; j < nt; ++j) {
107 out.
C(h, j) = probs[h] * Fh[j];
108 out.
Fhold[j] += probs[h] * Fh[j];
113 std::size_t npre = 0;
114 std::vector<double> g;
117 g.assign(pre.begin(), pre.end() - 1);
120 g.insert(g.end(), t.begin(), t.end());
121 const std::size_t ng = g.size(), nl = live.size();
122 std::vector<double> gm(ng - 1);
123 for (std::size_t j = 0; j + 1 < ng; ++j) gm[j] = (g[j] + g[j + 1]) / 2.0;
124 std::vector<std::vector<double>> F(nl), Fm(nl);
125 for (std::size_t k = 0; k < nl; ++k) {
129 for (std::size_t k = 0; k < nl; ++k) {
131 for (std::size_t j = 1; j < ng; ++j) {
133 for (std::size_t q = 0; q < nl; ++q)
134 if (q != k) Sother *= 1.0 - Fm[q][j - 1];
135 acc += (F[k][j] - F[k][j - 1]) * Sother;
136 if (j >= npre) out.
C(live[k], j - npre) = acc;
139 for (std::size_t j = 0; j < nt; ++j) {
141 for (std::size_t k = 0; k < nl; ++k) S *= 1.0 - F[k][npre + j];
142 out.
Fhold[j] = 1.0 - S;
std::vector< double > linspace(double a, double b, std::size_t n)
linspace(a, b, n), with the last point exactly b.
std::vector< double > cdf_row(const lang::Distrib< T > &d, const std::vector< double > &t)
The CDF of d at every instant of t, clamped to [0, 1] (cdfRow).
SmpStageCif smp_stage_cif(const std::vector< lang::Distrib< T > > &arcs, const std::vector< double > &probs, const std::vector< double > &t)
CIF and holding-time CDF of a stage at the ascending instants t.