L i xddlmZmZddlZddlmZddlmZddlmZddl m Z ddl m Z m Z dgZGd deZy) )OptionalUnionN)Tensor) constraints)ExponentialFamily) broadcast_all)_NumberNumberPoissonceZdZdZdej iZejZe de fdZ e de fdZ e de fdZ ddee efdeeddffd Zdfd Zej*fd Zd Ze dee fd ZdZxZS)r a Creates a Poisson distribution parameterized by :attr:`rate`, the rate parameter. Samples are nonnegative integers, with a pmf given by .. math:: \mathrm{rate}^k \frac{e^{-\mathrm{rate}}}{k!} Example:: >>> # xdoctest: +SKIP("poisson_cpu not implemented for 'Long'") >>> m = Poisson(torch.tensor([4])) >>> m.sample() tensor([ 3.]) Args: rate (Number, Tensor): the rate parameter ratereturnc|jSNr selfs a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/torch/distributions/poisson.pymeanz Poisson.mean& yyc6|jjSr)r floorrs rmodez Poisson.mode*syy  rc|jSrrrs rvariancezPoisson.variance.rrN validate_argsct|\|_t|trt j }n|jj }t|!||y)Nr) rr isinstancer torchSizesizesuper__init__)rr r batch_shape __class__s rr%zPoisson.__init__2sJ %T*  dG $**,K))..*K MBrc|jt|}tj|}|jj ||_t t||d|j|_|S)NFr) _get_checked_instancer r!r"r expandr$r%_validate_args)rr& _instancenewr's rr*zPoisson.expand>s`(()<jj- 99##K0 gs$[$F!00 rc|j|}tj5tj|jj |cdddS#1swYyxYwr)_extended_shaper!no_gradpoissonr r*)r sample_shapeshapes rsamplezPoisson.sampleFsK$$\2 ]]_ :==!1!1%!89 : : :s .AA'c|jr|j|t|j|\}}|j ||z |dzj z S)N)r+_validate_samplerr xlogylgamma)rvaluer s rlog_probzPoisson.log_probKsS     ! !% (#DIIu5 e{{4 4'519*<*<*>>>rcBtj|jfSr)r!logr rs r_natural_paramszPoisson._natural_paramsQs $))$&&rc,tj|Sr)r!exp)rxs r_log_normalizerzPoisson._log_normalizerUsyy|rr)__name__ __module__ __qualname____doc__r nonnegativearg_constraintsnonnegative_integersupportpropertyrrrrrr rboolr%r*r!r"r4r;tupler>rB __classcell__)r's@rr r s&{667O--G f!f!!& )- CFFN# C ~ C  C#-%**,: ? 'v''r)typingrrr!rtorch.distributionsrtorch.distributions.exp_familyrtorch.distributions.utilsr torch.typesr r __all__r rrrVs2" +<3' +GGr