import tensorflow as tf

from .. import config
from ..distribution import Distribution


@Distribution
def Exponential(lambda_, name=None):
    X = tf.placeholder(config.dtype, name=name)

    Distribution.logp = tf.log(lambda_) - lambda_*X

    def cdf(lim):
        return tf.constant(1, dtype=config.dtype) - tf.exp(-lambda_*lim)

    Distribution.integral = lambda lower, upper: cdf(upper) - cdf(lower)

    return X

import tensorflow as tf

from .. import config
from ..distribution import Distribution


@Distribution
def Exponential(lambda_, name=None):
    X = tf.placeholder(config.dtype, name=name)

    Distribution.logp = tf.log(lambda_) - lambda_*X

    def integral(lower, upper):
        return tf.exp(-lambda_*lower) - tf.exp(-lambda_*upper)

    Distribution.integral = integral

    return X

Correct integral used for Exponential distributon
Correct integral used for Exponential distributon

  import tensorflow as tf
  
  from .. import config
  from ..distribution import Distribution
  
  
  @Distribution
  def Exponential(lambda_, name=None):
      X = tf.placeholder(config.dtype, name=name)
  
      Distribution.logp = tf.log(lambda_) - lambda_*X
  
-     def cdf(lim):
-         return tf.constant(1, dtype=config.dtype) - tf.exp(-lambda_*lim)
+     def integral(lower, upper):
+         return tf.exp(-lambda_*lower) - tf.exp(-lambda_*upper)
  
-     Distribution.integral = lambda lower, upper: cdf(upper) - cdf(lower)
+     Distribution.integral = integral
  
      return X
  
Correct integral used for Exponential distributon
## Code Before:
import tensorflow as tf

from .. import config
from ..distribution import Distribution


@Distribution
def Exponential(lambda_, name=None):
    X = tf.placeholder(config.dtype, name=name)

    Distribution.logp = tf.log(lambda_) - lambda_*X

    def cdf(lim):
        return tf.constant(1, dtype=config.dtype) - tf.exp(-lambda_*lim)

    Distribution.integral = lambda lower, upper: cdf(upper) - cdf(lower)

    return X

## Instruction:
Correct integral used for Exponential distributon
## Code After:
import tensorflow as tf

from .. import config
from ..distribution import Distribution


@Distribution
def Exponential(lambda_, name=None):
    X = tf.placeholder(config.dtype, name=name)

    Distribution.logp = tf.log(lambda_) - lambda_*X

    def integral(lower, upper):
        return tf.exp(-lambda_*lower) - tf.exp(-lambda_*upper)

    Distribution.integral = integral

    return X
