L i0 ddlZddlmZmZddlZddlmZmZddlmZddl m Z ddl m Z ddl mZdgZGd de Zy) N)OptionalUnion)infTensor) constraints)Cauchy)TransformedDistribution) AbsTransform HalfCauchyceZdZUdZdej iZejZdZ e e d< dde e efdeeddffd Zdfd Zede fd Zede fd Zede fd Zede fd ZdZdZdZdZxZS)r a Creates a half-Cauchy distribution parameterized by `scale` where:: X ~ Cauchy(0, scale) Y = |X| ~ HalfCauchy(scale) Example:: >>> # xdoctest: +IGNORE_WANT("non-deterministic") >>> m = HalfCauchy(torch.tensor([1.0])) >>> m.sample() # half-cauchy distributed with scale=1 tensor([ 2.3214]) Args: scale (float or Tensor): scale of the full Cauchy distribution scaleT base_distN validate_argsreturncVtd|d}t| |t|y)NrF)r)rsuper__init__r )selfr rr __class__s e/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/distributions/half_cauchy.pyrzHalfCauchy.__init__'s) 1e59  LN-PcR|jt|}t| ||S)N) _instance)_get_checked_instancer rexpand)r batch_shapernewrs rrzHalfCauchy.expand/s(((Y?w~kS~99rc.|jjSN)rr rs rr zHalfCauchy.scale3s~~###rctj|jtj|j j |j jS)Ndtypedevice)torchfull_extended_shapemathrr r#r$r s rmeanzHalfCauchy.mean7s@zz  " HH**""::$$   rc@tj|jSr)r% zeros_liker r s rmodezHalfCauchy.mode@s ++rc.|jjSr)rvariancer s rr.zHalfCauchy.varianceDs~~&&&rc|jr|j|tj||jj j |jj j}|jj|tjdz}tj|dk\|t }|S)Nr"r) _validate_args_validate_sampler% as_tensorrr r#r$log_probr(logwherer)rvaluer4s rr4zHalfCauchy.log_probHs     ! !% ( --33DNN>**51DHHQK?;;uz8cT:rc~|jr|j|d|jj|zdz S)Nr0)r1r2rcdf)rr7s rr:zHalfCauchy.cdfRs8     ! !% (4>>%%e,,q00rcD|jj|dzdz S)Nr9r0)ricdf)rprobs rr<zHalfCauchy.icdfWs~~""D1H>22rcb|jjtjdz S)Nr0)rentropyr(r5r s rr?zHalfCauchy.entropyZs"~~%%'$((1+55rr)__name__ __module__ __qualname____doc__rpositivearg_constraints nonnegativesupport has_rsampler__annotations__rrfloatrboolrrpropertyr r)r,r.r4r:r<r? __classcell__)rs@rr r s" 4 45O%%GK )-QVU]#Q ~Q  Q:$v$$ f  ,f,,'&''1 36r)r(typingrrr%rrtorch.distributionsrtorch.distributions.cauchyr,torch.distributions.transformed_distributionr torch.distributions.transformsr __all__r rrrUs5 " +-P7 .K6(K6r