Invert the CDF defined by (t, w) at the points specified by u in [0, 1).
(u, t, w_logits)
| 152 | |
| 153 | |
| 154 | def invert_cdf(u, t, w_logits): |
| 155 | """Invert the CDF defined by (t, w) at the points specified by u in [0, 1).""" |
| 156 | # Compute the PDF and CDF for each weight vector. |
| 157 | w = torch.softmax(w_logits, dim=-1) |
| 158 | cw = integrate_weights(w) |
| 159 | # Interpolate into the inverse CDF. |
| 160 | t_new = math.sorted_interp(u, cw, t) |
| 161 | return t_new |
| 162 | |
| 163 | |
| 164 | def invert_cdf_np(u, t, w_logits): |
no test coverage detected