class_docstr: Base class for parameterized probability distributions.
  
  Distributions in Pyro are stochastic function objects with :meth:`sample` and
  :meth:`log_prob` methods. Distribution are stochastic functions with fixed
  parameters::
  
    d = dist.Bernoulli(param)
    x = d()                                # Draws a random sample.
    p = d.log_prob(x)                      # Evaluates log probability of x.
  
  **Implementing New Distributions**:
  
  Derived classes must implement the methods: :meth:`sample`,
  :meth:`log_prob`.
  
  **Examples**:
  
  Take a look at the `examples <http://pyro.ai/examples>`_ to see how they interact
  with inference algorithms.
class_docstr_tok: ["Base","class","for","parameterized","probability","distributions",".","Distributions","in","Pyro","are","stochastic","function","objects","with",":","meth",":","`","sample","`","and",":","meth",":","`","log_prob","`","methods",".","Distribution","are","stochastic","functions","with","fixed","parameters",":",":","d","=","dist.Bernoulli","(","param",")","x","=","d","(",")","#","Draws","a","random","sample",".","p","=","d.log_prob","(","x",")","#","Evaluates","log","probability","of","x",".","*","*","Implementing","New","Distributions","*","*",":","Derived","classes","must","implement","the","methods",":",":","meth",":","`","sample","`",",",":","meth",":","`","log_prob","`",".","*","*","Examples","*","*",":","Take","a","look","at","the","`","examples","<","http",":","\/\/pyro.ai\/examples",">","`","_","to","see","how","they","interact","with","inference","algorithms","."]
docstr: EXPERIMENTAL Creates an updated distribution fusing information from
  another compatible distribution. This is supported by only a few
  conjugate distributions.
  
  This should satisfy the equation::
  
      fg, log_normalizer = f.conjugate_update(g)
      assert f.log_prob(x) + g.log_prob(x) == fg.log_prob(x) + log_normalizer
  
  Note this is equivalent to :obj:`funsor.ops.add` on
  :class:`~funsor.terms.Funsor` distributions, but we return a lazy sum
  ``(updated, log_normalizer)`` because PyTorch distributions must be
  normalized.  Thus :meth:`conjugate_update` should commute with
  :func:`~funsor.pyro.convert.dist_to_funsor` and
  :func:`~funsor.pyro.convert.tensor_to_funsor` ::
  
      dist_to_funsor(f) + dist_to_funsor(g)
        == dist_to_funsor(fg) + tensor_to_funsor(log_normalizer)
  
  :param other: A distribution representing ``p(data|latent)`` but
      normalized over ``latent`` rather than ``data``. Here ``latent``
      is a candidate sample from ``self`` and ``data`` is a ground
      observation of unrelated type.
  :return: a pair ``(updated,log_normalizer)`` where ``updated`` is an
      updated distribution of type ``type(self)``, and ``log_normalizer``
      is a :class:`~torch.Tensor` representing the normalization factor.
docstr_tok: ["EXPERIMENTAL","Creates","an","updated","distribution","fusing","information","from","another","compatible","distribution",".","This","is","supported","by","only","a","few","conjugate","distributions",".","This","should","satisfy","the","equation",":",":","fg",",","log_normalizer","=","f.conjugate_update","(","g",")","assert","f.log_prob","(","x",")","+","g.log_prob","(","x",")","==","fg.log_prob","(","x",")","+","log_normalizer","Note","this","is","equivalent","to",":","obj",":","`","funsor.ops.add","`","on",":","class",":","`","~funsor.terms.Funsor","`","distributions",",","but","we","return","a","lazy","sum","``","(","updated",",","log_normalizer",")","``","because","PyTorch","distributions","must","be","normalized",".","Thus",":","meth",":","`","conjugate_update","`","should","commute","with",":","func",":","`","~funsor.pyro.convert.dist_to_funsor","`","and",":","func",":","`","~funsor.pyro.convert.tensor_to_funsor","`",":",":","dist_to_funsor","(","f",")","+","dist_to_funsor","(","g",")","==","dist_to_funsor","(","fg",")","+","tensor_to_funsor","(","log_normalizer",")",":","param","other",":","A","distribution","representing","``","p","(","data|latent",")","``","but","normalized","over","``","latent","``","rather","than","``","data","``",".","Here","``","latent","``","is","a","candidate","sample","from","``","self","``","and","``","data","``","is","a","ground","observation","of","unrelated","type",".",":","return",":","a","pair","``","(","updated",",","log_normalizer",")","``","where","``","updated","``","is","an","updated","distribution","of","type","``","type","(","self",")","``",",","and","``","log_normalizer","``","is","a",":","class",":","`","~torch.Tensor","`","representing","the","normalization","factor","."]
code: def conjugate_update(self, other):
      """
      EXPERIMENTAL Creates an updated distribution fusing information from
      another compatible distribution. This is supported by only a few
      conjugate distributions.
  
      This should satisfy the equation::
  
          fg, log_normalizer = f.conjugate_update(g)
          assert f.log_prob(x) + g.log_prob(x) == fg.log_prob(x) + log_normalizer
  
      Note this is equivalent to :obj:`funsor.ops.add` on
      :class:`~funsor.terms.Funsor` distributions, but we return a lazy sum
      ``(updated, log_normalizer)`` because PyTorch distributions must be
      normalized.  Thus :meth:`conjugate_update` should commute with
      :func:`~funsor.pyro.convert.dist_to_funsor` and
      :func:`~funsor.pyro.convert.tensor_to_funsor` ::
  
          dist_to_funsor(f) + dist_to_funsor(g)
            == dist_to_funsor(fg) + tensor_to_funsor(log_normalizer)
  
      :param other: A distribution representing ``p(data|latent)`` but
          normalized over ``latent`` rather than ``data``. Here ``latent``
          is a candidate sample from ``self`` and ``data`` is a ground
          observation of unrelated type.
      :return: a pair ``(updated,log_normalizer)`` where ``updated`` is an
          updated distribution of type ``type(self)``, and ``log_normalizer``
          is a :class:`~torch.Tensor` representing the normalization factor.
      """
      raise NotImplementedError(
          "{} does not support .conjugate_update()".format(
              type(self).__name__
          )
      )
  
file_path: pyro/pyro/distributions/distribution.py
imports: import functools
  import inspect
  from abc import ABCMeta, abstractmethod
  import torch
  from pyro.distributions.score_parts import ScoreParts
label_desc: Use image node_id 6 for calling the Distribution obj's underlying member method code with example usage: obj.conjugate_update(other) without return types