ne_ )  [ [source]
](_modules/torch/distributions/categorical.html#Categorical) ¶

    

Bases:  ` torch.distributions.distribution.Distribution  `

Creates a categorical distribution parameterized by either  ` probs  ` or  `
logits  ` (but not both).

Note

It is equivalent to the distribution that [ ` torch.multinomial()  `
](generated/torch.multinomial.html#torch.multinomial "torch.multinomial")
samples from.

Samples are integers from  {  0  ,  …  ,  K  −  1  }  \\{0, \ldots, K-1\\}  {
0  ,  …  ,  K  −  1  }  where  K  is ` probs.size(-1)  ` .

If  ` probs  ` is 1D with length-  K  , each element is the relative
probability of sampling the class at that index.

If  ` probs  ` is 2D, it is treated as a batch of relative probability
vectors.

Note

` probs  ` must be non-negative, finite and have a non-zero sum, and it will
be normalized to sum to 1.

See also: [ ` torch.multinomial()  `
](generated/torch.multinomial.html#torch.multinomial "torch.multinomial")

Example:

    
    
    >>> m = Categorical(torch.tensor([ 0.25, 0.25, 0.25, 0.25 ]))
    >>> m.sample()  # equal probability of 0, 1, 2, 3
    tensor(3)
    

Parameters

    

  * **probs** ( [ _Tensor_ ](tensors.html#torch.Tensor "torch.Tensor") ) – event probabilities 

  * **logits** ( [ _Tensor_ ](tensors.html#torch.Tensor "torch.Tensor") ) – event log-odds 

` arg_constraints ` _= {'logits': Real(), 'probs': Simplex()}_ ¶

    

` entropy ` (  )  [ [source]
](_modules/torch/distributions/categorical.html#Categorical.entropy) ¶

    

` enumerate_support ` (  _expand=True_ )  [ [source]
](_modules/torch/distributions/categorical.html#Categorical.enumerate_support)
¶

    

` expand ` (  _batch_shape_ , __instance=None_ )  [ [source]
](_modules/torch/distributions/categorical.html#Categorical.expand) ¶

    

` has_enumerate_support ` _= True_ ¶

    

` log_prob ` (  _value_ )  [ [source]
](_modules/torch/distributions/categorical.html#Categorical.log_prob) ¶

    

` logits ` [ [source]
](_modules/torch/distributions/categorical.html#Categorical.logits) ¶

    

_property_ ` mean ` ¶

    

_property_ ` param_shape ` ¶

    

` probs ` [ [source]
](_modules/torch/distributions/categorical.html#Categorical.probs) ¶

    

` sample ` (  _sample_shape=torch.Size([])_ )  [ [source]
](_modules/torch/distributions/categorical.html#Categorical.sample) ¶

    

_property_ ` support ` ¶

    

_property_ ` variance ` ¶

    

##  Cauchy  ¶

_class_ ` torch.distributions.cauchy. ` ` Cauchy ` (  _loc_ , _scale_ ,
_validate_args=None_ )  [ [source]
](_modules/torch/distributions/cauchy.html#Cauchy) ¶

    

Bases:  ` torch.distributions.distribution.Distribution  `

Samples from a Cauchy (Lorentz) distribution. The distribution of the ratio of
independent normally distributed random variables with means  0  follows a
Cauchy distribution.

Example:

    
    
    >>> m = Cauchy(torch.tensor([0.0]), torch.tensor([1.0]))
    >>> m.sample()  # sample from a Cauchy distribution with loc=0 and scale=1
    tensor([ 2.3214])
    

Parameters

    

  * **loc** ( [ _float_ ](https://docs.python.org/3/library/functions.html#float "\(in Python v3.8\)") _or_ [ _Tensor_ ](tensors.html#torch.Tensor "torch.Tensor") ) – mode or median of the distribution. 

  * **scale** ( [ _float_ ](https://docs.python.org/3/library/functions.html#float "\(in Python v3.8\)") _or_ [ _Tensor_ ](tensors.html#torch.Tensor "torch.Tensor") ) – half width at half maximum. 

` arg_constraints ` _= {'loc': Real(), 'scale': GreaterThan(lower_bound=0.0)}_
¶

    

` cdf ` (  _value_ )  [ [source]
](_modules/torch/distributions/cauchy.html#Cauchy.cdf) ¶

    

` entropy ` (  )  [ [source]
](_modules/torch/distributions/cauchy.html#Cauchy.entropy) ¶

    

` expand ` (  _batch_shape_ , __instance=None_ )  [ [source]
](_modules/torch/distributions/cauchy.html#Cauchy.expand) ¶

    

` has_rsample ` _= True_ ¶

    

` icdf ` (  _value_ )  [ [source]
](_modules/torch/distributions/cauchy.html#Cauchy.icdf) ¶

    

` lo