# Path: csb/statistics/ars.py
# class ARS(object):
# 
#     from numpy import inf
# 
#     def __init__(self, logp):
# 
#         self.logp = logp
# 
#     def initialize(self, x, z0=-inf, zmax=inf):
# 
#         from numpy import array
# 
#         self.hull = Envelope(array(x), *self.logp(array(x)))
#         self.hull.z0 = z0
#         self.hull.zk = zmax
# 
#     def sample(self, maxiter=100):
# 
#         from numpy.random import random
# 
#         for i in range(maxiter):
# 
#             x = self.hull.sample()
#             l = self.hull.l(x)
#             u = self.hull.u(x)
#             w = random()
# 
#             if w <= exp(l - u): return x
# 
#             h, dh = self.logp(x)
# 
#             if w <= exp(h - u): return x
# 
#             self.hull.insert(x, h, dh)
# 
# class Gauss(LogProb):
# 
#     def __init__(self, mu, sigma=1.):
# 
#         self.mu = float(mu)
#         self.sigma = float(sigma)
# 
#     def __call__(self, x):
# 
#         return -0.5 * (x - self.mu) ** 2 / self.sigma ** 2, \
#                - (x - self.mu) / self.sigma ** 2


import numpy
import csb.test as test
from csb.statistics.ars import ARS, Gauss



@test.functional
class TestARS(test.Case):

    def testNormal(self):
        mu = 5.
        sigma = 1.

# Path: csb/statistics/ars.py
# class ARS(object):
# 
#     from numpy import inf
# 
#     def __init__(self, logp):
# 
#         self.logp = logp
# 
#     def initialize(self, x, z0=-inf, zmax=inf):
# 
#         from numpy import array
# 
#         self.hull = Envelope(array(x), *self.logp(array(x)))
#         self.hull.z0 = z0
#         self.hull.zk = zmax
# 
#     def sample(self, maxiter=100):
# 
#         from numpy.random import random
# 
#         for i in range(maxiter):
# 
#             x = self.hull.sample()
#             l = self.hull.l(x)
#             u = self.hull.u(x)
#             w = random()
# 
#             if w <= exp(l - u): return x
# 
#             h, dh = self.logp(x)
# 
#             if w <= exp(h - u): return x
# 
#             self.hull.insert(x, h, dh)
# 
# class Gauss(LogProb):
# 
#     def __init__(self, mu, sigma=1.):
# 
#         self.mu = float(mu)
#         self.sigma = float(sigma)
# 
#     def __call__(self, x):
# 
#         return -0.5 * (x - self.mu) ** 2 / self.sigma ** 2, \
#                - (x - self.mu) / self.sigma ** 2


# Path: csb/test/cases/statistics/ars.py
import numpy
import csb.test as test
from csb.statistics.ars import ARS, Gauss




@test.functional
class TestARS(test.Case):

    def testNormal(self):
        mu = 5.
        sigma = 1.

        ars = ARS(Gauss(mu, sigma))