
    AVhx                         d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlmZ ddgZ edg       G d dej$                               Z G d de      Zy)z#The Exponential distribution class.    N)dtypes)ops)	array_ops)math_ops)nn)
random_ops)gamma)deprecation)	tf_exportExponentialExponentialWithSoftplusRatezdistributions.Exponential)v1c                        e Zd ZdZ ej
                  ddd      	 	 	 d fd	       Zed        Ze	d        Z
d	 Zdd
Z xZS )r   a  Exponential distribution.

  The Exponential distribution is parameterized by an event `rate` parameter.

  #### Mathematical Details

  The probability density function (pdf) is,

  ```none
  pdf(x; lambda, x > 0) = exp(-lambda x) / Z
  Z = 1 / lambda
  ```

  where `rate = lambda` and `Z` is the normalizaing constant.

  The Exponential distribution is a special case of the Gamma distribution,
  i.e.,

  ```python
  Exponential(rate) = Gamma(concentration=1., rate)
  ```

  The Exponential distribution uses a `rate` parameter, or "inverse scale",
  which can be intuited as,

  ```none
  X ~ Exponential(rate=1)
  Y = X / rate
  ```

  
2019-01-01zThe TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.T	warn_oncec                    t        t                     }t        j                  ||g      5 }t        j                  |d      | _        ddd       t        t        | #  t        j                  g | j
                  j                        | j
                  |||       || _        | xj                  | j
                  gz  c_        y# 1 sw Y   |xY w)a  Construct Exponential distribution with parameter `rate`.

    Args:
      rate: Floating point tensor, equivalent to `1 / mean`. Must contain only
        positive values.
      validate_args: Python `bool`, default `False`. When `True` distribution
        parameters are checked for validity despite possibly degrading runtime
        performance. When `False` invalid inputs may silently render incorrect
        outputs.
      allow_nan_stats: Python `bool`, default `True`. When `True`, statistics
        (e.g., mean, mode, variance) use the value "`NaN`" to indicate the
        result is undefined. When `False`, an exception is raised if one or
        more of the statistic's batch members are undefined.
      name: Python `str` name prefixed to Ops created by this class.
    valuesratenameNdtype)concentrationr   allow_nan_statsvalidate_argsr   )dictlocalsr   
name_scopeconvert_to_tensor_ratesuperr   __init__r   onesr   _parameters_graph_parentsselfr   r   r   r   
parameters	__class__s         _/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/distributions/exponential.pyr$   zExponential.__init__F   s    8 fhJ
 
dV	, <((F;dj<	+t%nnRtzz/?/?@ZZ'# &  "DDJJ<'< <s   CCc                 P    dt        j                  | t        j                        iS )Nr   r   )r   r!   r   int32)sample_shapes    r,   _param_shapeszExponential._param_shapesr   s    C)),fllKLL    c                     | j                   S N)r"   )r)   s    r,   r   zExponential.ratev   s    ::r1   c                 d    | j                  |      t        j                  | j                        z
  S r3   )	_log_probr   logr"   )r)   values     r,   _log_survival_functionz"Exponential._log_survival_functionz   s#    >>% 8<<

#;;;r1   c                 ^   t        j                  |gt        j                  | j                        gd      }t	        j
                  |t        j                  | j                  j                        j                  d|| j                        }t        j                  |       | j                  z  S )Nr   g      ?)minvalmaxvalseedr   )r   concatshaper"   r   random_uniformnpfinfor   as_numpy_dtypetinyr   r6   )r)   nr<   r>   sampleds        r,   	_sample_nzExponential._sample_n}   s    qc9??4::#>?CE ''xx

11277jjG LL!!DJJ..r1   )FTr   r3   )__name__
__module____qualname____doc__r
   
deprecatedr$   staticmethodr0   propertyr   r8   rF   __classcell__r+   s   @r,   r   r   $   sw    @ ;'
  ##!	"("(H M M  </r1   c                   Z     e Zd ZdZ ej
                  ddd      	 	 	 d fd	       Z xZS )r   z.Exponential with softplus transform on `rate`.r   z+Use `tfd.Exponential(tf.nn.softplus(rate)).Tr   c                     t        t                     }t        j                  ||g      5 }t        t
        |   t        j                  |d      |||       d d d        || _	        y # 1 sw Y   || _	        y xY w)Nr   softplus_rater   )r   r   r   r   )
r   r   r   r    r#   r   r$   r   softplusr&   r(   s         r,   r$   z$ExponentialWithSoftplusRate.__init__   sr     fhJ	dV	, '7{{4o6%)	 8  "D "Ds   -A**A:)FTr   )rG   rH   rI   rJ   r
   rK   r$   rN   rO   s   @r,   r   r      s9    6;3 ##1	"	"r1   )rJ   numpyr@   tensorflow.python.frameworkr   r   tensorflow.python.opsr   r   r   r   #tensorflow.python.ops.distributionsr	   tensorflow.python.utilr
    tensorflow.python.util.tf_exportr   __all__Gammar   r    r1   r,   <module>r]      so    *  . + + * $ , 5 . 6 ! *+,g/%++ g/ -g/T"+ "r1   