code: def addobs(self, w, r, p_drop=0, n_drop=None):
      assert w >= 0
      assert 0 <= p_drop < 1
      assert n_drop is None or n_drop >= 0
  
      if not self.adjust:
          r = min(self.rmax, max(self.rmin, r))
      else:
          self.rmin = min(self.rmin, r)
          self.rmax = max(self.rmax, r)
  
      if n_drop is None:
          n_drop = p_drop / (1 - p_drop)
  
      if n_drop > 0:
          import scipy.special as sc
  
          # we have to simulate presenting n_drop events with w=0 in a row, which we can do in closed form
          # Sum[(a/(b + s))^2, { s, 0, n - 1 }]
          # a^2 PolyGamma[1,b]-a^2 PolyGamma[1,b+n]
  
          sumXlow = (
              float(self.sumwr) - float(self.sumw) * self.rmin
          ) / (self.rmax - self.rmin)
          alow = sumXlow + 1 / 2
          blow = self.t + 1
          self.sumxhatlowsq += alow**2 * (
              sc.polygamma(1, blow).item()
              - sc.polygamma(1, blow + n_drop).item()
          )
  
          sumXhigh = (
              float(self.sumw) * self.rmax - float(self.sumwr)
          ) / (self.rmax - self.rmin)
          ahigh = sumXhigh + 1 / 2
          bhigh = self.t + 1
          self.sumxhathighsq += ahigh**2 * (
              sc.polygamma(1, bhigh).item()
              - sc.polygamma(1, bhigh + n_drop).item()
          )
  
          self.t += n_drop
  
      sumXlow = (float(self.sumwr) - float(self.sumw) * self.rmin) / (
          self.rmax - self.rmin
      )
      Xhatlow = (sumXlow + 1 / 2) / (self.t + 1)
      sumXhigh = (float(self.sumw) * self.rmax - float(self.sumwr)) / (
          self.rmax - self.rmin
      )
      Xhathigh = (sumXhigh + 1 / 2) / (self.t + 1)
  
      w /= 1 - p_drop
  
      self.sumwsqrsq += (w * r) ** 2
      self.sumwsqr += w**2 * r
      self.sumwsq += w**2
      self.sumwr += w * r
      self.sumw += w
      self.sumwrxhatlow += w * r * Xhatlow
      self.sumwxhatlow += w * Xhatlow
      self.sumxhatlowsq += Xhatlow**2
      self.sumwrxhathigh += w * r * Xhathigh
      self.sumwxhathigh += w * Xhathigh
      self.sumxhathighsq += Xhathigh**2
  
      self.t += 1
  
file_path: vowpal_wabbit/python/tests/confidence_sequence.py
imports: from cmath import sqrt
label_desc: Use image node_id 2 for calling the confidence_sequence obj's underlying member method code with example usage: obj.addobs(w, r, p_drop, n_drop) without return types