class_docstr: Multinomial distribution for categorical data.
  
  Parameters
  ----------
  events
      An optional list of events that already occurred.
  seed
      Random number generator seed for reproducibility.
  
  Examples
  --------
  
  >>> from river import proba
  
  >>> p = proba.Multinomial(['green'] * 3)
  >>> p.update('red')
  >>> p('red')
  0.25
  
  >>> p.update('red')
  >>> p.update('red')
  >>> p('green')
  0.5
  
  >>> p.revert('red')
  >>> p.revert('red')
  >>> p('red')
  0.25
  
  You can wrap this with a `utils.Rolling` to measure a distribution over a window:
  
  >>> from river import utils
  
  >>> X = ['red', 'green', 'green', 'blue', 'blue']
  
  >>> dist = utils.Rolling(
  ...     proba.Multinomial(),
  ...     window_size=3
  ... )
  
  >>> for x in X:
  ...     dist.update(x)
  ...     print(dist)
  ...     print()
  P(red) = 1.000
  <BLANKLINE>
  P(red) = 0.500
  P(green) = 0.500
  <BLANKLINE>
  P(green) = 0.667
  P(red) = 0.333
  <BLANKLINE>
  P(green) = 0.667
  P(blue) = 0.333
  P(red) = 0.000
  <BLANKLINE>
  P(blue) = 0.667
  P(green) = 0.333
  P(red) = 0.000
  <BLANKLINE>
  
  You can wrap this with a `utils.Rolling` to measure a distribution over a window of time:
  
  >>> import datetime as dt
  
  >>> X = ['red', 'green', 'green', 'blue']
  >>> days = [1, 2, 3, 4]
  
  >>> dist = utils.TimeRolling(
  ...     proba.Multinomial(),
  ...     period=dt.timedelta(days=2)
  ... )
  
  >>> for x, day in zip(X, days):
  ...     dist.update(x, t=dt.datetime(2019, 1, day))
  ...     print(dist)
  ...     print()
  P(red) = 1.000
  <BLANKLINE>
  P(red) = 0.500
  P(green) = 0.500
  <BLANKLINE>
  P(green) = 1.000
  P(red) = 0.000
  <BLANKLINE>
  P(green) = 0.500
  P(blue) = 0.500
  P(red) = 0.000
  <BLANKLINE>
class_docstr_tok: ["Multinomial","distribution","for","categorical","data",".","Parameters","--","--","--","--","--","events","An","optional","list","of","events","that","already","occurred",".","seed","Random","number","generator","seed","for","reproducibility",".","Examples","--","--","--","--",">",">",">","from","river","import","proba",">",">",">","p","=","proba.Multinomial","(","[","'green","'","]","*","3",")",">",">",">","p.update","(","'red","'",")",">",">",">","p","(","'red","'",")","0.25",">",">",">","p.update","(","'red","'",")",">",">",">","p.update","(","'red","'",")",">",">",">","p","(","'green","'",")","0.5",">",">",">","p.revert","(","'red","'",")",">",">",">","p.revert","(","'red","'",")",">",">",">","p","(","'red","'",")","0.25","You","can","wrap","this","with","a","`","utils.Rolling","`","to","measure","a","distribution","over","a","window",":",">",">",">","from","river","import","utils",">",">",">","X","=","[","'red","'",",","'green","'",",","'green","'",",","'blue","'",",","'blue","'","]",">",">",">","dist","=","utils.Rolling","(","...","proba.Multinomial","(",")",",","...","window_size=3","...",")",">",">",">","for","x","in","X",":","...","dist.update","(","x",")","...","print","(","dist",")","...","print","(",")","P","(","red",")","=","1.000","<","BLANKLINE",">","P","(","red",")","=","0.500","P","(","green",")","=","0.500","<","BLANKLINE",">","P","(","green",")","=","0.667","P","(","red",")","=","0.333","<","BLANKLINE",">","P","(","green",")","=","0.667","P","(","blue",")","=","0.333","P","(","red",")","=","0.000","<","BLANKLINE",">","P","(","blue",")","=","0.667","P","(","green",")","=","0.333","P","(","red",")","=","0.000","<","BLANKLINE",">","You","can","wrap","this","with","a","`","utils.Rolling","`","to","measure","a","distribution","over","a","window","of","time",":",">",">",">","import","datetime","as","dt",">",">",">","X","=","[","'red","'",",","'green","'",",","'green","'",",","'blue","'","]",">",">",">","days","=","[","1",",","2",",","3",",","4","]",">",">",">","dist","=","utils.TimeRolling","(","...","proba.Multinomial","(",")",",","...","period=dt.timedelta","(","days=2",")","...",")",">",">",">","for","x",",","day","in","zip","(","X",",","days",")",":","...","dist.update","(","x",",","t=dt.datetime","(","2019",",","1",",","day",")",")","...","print","(","dist",")","...","print","(",")","P","(","red",")","=","1.000","<","BLANKLINE",">","P","(","red",")","=","0.500","P","(","green",")","=","0.500","<","BLANKLINE",">","P","(","green",")","=","1.000","P","(","red",")","=","0.000","<","BLANKLINE",">","P","(","green",")","=","0.500","P","(","blue",")","=","0.500","P","(","red",")","=","0.000","<","BLANKLINE",">"]
code: def __iter__(self):
      return iter(self.counts)
  
file_path: river/river/proba/multinomial.py
imports: from __future__ import annotations
  import collections
  import typing
  from river.proba import base
label_desc: Use image node_id 3 for calling the Multinomial obj's underlying member method code with example usage: obj.__iter__() and returns: iter