def testBijectorValues(self):
        x = [-1., 0., 1.]
        bij = tfb.GeneralizedPareto(loc=[1., 2., 3.],
                                    scale=5.,
                                    concentration=[[-4., -6., -1.],
                                                   [2., 4., 0.]],
                                    validate_args=True)

        y = self.evaluate(bij.forward(x))
        self.assertAllClose(y[0],
                            self.evaluate(
                                bij._negative_concentration_bijector()(x)[0]),
                            rtol=1e-6,
                            atol=0)
        self.assertAllClose(y[1],
                            self.evaluate(
                                bij._non_negative_concentration_bijector(x)),
                            rtol=1e-6,
                            atol=0)

        y = [1.5, 2.5, 3.5]
        ildj = self.evaluate(bij.inverse_log_det_jacobian(y, event_ndims=0))
        self.assertAllClose(ildj[0],
                            self.evaluate(bij._negative_concentration_bijector(
                            ).inverse_log_det_jacobian(y, event_ndims=0))[0],
                            rtol=1e-6,
                            atol=0)
        self.assertAllClose(ildj[1],
                            self.evaluate(
                                bij._non_negative_concentration_bijector.
                                inverse_log_det_jacobian(y, event_ndims=0)),
                            rtol=1e-6,
                            atol=0)
 def testScalarCongruencyNegativeConcentration(self):
     bijector_test_util.assert_scalar_congruency(tfb.GeneralizedPareto(
         loc=1., scale=3., concentration=-5., validate_args=True),
                                                 lower_x=-7.,
                                                 upper_x=7.,
                                                 eval_func=self.evaluate,
                                                 rtol=.1)
 def testBijectiveAndFinitePositiveConcentration(self):
     loc = 5.
     x = np.linspace(-10., 20., 20).astype(np.float32)
     y = np.linspace(loc + 1e-3, 20., 20).astype(np.float32)
     bijector_test_util.assert_bijective_and_finite(tfb.GeneralizedPareto(
         loc=loc, scale=2., concentration=1., validate_args=True),
                                                    x,
                                                    y,
                                                    eval_func=self.evaluate,
                                                    event_ndims=0,
                                                    atol=1e-2,
                                                    rtol=1e-2)
 def testBijectiveAndFiniteNegativeConcentration(self):
     x = np.linspace(-10., 10., 20).astype(np.float32)
     eps = 1e-3
     loc = 5.
     scale = 4.
     concentration = 1.
     upper_bound = loc + scale / concentration
     y = np.linspace(loc + eps, upper_bound - eps, 20).astype(np.float32)
     bijector_test_util.assert_bijective_and_finite(tfb.GeneralizedPareto(
         loc=loc,
         scale=scale,
         concentration=concentration,
         validate_args=True),
                                                    x,
                                                    y,
                                                    eval_func=self.evaluate,
                                                    event_ndims=0,
                                                    atol=1e-2,
                                                    rtol=1e-2)