+
    &j                     n    ^ RI t ^ RIHtHt ^ RIt^ RIHtHt ^ RIHtH	t	 ^ RI
Ht R.t ! R R]	4      tR# )    N)NumberReal)infnan)constraintsDistribution)broadcast_allGeneralizedParetoc                   R  a a ] tR t^t oRtR]P                  R]P                  R]P                  /tRt	RV 3R llt
RV 3R llt]P                  ! 4       3R ltR	 tR
 tR tR tR tR t]R 4       t]R 4       tR t]R 4       t]P4                  ! R^ R7      R 4       tRtVtV ;t# )r
   a]  
Creates a Generalized Pareto distribution parameterized by :attr:`loc`, :attr:`scale`, and :attr:`concentration`.

The Generalized Pareto distribution is a family of continuous probability distributions on the real line.
Special cases include Exponential (when :attr:`loc` = 0, :attr:`concentration` = 0), Pareto (when :attr:`concentration` > 0,
:attr:`loc` = :attr:`scale` / :attr:`concentration`), and Uniform (when :attr:`concentration` = -1).

This distribution is often used to model the tails of other distributions. This implementation is based on the
implementation in TensorFlow Probability.

Example::

    >>> # xdoctest: +IGNORE_WANT("non-deterministic")
    >>> m = GeneralizedPareto(torch.tensor([0.1]), torch.tensor([2.0]), torch.tensor([0.4]))
    >>> m.sample()  # sample from a Generalized Pareto distribution with loc=0.1, scale=2.0, and concentration=0.4
    tensor([ 1.5623])

Args:
    loc (float or Tensor): Location parameter of the distribution
    scale (float or Tensor): Scale parameter of the distribution
    concentration (float or Tensor): Concentration parameter of the distribution
locscaleconcentrationTc                J  < \        WV4      w  V n        V n        V n        \	        V\
        4      '       dC   \	        V\
        4      '       d-   \	        V\
        4      '       d   \        P                  ! 4       pMV P                  P                  4       p\        SV `)  WTR 7       R# )validate_argsN)r	   r   r   r   
isinstancer   torchSizesizesuper__init__)selfr   r   r   r   batch_shape	__class__s   &&&&& ~/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torch/distributions/generalized_pareto.pyr   GeneralizedPareto.__init__.   ss    3@4
0$*d0 sF##5&))=&11**,K((--/KB    c                l  < V P                  \        V4      p\        P                  ! V4      pV P                  P                  V4      Vn        V P                  P                  V4      Vn        V P                  P                  V4      Vn        \        \        V`'  VR R7       V P                  Vn
        V# )Fr   )_get_checked_instancer
   r   r   r   expandr   r   r   r   _validate_args)r   r   	_instancenewr   s   &&& r   r    GeneralizedPareto.expand<   s    (():IFjj-((//+.JJ%%k2	 ..55kB.{%.P!00
r   c                    V P                  V4      p\        P                  ! W P                  P                  V P                  P
                  R 7      pV P                  V4      # ))dtypedevice)_extended_shaper   randr   r&   r'   icdf)r   sample_shapeshapeus   &&  r   rsampleGeneralizedPareto.rsampleF   s@    $$\2JJuHHNN488??Kyy|r   c           	        V P                   '       d   V P                  V4       V P                  V4      p\        P                  ! V P
                  \        P                  ! R 4      4      p\        P                  ! V\        P                  ! V P
                  4      V P
                  4      p^V,          \        P                  ! V4      ,           p\        P                  ! V^ 8H  WU\        P                  ! WB,          4      ,          4      p\        V P                  \        4      '       d!   \        P                  ! V P                  4      MV P                  P                  4       pV) \        P                  ! W2V4      ,
          # g        )r!   _validate_sample_zr   iscloser   tensorwhere	ones_likelog1pr   r   r   mathlog)r   valuezeq_zero	safe_concywhere_nonzero	log_scales   &&      r   log_probGeneralizedPareto.log_probK   s    !!%(GGEN-- 2 2ELL4EFKKU__T%7%78$:L:L
	 	MEOOA..AFA5;;y}3M/MN$.tzz4$@$@DHHTZZ djjnnFV 	 zEKKMBBBr   c                   V P                   '       d   V P                  V4       V P                  V4      p\        P                  ! V P
                  \        P                  ! R 4      4      p\        P                  ! V\        P                  ! V P
                  4      V P
                  4      p\        P                  ! WB,          4      ) V,          p\        P                  ! W2) V4      # r1   )
r!   r2   r3   r   r4   r   r5   r6   r7   r8   )r   r;   r<   r=   r>   r@   s   &&    r   log_survival_function'GeneralizedPareto.log_survival_functionZ   s    !!%(GGEN-- 2 2ELL4EFKKU__T%7%78$:L:L
	 Y]33i?{{7B66r   c                v    \         P                  ! \         P                  ! V P                  V4      4      ) 4      # N)r   r8   exprE   r   r;   s   &&r   log_cdfGeneralizedPareto.log_cdfe   s(    {{EIId&@&@&GHHIIr   c                L    \         P                  ! V P                  V4      4      # rH   )r   rI   rK   rJ   s   &&r   cdfGeneralizedPareto.cdfh   s    yye,--r   c                   V P                   pV P                  pV P                  p\        P                  ! V\        P
                  ! V4      4      p\        P                  ! V\        P                  ! V4      V4      p\        P                  ! V) 4      pW#V,          \        P                  ! V) V,          4      ,          ,           pW#V,          ,
          p	\        P                  ! WYV4      # rH   )
r   r   r   r   r4   
zeros_liker6   r7   r8   expm1)
r   r;   r   r   r   r=   r>   logur@   
where_zeros
   &&        r   r*   GeneralizedPareto.icdfk   s    hh

**--u/?/?/NOKK)GW	{{E6"i/%++yj4>O2PPP4<'
{{7>>r   c                H    WP                   ,
          V P                  ,          # rH   )r   r   )r   xs   &&r   r3   GeneralizedPareto._zv   s    HH

**r   c                    V P                   pV^8  p\        P                  ! W!R4      pV P                  V P                  ^V,
          ,          ,           p\        P                  ! W$\
        4      # )         ?)r   r   r6   r   r   r   r   r   validr>   results   &    r   meanGeneralizedPareto.meany   sS    **!KKc:	DJJ!i-88{{5#..r   c                   V P                   pVR 8  p\        P                  ! W!R4      pV P                  ^,          ^V,
          ^,          ^^V,          ,
          ,          ,          p\        P                  ! W$\        4      # )r[   g      ?)r   r   r6   r   r   r\   s   &    r   varianceGeneralizedPareto.variance   sa    **#KKd;	Q1y=Q"6!a)m:K"LM{{5#..r   c                    \         P                  ! V P                  4      V P                  ,           ^,           p\         P                  ! WP
                  4      # )rZ   )r   r:   r   r   broadcast_to_batch_shape)r   anss   & r   entropyGeneralizedPareto.entropy   s;    ii

#d&8&881<!!#'8'899r   c                    V P                   # rH   )r   )r   s   &r   modeGeneralizedPareto.mode   s    xxr   F)is_discrete	event_dimc                    V P                   p\        P                  ! V P                  ^ 8  WP                  V P                  ,          ,
          \
        4      p\        P                  ! W4      # )r   )r   r   r6   r   r   r   r   interval)r   loweruppers   &  r   supportGeneralizedPareto.support   sR     "EJJ9K9K,K$KS
 ##E11r   )r   r   r   rH   )__name__
__module____qualname____firstlineno____doc__r   realpositivearg_constraintshas_rsampler   r    r   r   r.   rB   rE   rK   rN   r*   r3   propertyr_   rb   rh   rk   dependent_propertyrs   __static_attributes____classdictcell____classcell__)r   __classdict__s   @@r   r
   r
      s     2 	{%%))O
 KC $)::< 
C	7J.	?+ / / / /:   ##C2 D2 2r   )r9   numbersr   r   r   r   r   torch.distributionsr   r   torch.distributions.utilsr	   __all__r
    r   r   <module>r      s/         9 3 
J2 J2r   