MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / interval_distortion

Function interval_distortion

utils/stepfun.py:310–326  ·  view source on GitHub ↗

Compute mean(abs(x-y); x in [t0_lo, t0_hi], y in [t1_lo, t1_hi]).

(t0_lo, t0_hi, t1_lo, t1_hi)

Source from the content-addressed store, hash-verified

308
309
310def interval_distortion(t0_lo, t0_hi, t1_lo, t1_hi):
311 """Compute mean(abs(x-y); x in [t0_lo, t0_hi], y in [t1_lo, t1_hi])."""
312 # Distortion when the intervals do not overlap.
313 d_disjoint = torch.abs((t1_lo + t1_hi) / 2 - (t0_lo + t0_hi) / 2)
314
315 # Distortion when the intervals overlap.
316 d_overlap = (2 *
317 (torch.minimum(t0_hi, t1_hi) ** 3 - torch.maximum(t0_lo, t1_lo) ** 3) +
318 3 * (t1_hi * t0_hi * torch.abs(t1_hi - t0_hi) +
319 t1_lo * t0_lo * torch.abs(t1_lo - t0_lo) + t1_hi * t0_lo *
320 (t0_lo - t1_hi) + t1_lo * t0_hi *
321 (t1_lo - t0_hi))) / (6 * (t0_hi - t0_lo) * (t1_hi - t1_lo))
322
323 # Are the two intervals not overlapping?
324 are_disjoint = (t0_lo > t1_hi) | (t1_lo > t0_hi)
325
326 return torch.where(are_disjoint, d_disjoint, d_overlap)
327
328
329def weighted_percentile(t, w, ps):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected