code: def discretize(prv, domain: Domain) -> DiscretePRV:
      tC = domain.ts
      tL = tC - domain.dt / 2
      tR = tC + domain.dt / 2
      discrete_pmf = prv.cdf(tR) - prv.cdf(tL)
  
      mean_d = np.dot(domain.ts, discrete_pmf)
      mean_c = prv.mean()
  
      mean_shift = mean_c - mean_d
  
      if np.abs(mean_shift) >= domain.dt / 2:
          raise RuntimeError(
              "Discrete mean differs significantly from continuous mean."
          )
  
      domain_shifted = domain.shift_right(mean_shift)
  
      return DiscretePRV(pmf=discrete_pmf, domain=domain_shifted)
  
imports: from dataclasses import dataclass
  from typing import Tuple
  import numpy
  from scipy import integrate
  from scipy.special import erfc
  from ..rdp import _compute_rdp
  from .domain import Domain
label_desc: Use image node_id 1 for calling a global function with example usage: discretize(prv, domain) and returns: DiscretePRV