![]() |
primarycensored
|
Functions in this File | |
| real | pstep_lcdf (real t, vector boundaries, vector pmf) |
| vector | hazards_to_pmf (vector hazards) |
| real | phazard_lcdf (real t, vector boundaries, vector hazards) |
| vector | primary_lcdf_vec (vector p, int primary_id, array[] real primary_params, data real pwindow) |
| real | discretestep_lcdf (data real d, vector boundaries, vector pmf, int primary_id, array[] real primary_params, data real pwindow) |
| real | discretehazard_lcdf (data real d, vector boundaries, vector hazards, int primary_id, array[] real primary_params, data real pwindow) |
| real discretehazard_lcdf | ( | data real | d, |
| vector | boundaries, | ||
| vector | hazards, | ||
| int | primary_id, | ||
| array[]real | primary_params, | ||
| data real | pwindow ) |
Primary event censored log CDF for a discrete-hazard delay
Wrapper that converts hazards to a PMF and delegates to discretestep_lcdf. Provides the analytic CDF for dist_id == 27.
| d | Delay (observation point) |
| boundaries | Vector of K+1 step boundaries |
| hazards | Vector of K hazards in [0, 1] with hazards[K] = 1 |
| primary_id | Primary distribution identifier |
| primary_params | Primary distribution parameters |
| pwindow | Primary event window width |
Definition at line 211 of file nonparametric.stan.


| real discretestep_lcdf | ( | data real | d, |
| vector | boundaries, | ||
| vector | pmf, | ||
| int | primary_id, | ||
| array[]real | primary_params, | ||
| data real | pwindow ) |
Primary event censored log CDF for a step delay (vectorised analytic)
Computes log(F_obs(d)) where F_obs(d) = integral_q^d F_step(u) f_primary(d - u) du, q = d - pwindow. Using f_primary(d - u) du = -d F_primary(d - u), the integral on each sub-interval [lo, hi] where F_step is constant becomes cumulative * (F_primary(d - lo) - F_primary(d - hi)). The lo/hi/cumulative vectors are built in one pass; f_lo and f_hi come from two vectorised primary_lcdf_vec calls; an active mask zeros out empty sub-intervals; the per-bin contributions are reduced via dot_product. The tail [boundaries[K+1], d] (where F_step = 1) is added in a single closed-form term, no loop.
Boundary case: when the integration support lies entirely at or below boundaries[2] the only sub-interval that overlaps is bin 1 (with cum_before = 0) and the tail is empty, so the integral is structurally zero. We return negative_infinity() directly to keep log(0) off the autodiff tape; the value has no parameter dependence in this regime so the gradient is zero, and downstream log_diff_exp(a, -inf) evaluates cleanly to a.
| d | Delay (observation point) |
| boundaries | Vector of K+1 step boundaries |
| pmf | Step PMF of length K |
| primary_id | Primary distribution identifier |
| primary_params | Primary distribution parameters |
| pwindow | Primary event window width |
Definition at line 137 of file nonparametric.stan.


| vector hazards_to_pmf | ( | vector | hazards | ) |
Convert discrete hazards to a PMF
Each entry satisfies pmf[i] = hazards[i] * prod_{j < i} (1 - hazards[j]). The last hazard must equal 1 so the PMF sums to 1 (caller's responsibility). One log1m, one cumulative_sum, one exp – no per-bin loop on the autodiff tape.
| hazards | Vector of K hazards in [0, 1], with hazards[K] = 1 |
Definition at line 55 of file nonparametric.stan.

| real phazard_lcdf | ( | real | t, |
| vector | boundaries, | ||
| vector | hazards ) |
Log CDF of a discrete-hazard distribution
Sibling of pstep_lcdf for the hazard parameterisation; converts hazards to the implied PMF then dispatches to pstep_lcdf.
| t | Evaluation point |
| boundaries | Vector of K+1 boundaries (strictly increasing) |
| hazards | Vector of K hazards in [0, 1] with hazards[K] = 1 |
Definition at line 77 of file nonparametric.stan.


| vector primary_lcdf_vec | ( | vector | p, |
| int | primary_id, | ||
| array[]real | primary_params, | ||
| data real | pwindow ) |
Vectorised primary log CDF
Element-wise wrapper around primary_lcdf. Lets the analytic step convolution pull f_lo and f_hi out of one pair of vector calls without per-bin branching at the reduction site.
| p | Vector of primary event times in [0, pwindow] |
| primary_id | Primary distribution identifier |
| primary_params | Distribution parameters |
| pwindow | Primary event window width |
log(F_primary(p)) Definition at line 95 of file nonparametric.stan.


| real pstep_lcdf | ( | real | t, |
| vector | boundaries, | ||
| vector | pmf ) |
Non-parametric step CDF and hazard conversion utilities.
The step CDF is defined by K intervals and a PMF over those intervals. boundaries is a vector of length K+1 giving interval endpoints [boundaries[1], boundaries[2]), ..., [boundaries[K], boundaries[K+1]). pmf is a simplex of length K giving the probability mass in each interval. The hazard parameterisation replaces pmf with discrete hazards in [0, 1] whose final entry is 1 so the implied PMF sums to 1. Log CDF of a piecewise-constant (step) distribution
Vectorised PMF reduction via cumulative_sum. The bin-search index runs on data-level inputs (t, boundaries) and never appears on the autodiff tape, so a small data-only loop is kept here.
| t | Evaluation point |
| boundaries | Vector of K+1 interval endpoints (strictly increasing) |
| pmf | Simplex of K probabilities, one per interval (must sum to 1) |
Definition at line 28 of file nonparametric.stan.
