
    ȅi	                     h    S SK r S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	J
r
  S/r " S S\5      rg)	    N)Tensor)constraints)ExponentialFamily)broadcast_all)_NumberNumberPoissonc                   .  ^  \ rS rSrSrS\R                  0r\R                  r	\
S\4S j5       r\
S\4S j5       r\
S\4S j5       r SS\\-  S	\S-  SS4U 4S
 jjjrSU 4S jjr\R(                  " 5       4S jrS r\
S\\   4S j5       rS rSrU =r$ )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
ratereturnc                     U R                   $ Nr   selfs    U/home/james-whalen/.local/lib/python3.13/site-packages/torch/distributions/poisson.pymeanPoisson.mean&       yy    c                 6    U R                   R                  5       $ r   )r   floorr   s    r   modePoisson.mode*   s    yy  r   c                     U R                   $ r   r   r   s    r   variancePoisson.variance.   r   r   Nvalidate_argsc                    > [        U5      u  U l        [        U[        5      (       a  [        R
                  " 5       nOU R                  R                  5       n[        TU ]!  X2S9  g )Nr   )	r   r   
isinstancer   torchSizesizesuper__init__)r   r   r   batch_shape	__class__s       r   r'   Poisson.__init__2   sK    
 %T*dG$$**,K))..*KBr   c                    > U R                  [        U5      n[        R                  " U5      nU R                  R                  U5      Ul        [        [        U]  USS9  U R                  Ul        U$ )NFr!   )	_get_checked_instancer	   r#   r$   r   expandr&   r'   _validate_args)r   r(   	_instancenewr)   s       r   r-   Poisson.expand>   s`    (()<jj-99##K0gs$[$F!00
r   c                     U R                  U5      n[        R                  " 5          [        R                  " U R                  R                  U5      5      sS S S 5        $ ! , (       d  f       g = fr   )_extended_shaper#   no_gradpoissonr   r-   )r   sample_shapeshapes      r   samplePoisson.sampleF   s@    $$\2]]_==!1!1%!89 __s   /A  
A.c                     U R                   (       a  U R                  U5        [        U R                  U5      u  p!UR	                  U5      U-
  US-   R                  5       -
  $ )N   )r.   _validate_sampler   r   xlogylgamma)r   valuer   s      r   log_probPoisson.log_probK   sQ    !!%(#DIIu5{{4 4'519*<*<*>>>r   c                 D    [         R                  " U R                  5      4$ r   )r#   logr   r   s    r   _natural_paramsPoisson._natural_paramsQ   s    		$))$&&r   c                 .    [         R                  " U5      $ r   )r#   exp)r   xs     r   _log_normalizerPoisson._log_normalizerV   s    yy|r   r   r   )__name__
__module____qualname____firstlineno____doc__r   nonnegativearg_constraintsnonnegative_integersupportpropertyr   r   r   r   r   boolr'   r-   r#   r$   r8   r@   tuplerD   rI   __static_attributes____classcell__)r)   s   @r   r	   r	      s    ( {667O--Gf   !f ! ! &   &*
Cvo
C d{
C 
	
C 
C #(**, :
? 'v ' ' r   )r#   r   torch.distributionsr   torch.distributions.exp_familyr   torch.distributions.utilsr   torch.typesr   r   __all__r	    r   r   <module>r_      s1      + < 3 ' +I Ir   