51 const std::vector<double>& probs) {
52 const std::size_t E = arcs.size();
55 std::vector<std::size_t> live;
56 for (std::size_t h = 0; h < E; ++h)
57 if (!arcs[h].disabled) live.push_back(h);
58 if (live.empty())
return out;
59 std::vector<double> mu(live.size(), 0.0);
60 for (std::size_t k = 0; k < live.size(); ++k) {
62 if (!(std::isfinite(mu[k]) && mu[k] > 0.0)) {
64 std::snprintf(buf,
sizeof buf,
"%g", mu[k]);
65 throw InputError(std::string(
"smp_stage_quad: the ") +
67 " law of the transition to stage " + std::to_string(live[k] + 1) +
69 ": a semi-Markov stage needs every transition law to have a finite "
74 for (std::size_t k = 0; k < live.size(); ++k) {
75 out.
P[live[k]] = probs[live[k]];
76 out.
m += probs[live[k]] * mu[k];
78 out.
U = *std::max_element(mu.begin(), mu.end());
81 const double mumax = *std::max_element(mu.begin(), mu.end());
82 const auto survival = [&](
double t) {
84 for (std::size_t h : live)
90 while (survival(U) > 1e-12 && U < 1e8 * mumax) U = 2.0 * U;
93 for (std::size_t k = 0; k < live.size(); ++k) {
95 g.insert(g.end(), gk.begin(), gk.end());
96 g.push_back(std::min(mu[k], U));
98 std::sort(g.begin(), g.end());
99 g.erase(std::unique(g.begin(), g.end()), g.end());
101 const std::size_t ng = g.size();
103 for (std::size_t h = 0; h < E; ++h) {
104 out.
P[h] = c.
C(h, ng - 1);
108 for (std::size_t h = 0; h < E; ++h) out.
P[h] /= tot;
109 std::vector<double> gm(ng - 1);
110 for (std::size_t j = 0; j + 1 < ng; ++j) gm[j] = (g[j] + g[j + 1]) / 2.0;
113 for (std::size_t j = 0; j + 1 < ng; ++j)
114 acc += ((1.0 - c.
Fhold[j]) + 4.0 * (1.0 - cm.
Fhold[j]) + (1.0 - c.
Fhold[j + 1])) *
std::vector< double > linspace(double a, double b, std::size_t n)
linspace(a, b, n), with the last point exactly b.
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.