o
    2hx                     @   s   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dG dd dejZG dd deZdS )z#The Exponential distribution class.    N)dtypes)ops)	array_ops)math_ops)nn)
random_ops)gamma)deprecation)	tf_exportExponentialExponentialWithSoftplusRatezdistributions.Exponential)v1c                       sb   e Zd ZdZejdddd			 d fdd	Zed	d
 Ze	dd Z
dd ZdddZ  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_onceFc                    s   t t }tj||gd}tj|dd| _W d   n1 s w   Y  tt| jt	j
g | jjd| j|||d || _|  j| jg7  _dS )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__ j/var/www/html/chatgem/venv/lib/python3.10/site-packages/tensorflow/python/ops/distributions/exponential.pyr!   F   s   

zExponential.__init__c                 C   s   dt j| tjdiS )Nr   r   )r   r   r   int32)sample_shaper*   r*   r+   _param_shapesr   s   zExponential._param_shapesc                 C   s   | j S N)r   )r&   r*   r*   r+   r   v   s   zExponential.ratec                 C   s   |  |t| j S r/   )	_log_probr   logr   )r&   valuer*   r*   r+   _log_survival_functionz   s   z"Exponential._log_survival_functionNc                 C   sN   t |gt | jgd}tj|t| jj	j
d|| jd}t| | j S )Nr   g      ?)minvalmaxvalseedr   )r   concatshaper   r   random_uniformnpfinfor   as_numpy_dtypetinyr   r1   )r&   nr6   r8   sampledr*   r*   r+   	_sample_n}   s   zExponential._sample_n)FTr   r/   )__name__
__module____qualname____doc__r	   
deprecatedr!   staticmethodr.   propertyr   r3   r@   __classcell__r*   r*   r(   r+   r   $   s"     
$

c                       s8   e Zd ZdZejdddd			 d	 fdd	Z  ZS )
r   z.Exponential with softplus transform on `rate`.r   z+Use `tfd.Exponential(tf.nn.softplus(rate)).Tr   Fc                    sf   t t }tj||gd}tt| jtj|dd|||d W d    n1 s)w   Y  || _	d S )Nr   softplus_rater   )r   r   r   r   )
r   r   r   r   r    r   r!   r   softplusr#   r%   r(   r*   r+   r!      s   
	

z$ExponentialWithSoftplusRate.__init__)FTr   )rA   rB   rC   rD   r	   rE   r!   rH   r*   r*   r(   r+   r      s    )rD   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   r*   r*   r*   r+   <module>   s"   
j