class_docstr: Running quantile.
  
  Uses the P² algorithm, which is also known as the "Piecewise-Parabolic quantile estimator".
  The code is inspired by LiveStat's implementation [^2].
  
  Parameters
  ----------
  q
      Determines which quantile to compute, must be comprised between 0 and 1.
  
  Examples
  --------
  
  >>> from river import stats
  >>> import numpy as np
  
  >>> np.random.seed(42 * 1337)
  >>> mu, sigma = 0, 1
  >>> s = np.random.normal(mu, sigma, 500)
  
  >>> median = stats.Quantile(0.5)
  >>> for x in s:
  ...    _ = median.update(x)
  >>> print(f'The estimated value of the 50th (median) quantile is {median.get():.4f}')
  The estimated value of the 50th (median) quantile is -0.0275
  
  >>> print(f'The real value of the 50th (median) quantile is {np.median(s):.4f}')
  The real value of the 50th (median) quantile is -0.0135
  
  >>> percentile_17 = stats.Quantile(0.17)
  >>> for x in s:
  ...    _ = percentile_17.update(x)
  >>> print(f'The estimated value of the 17th quantile is {percentile_17.get():.4f}')
  The estimated value of the 17th quantile is -0.8652
  
  >>> print(f'The real value of the 17th quantile is {np.percentile(s,17):.4f}')
  The real value of the 17th quantile is -0.9072
  
  References
  ----------
  [^1]: [The P² Algorithm for Dynamic Univariateal Computing Calculation of Quantiles and Editor Histograms Without Storing Observations](https://www.cse.wustl.edu/~jain/papers/ftp/psqr.pdf)
  [^2]: [LiveStats](https://github.com/cxxr/LiveStats)
  [^3]: [P² quantile estimator: estimating the median without storing values](https://aakinshin.net/posts/p2-quantile-estimator/)
class_docstr_tok: ["Running","quantile",".","Uses","the","P\u00b2","algorithm",",","which","is","also","known","as","the","``","Piecewise-Parabolic","quantile","estimator","''",".","The","code","is","inspired","by","LiveStat","'s","implementation","[","^2","]",".","Parameters","--","--","--","--","--","q","Determines","which","quantile","to","compute",",","must","be","comprised","between","0","and","1",".","Examples","--","--","--","--",">",">",">","from","river","import","stats",">",">",">","import","numpy","as","np",">",">",">","np.random.seed","(","42","*","1337",")",">",">",">","mu",",","sigma","=","0",",","1",">",">",">","s","=","np.random.normal","(","mu",",","sigma",",","500",")",">",">",">","median","=","stats.Quantile","(","0.5",")",">",">",">","for","x","in","s",":","...","_","=","median.update","(","x",")",">",">",">","print","(","f'The","estimated","value","of","the","50th","(","median",")","quantile","is","{","median.get","(",")",":",".4f","}","'",")","The","estimated","value","of","the","50th","(","median",")","quantile","is","-0.0275",">",">",">","print","(","f'The","real","value","of","the","50th","(","median",")","quantile","is","{","np.median","(","s",")",":",".4f","}","'",")","The","real","value","of","the","50th","(","median",")","quantile","is","-0.0135",">",">",">","percentile_17","=","stats.Quantile","(","0.17",")",">",">",">","for","x","in","s",":","...","_","=","percentile_17.update","(","x",")",">",">",">","print","(","f'The","estimated","value","of","the","17th","quantile","is","{","percentile_17.get","(",")",":",".4f","}","'",")","The","estimated","value","of","the","17th","quantile","is","-0.8652",">",">",">","print","(","f'The","real","value","of","the","17th","quantile","is","{","np.percentile","(","s,17",")",":",".4f","}","'",")","The","real","value","of","the","17th","quantile","is","-0.9072","References","--","--","--","--","--","[","^1","]",":","[","The","P\u00b2","Algorithm","for","Dynamic","Univariateal","Computing","Calculation","of","Quantiles","and","Editor","Histograms","Without","Storing","Observations","]","(","https",":","\/\/www.cse.wustl.edu\/~jain\/papers\/ftp\/psqr.pdf",")","[","^2","]",":","[","LiveStats","]","(","https",":","\/\/github.com\/cxxr\/LiveStats",")","[","^3","]",":","[","P\u00b2","quantile","estimator",":","estimating","the","median","without","storing","values","]","(","https",":","\/\/aakinshin.net\/posts\/p2-quantile-estimator\/",")"]
code: def __init__(self, q: float = 0.5):
      super().__init__()
      if not 0 < q < 1:
          raise ValueError("q is not comprised between 0 and 1")
      self._quantile = _rust_stats.RsQuantile(q)
      self._is_updated = False
      self.q = q
  
file_path: river/river/stats/quantile.py
imports: from __future__ import annotations
  from river import stats
  from river.stats import _rust_stats
label_desc: Use image node_id 1 to create a new Quantile object from inherited base classes: stats.base with example: obj = Quantile(q)