class_docstr: Running variance using Welford's algorithm.
  
  Parameters
  ----------
  ddof
      Delta Degrees of Freedom. The divisor used in calculations is `n - ddof`, where `n`
      represents the number of seen elements.
  
  Attributes
  ----------
  mean
      It is necessary to calculate the mean of the data in order to calculate its variance.
  
  Notes
  -----
  The outcomes of the incremental and parallel updates are consistent with numpy's
  batch processing when $\text{ddof} \le 1$.
  
  Examples
  --------
  
  >>> from river import stats
  
  >>> X = [3, 5, 4, 7, 10, 12]
  
  >>> var = stats.Var()
  >>> for x in X:
  ...     var.update(x)
  ...     print(var.get())
  0.0
  2.0
  1.0
  2.916666
  7.7
  12.56666
  
  You can measure a rolling variance by using a `utils.Rolling` wrapper:
  
  >>> from river import utils
  
  >>> X = [1, 4, 2, -4, -8, 0]
  >>> rvar = utils.Rolling(stats.Var(ddof=1), window_size=3)
  >>> for x in X:
  ...     rvar.update(x)
  ...     print(rvar.get())
  0.0
  4.5
  2.333333
  17.333333
  25.333333
  16.0
  
  References
  ----------
  [^1]: [Wikipedia article on algorithms for calculating variance](https://www.wikiwand.com/en/Algorithms_for_calculating_variance#/Covariance)
  [^2]: [Chan, T.F., Golub, G.H. and LeVeque, R.J., 1983. Algorithms for computing the sample variance: Analysis and recommendations. The American Statistician, 37(3), pp.242-247.](https://amstat.tandfonline.com/doi/abs/10.1080/00031305.1983.10483115)
  [^3]: Schubert, E. and Gertz, M., 2018, July. Numerically stable parallel computation of
  (co-)variance. In Proceedings of the 30th International Conference on Scientific and
  Statistical Database Management (pp. 1-12).
class_docstr_tok: ["Running","variance","using","Welford","'s","algorithm",".","Parameters","--","--","--","--","--","ddof","Delta","Degrees","of","Freedom",".","The","divisor","used","in","calculations","is","`","n","-","ddof","`",",","where","`","n","`","represents","the","number","of","seen","elements",".","Attributes","--","--","--","--","--","mean","It","is","necessary","to","calculate","the","mean","of","the","data","in","order","to","calculate","its","variance",".","Notes","--","--","-","The","outcomes","of","the","incremental","and","parallel","updates","are","consistent","with","numpy's","batch","processing","when","$","\\text","{","ddof","}","\\le","1","$",".","Examples","--","--","--","--",">",">",">","from","river","import","stats",">",">",">","X","=","[","3",",","5",",","4",",","7",",","10",",","12","]",">",">",">","var","=","stats.Var","(",")",">",">",">","for","x","in","X",":","...","var.update","(","x",")","...","print","(","var.get","(",")",")","0.0","2.0","1.0","2.916666","7.7","12.56666","You","can","measure","a","rolling","variance","by","using","a","`","utils.Rolling","`","wrapper",":",">",">",">","from","river","import","utils",">",">",">","X","=","[","1",",","4",",","2",",","-4",",","-8",",","0","]",">",">",">","rvar","=","utils.Rolling","(","stats.Var","(","ddof=1",")",",","window_size=3",")",">",">",">","for","x","in","X",":","...","rvar.update","(","x",")","...","print","(","rvar.get","(",")",")","0.0","4.5","2.333333","17.333333","25.333333","16.0","References","--","--","--","--","--","[","^1","]",":","[","Wikipedia","article","on","algorithms","for","calculating","variance","]","(","https",":","\/\/www.wikiwand.com\/en\/Algorithms_for_calculating_variance","#","\/Covariance",")","[","^2","]",":","[","Chan",",","T.F.",",","Golub",",","G.H",".","and","LeVeque",",","R.J.",",","1983",".","Algorithms","for","computing","the","sample","variance",":","Analysis","and","recommendations",".","The","American","Statistician",",","37","(","3",")",",","pp.242-247",".","]","(","https",":","\/\/amstat.tandfonline.com\/doi\/abs\/10.1080\/00031305.1983.10483115",")","[","^3","]",":","Schubert",",","E.","and","Gertz",",","M.",",","2018",",","July",".","Numerically","stable","parallel","computation","of","(","co-",")","variance",".","In","Proceedings","of","the","30th","International","Conference","on","Scientific","and","Statistical","Database","Management","(","pp",".","1-12",")","."]
code: def __iadd__(self, other):
      S = (
          self._S
          + other._S
          + (self.mean.get() - other.mean.get()) ** 2
          * self.n
          * other.n
          / (self.n + other.n)
      )
      self.mean += other.mean
      self._S = S
      return self
  
file_path: river/river/stats/var.py
imports: from __future__ import annotations
  import copy
  import numpy
  from river import stats
label_desc: Use image node_id 8 for calling the Var obj's underlying member method code with example usage: obj.__iadd__(other) and returns: self