/usr/local/lib64/python3.6/site-packages/torch/distributions/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/distributions/__pycache__/cauchy.cpython-36.pyc (3310B)
3
Eg
@ sd d dl Z d dlmZmZ d dlmZ d dlZd dlmZ d dl m
Z
d dlmZ G dd de
Z
dS ) N)infnan)Number)constraints)Distribution)
broadcast_allc s e Zd ZdZejejdZejZdZ d fdd Z
d fdd Zed d
Z
edd Zej fd
dZdd Zdd Zdd Zdd Z ZS )Cauchya
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])
Args:
loc (float or Tensor): mode or median of the distribution.
scale (float or Tensor): half width at half maximum.
)locscaleTNc sR t ||\| _| _t|tr0t|tr0tj }n
| jj }tt | j
||d d S )N)
validate_args)r r r
isinstancer torchSizesizesuperr __init__)selfr r
r batch_shape) __class__ F/usr/local/lib64/python3.6/site-packages/torch/distributions/cauchy.pyr s
zCauchy.__init__c sR | j t|}tj|}| jj||_| jj||_tt|j|dd | j |_ |S )NF)r )
Z_get_checked_instancer r
r r expandr
r r _validate_args)r r Z _instancenew)r r r r ' s
z
Cauchy.expandc C s t j| j t| jj| jjdS )N)dtypedevice)r
full_extended_shaper r r r )r r r r mean0 s zCauchy.meanc C s t j| j t| jj| jjdS )N)r r )r
r r r r r r )r r r r variance4 s zCauchy.variancec C s* | j |}| jj|j }| j|| j S )N)r r r Zcauchy_r
)r Zsample_shapeshapeZepsr r r rsample8 s
zCauchy.rsamplec C sD | j r| j| tjtj | jj d|| j | j d j S )N )r _validate_samplemathlogpir
r )r valuer r r log_prob= s
zCauchy.log_probc C s0 | j r| j| tj|| j | j tj d S )Ng ?)r r$ r
atanr r
r% r' )r r( r r r cdfB s
z
Cauchy.cdfc C s t jtj|d | j | j S )Ng ?)r
tanr% r' r
r )r r( r r r icdfG s zCauchy.icdfc C s t jdt j | jj S )N )r% r&