class_docstr: `Reducer` that computes a running R-hat diagnostic statistic.
  
  `PotentialScaleReductionReducer` assumes that all provided chain states
  include samples from multiple independent Markov chains, and that all of
  these chains are to be included in the same calculation.
  `PotentialScaleReductionReducer` also assumes that incoming samples have
  shape `[Ci1, Ci2,...,CiD] + A`. Dimensions `0` through `D - 1` index the
  `Ci1 x ... x CiD` independent chains to be tested for convergence to the
  same target. The remaining dimensions, `A`, represent the event shape and
  hence, can have any shape (even empty, which implies scalar samples). The
  number of independent chain dimensions is defined by the
  `independent_chain_ndims` parameter at initialization.
  
  As with all reducers, PotentialScaleReductionReducer does not hold state
  information; rather, it stores supplied metadata. Intermediate calculations
  are held in a state object, which is returned via `initialize` and `one_step`
  method calls.
  
  `PotentialScaleReductionReducer` is meant to fit into the larger Streaming
  MCMC framework. `RunningPotentialScaleReduction` in `tfp.experimental.stats`
  is better suited for more generic streaming R-hat needs. More precise
  algorithmic details can also be found by referencing
  `RunningPotentialScaleReduction`.
class_docstr_tok: ["`","Reducer","`","that","computes","a","running","R-hat","diagnostic","statistic",".","`","PotentialScaleReductionReducer","`","assumes","that","all","provided","chain","states","include","samples","from","multiple","independent","Markov","chains",",","and","that","all","of","these","chains","are","to","be","included","in","the","same","calculation",".","`","PotentialScaleReductionReducer","`","also","assumes","that","incoming","samples","have","shape","`","[","Ci1",",","Ci2",",","...",",","CiD","]","+","A","`",".","Dimensions","`","0","`","through","`","D","-","1","`","index","the","`","Ci1","x","...","x","CiD","`","independent","chains","to","be","tested","for","convergence","to","the","same","target",".","The","remaining","dimensions",",","`","A","`",",","represent","the","event","shape","and","hence",",","can","have","any","shape","(","even","empty",",","which","implies","scalar","samples",")",".","The","number","of","independent","chain","dimensions","is","defined","by","the","`","independent_chain_ndims","`","parameter","at","initialization",".","As","with","all","reducers",",","PotentialScaleReductionReducer","does","not","hold","state","information",";","rather",",","it","stores","supplied","metadata",".","Intermediate","calculations","are","held","in","a","state","object",",","which","is","returned","via","`","initialize","`","and","`","one_step","`","method","calls",".","`","PotentialScaleReductionReducer","`","is","meant","to","fit","into","the","larger","Streaming","MCMC","framework",".","`","RunningPotentialScaleReduction","`","in","`","tfp.experimental.stats","`","is","better","suited","for","more","generic","streaming","R-hat","needs",".","More","precise","algorithmic","details","can","also","be","found","by","referencing","`","RunningPotentialScaleReduction","`","."]
docstr: Instantiates this object.
  
  Args:
    independent_chain_ndims: Integer type `Tensor` with value `>= 1` giving
      the number of dimensions, from `dim = 1` to `dim = D`, holding
      independent chain results to be tested for convergence.
    name: Python `str` name prefixed to Ops created by this function.
      Default value: `None` (i.e., 'potential_scale_reduction_reducer').
  
  Raises:
    ValueError: if `independent_chain_ndims < 1`. This results in undefined
      intermediate variance calculations.
docstr_tok: ["Instantiates","this","object",".","Args",":","independent_chain_ndims",":","Integer","type","`","Tensor","`","with","value","`",">","=","1","`","giving","the","number","of","dimensions",",","from","`","dim","=","1","`","to","`","dim","=","D","`",",","holding","independent","chain","results","to","be","tested","for","convergence",".","name",":","Python","`","str","`","name","prefixed","to","Ops","created","by","this","function",".","Default","value",":","`","None","`","(","i.e.",",","'potential_scale_reduction_reducer","'",")",".","Raises",":","ValueError",":","if","`","independent_chain_ndims","<","1","`",".","This","results","in","undefined","intermediate","variance","calculations","."]
code: def __init__(self, independent_chain_ndims=1, name=None):
      """Instantiates this object.
  
      Args:
        independent_chain_ndims: Integer type `Tensor` with value `>= 1` giving
          the number of dimensions, from `dim = 1` to `dim = D`, holding
          independent chain results to be tested for convergence.
        name: Python `str` name prefixed to Ops created by this function.
          Default value: `None` (i.e., 'potential_scale_reduction_reducer').
  
      Raises:
        ValueError: if `independent_chain_ndims < 1`. This results in undefined
          intermediate variance calculations.
      """
      if independent_chain_ndims < 1:
          raise ValueError(
              "Must specify at least 1 dimension to represent"
              "independent Markov chains. Note, at least 2 parallel"
              "chains are required for well-defined between_chain"
              "variances"
          )
      self._parameters = dict(
          independent_chain_ndims=independent_chain_ndims,
          name=name or "potential_scale_reduction_reducer",
      )
  
file_path: probability/tensorflow_probability/python/experimental/mcmc/potential_scale_reduction_reducer.py
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.mcmc import reducer
  from tensorflow_probability.python.experimental.stats import sample_stats
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.mcmc.internal import util
label_desc: Use image node_id 1 to create a new PotentialScaleReductionReducer object from inherited base classes: reducer_base with example: obj = PotentialScaleReductionReducer(independent_chain_ndims, name)