class_docstr: Levy :math:`\alpha`-stable distribution. See [1] for a review.
  
  This uses Nolan's parametrization [2] of the ``loc`` parameter, which is
  required for continuity and differentiability. This corresponds to the
  notation :math:`S^0_\alpha(\beta,\sigma,\mu_0)` of [1], where
  :math:`\alpha` = stability, :math:`\beta` = skew, :math:`\sigma` = scale,
  and :math:`\mu_0` = loc. To instead use the S parameterization as in scipy,
  pass ``coords="S"``, but BEWARE this is discontinuous at ``stability=1``
  and has poor geometry for inference.
  
  This implements a reparametrized sampler :meth:`rsample` , but does not
  implement :meth:`log_prob` . Inference can be performed using either
  likelihood-free algorithms such as
  :class:`~pyro.infer.energy_distance.EnergyDistance`, or reparameterization
  via the :func:`~pyro.poutine.handlers.reparam` handler with one of the
  reparameterizers :class:`~pyro.infer.reparam.stable.LatentStableReparam` ,
  :class:`~pyro.infer.reparam.stable.SymmetricStableReparam` , or
  :class:`~pyro.infer.reparam.stable.StableReparam` e.g.::
  
      with poutine.reparam(config={"x": StableReparam()}):
          pyro.sample("x", Stable(stability, skew, scale, loc))
  
  or simply wrap in :class:`~pyro.infer.reparam.strategies.MinimalReparam` or
  :class:`~pyro.infer.reparam.strategies.AutoReparam` , e.g.::
  
      @MinimalReparam()
      def model():
          ...
  
  [1] S. Borak, W. Hardle, R. Weron (2005).
      Stable distributions.
      https://edoc.hu-berlin.de/bitstream/handle/18452/4526/8.pdf
  [2] J.P. Nolan (1997).
      Numerical calculation of stable densities and distribution functions.
  [3] Rafal Weron (1996).
      On the Chambers-Mallows-Stuck Method for
      Simulating Skewed Stable Random Variables.
  [4] J.P. Nolan (2017).
      Stable Distributions: Models for Heavy Tailed Data.
      https://edspace.american.edu/jpnolan/wp-content/uploads/sites/1720/2020/09/Chap1.pdf
  
  :param Tensor stability: Levy stability parameter :math:`\alpha\in(0,2]` .
  :param Tensor skew: Skewness :math:`\beta\in[-1,1]` .
  :param Tensor scale: Scale :math:`\sigma > 0` . Defaults to 1.
  :param Tensor loc: Location :math:`\mu_0` when using Nolan's S0
      parametrization [2], or :math:`\mu` when using the S parameterization.
      Defaults to 0.
  :param str coords: Either "S0" (default) to use Nolan's continuous S0
      parametrization, or "S" to use the discontinuous parameterization.
class_docstr_tok: ["Levy",":","math",":","`","\\alpha","`","-stable","distribution",".","See","[","1","]","for","a","review",".","This","uses","Nolan","'s","parametrization","[","2","]","of","the","``","loc","``","parameter",",","which","is","required","for","continuity","and","differentiability",".","This","corresponds","to","the","notation",":","math",":","`","S^0_\\alpha","(","\\beta",",","\\sigma",",","\\mu_0",")","`","of","[","1","]",",","where",":","math",":","`","\\alpha","`","=","stability",",",":","math",":","`","\\beta","`","=","skew",",",":","math",":","`","\\sigma","`","=","scale",",","and",":","math",":","`","\\mu_0","`","=","loc",".","To","instead","use","the","S","parameterization","as","in","scipy",",","pass","``","coords=","''","S","''","``",",","but","BEWARE","this","is","discontinuous","at","``","stability=1","``","and","has","poor","geometry","for","inference",".","This","implements","a","reparametrized","sampler",":","meth",":","`","rsample","`",",","but","does","not","implement",":","meth",":","`","log_prob","`",".","Inference","can","be","performed","using","either","likelihood-free","algorithms","such","as",":","class",":","`","~pyro.infer.energy_distance.EnergyDistance","`",",","or","reparameterization","via","the",":","func",":","`","~pyro.poutine.handlers.reparam","`","handler","with","one","of","the","reparameterizers",":","class",":","`","~pyro.infer.reparam.stable.LatentStableReparam","`",",",":","class",":","`","~pyro.infer.reparam.stable.SymmetricStableReparam","`",",","or",":","class",":","`","~pyro.infer.reparam.stable.StableReparam","`","e.g",".",":",":","with","poutine.reparam","(","config=","{","``","x","''",":","StableReparam","(",")","}",")",":","pyro.sample","(","``","x","''",",","Stable","(","stability",",","skew",",","scale",",","loc",")",")","or","simply","wrap","in",":","class",":","`","~pyro.infer.reparam.strategies.MinimalReparam","`","or",":","class",":","`","~pyro.infer.reparam.strategies.AutoReparam","`",",","e.g",".",":",":","@","MinimalReparam","(",")","def","model","(",")",":","...","[","1","]","S.","Borak",",","W.","Hardle",",","R.","Weron","(","2005",")",".","Stable","distributions",".","https",":","\/\/edoc.hu-berlin.de\/bitstream\/handle\/18452\/4526\/8.pdf","[","2","]","J.P.","Nolan","(","1997",")",".","Numerical","calculation","of","stable","densities","and","distribution","functions",".","[","3","]","Rafal","Weron","(","1996",")",".","On","the","Chambers-Mallows-Stuck","Method","for","Simulating","Skewed","Stable","Random","Variables",".","[","4","]","J.P.","Nolan","(","2017",")",".","Stable","Distributions",":","Models","for","Heavy","Tailed","Data",".","https",":","\/\/edspace.american.edu\/jpnolan\/wp-content\/uploads\/sites\/1720\/2020\/09\/Chap1.pdf",":","param","Tensor","stability",":","Levy","stability","parameter",":","math",":","`","\\alpha\\in","(","0,2","]","`",".",":","param","Tensor","skew",":","Skewness",":","math",":","`","\\beta\\in","[","-1,1","]","`",".",":","param","Tensor","scale",":","Scale",":","math",":","`","\\sigma",">","0","`",".","Defaults","to","1.",":","param","Tensor","loc",":","Location",":","math",":","`","\\mu_0","`","when","using","Nolan","'s","S0","parametrization","[","2","]",",","or",":","math",":","`","\\mu","`","when","using","the","S","parameterization",".","Defaults","to","0.",":","param","str","coords",":","Either","``","S0","''","(","default",")","to","use","Nolan","'s","continuous","S0","parametrization",",","or","``","S","''","to","use","the","discontinuous","parameterization","."]
code: def mean(self):
      result = self.loc
      if self.coords == "S0":
          result = (
              result
              - self.scale
              * self.skew
              * (math.pi / 2 * self.stability).tan()
          )
      return result.masked_fill(self.stability <= 1, math.nan)
  
file_path: pyro/pyro/distributions/stable.py
imports: import math
  import torch
  from torch.distributions import constraints
  from torch.distributions.utils import broadcast_all
  from pyro.distributions.torch_distribution import TorchDistribution
label_desc: Use image node_id 5 for calling the Stable obj's underlying member method code with example usage: obj.mean() and returns: result