L id ddlZddlmZmZddlZddlmZmZmZddlm Z ddl m Z ddl m Z ddlmZmZdgZGd de Zy) N)OptionalUnion)infnanTensor) constraints) Distribution) broadcast_all)_Number_sizeCauchyc 8eZdZdZej ej dZej ZdZ dde e e fde e e fde eddffd Zdfd Zede fd Zede fd Zede fd Zej,fdede fdZdZdZdZdZxZS)r aC 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:: >>> # xdoctest: +IGNORE_WANT("non-deterministic") >>> 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. )locscaleTNrr validate_argsreturnct||\|_|_t|tr%t|trt j }n|jj}t|%||y)Nr) r rr isinstancer torchSizesizesuper__init__)selfrrr batch_shape __class__s `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/distributions/cauchy.pyrzCauchy.__init__&sY -S%8$* c7 # 5'(B**,K((--/K MBc*|jt|}tj|}|jj ||_|j j ||_tt|#|d|j|_ |S)NFr) _get_checked_instancer rrrexpandrrr_validate_args)rr _instancenewrs rr"z Cauchy.expand3st((;jj- ((//+.JJ%%k2  fc#Ku#E!00 rctj|jt|jj |jj SN)dtypedevice)rfull_extended_shaperrr(r)rs rmeanz Cauchy.mean<5zz  "Ctxx~~dhhoo  rc|jSN)rr,s rmodez Cauchy.modeBs xxrctj|jt|jj |jj Sr')rr*r+rrr(r)r,s rvariancezCauchy.varianceFr.r sample_shapec|j|}|jj|j}|j||jzzSr0)r+rr%cauchy_r)rr4shapeepss rrsamplezCauchy.rsampleLsE$$\2hhll5!))+xx# ***rc|jr|j|tjtj |j jz ||j z |j z dzjz S)N)r#_validate_samplemathlogpirrlog1prvalues rlog_probzCauchy.log_probQsl     ! !% ( XXdgg  jjnn !TZZ/A5<<> ? rc|jr|j|tj||jz |j z t jz dzSNg?)r#r<ratanrrr=r?rAs rcdfz Cauchy.cdfZsH     ! !% (zz5488+tzz9:TWWDsJJrctjtj|dz z|jz|j zSrE)rtanr=r?rrrAs ricdfz Cauchy.icdf_s0yyECK01DJJ>IIrctjdtjz|jjzS)N)r=r>r?rr,s rentropyzCauchy.entropybs)xxDGG $tzz~~'777rr0)__name__ __module__ __qualname____doc__rrealpositivearg_constraintssupport has_rsamplerrfloatrboolrr"propertyr-r1r3rrr r9rCrGrJrM __classcell__)rs@rr r s"*..9M9MNOGK )- C 65= ! CVU]# C ~ C  C f  f &  -7EJJL+E+V+  K J8r)r=typingrrrrrrtorch.distributionsr torch.distributions.distributionr torch.distributions.utilsr torch.typesr r __all__r rrrbs7 " ""+93& *S8\S8r