Ejemplo n.º 1
0
    def __init__(self, rate=1):
        """Create Poi(rate) distribution.

        :param rate The rate parameter.
        """

        # save params
        assert 0 < rate
        self.rate = rate

        # create distribution for sampling
        self.UG = UniformDist()
        super().__init__(DiscreteSpace(0, np.inf))
Ejemplo n.º 2
0
    def __init__(self, p=0.5):
        """Create Ber(p) distribution.

        :param p Probability that random var is true
        """

        # save params
        assert 0 <= p <= 1
        self.p = p

        # create distribution for sampling
        self.UG = UniformDist()
        super().__init__(DiscreteSpace([0, 1]))
Ejemplo n.º 3
0
    def __init__(self, a=1, b=3):
        """Create U(K) distribution.

        :param rate The rate parameter.
        """

        # save params
        assert b >= a
        self.a = a
        self.b = b

        # create distribution for sampling
        self.UG = UniformDist()
        super().__init__(DiscreteSpace(a, b + 1))
    def __init__(self, n = 1, p = 0.5):
        """Create Geom(p) distribution.

        :param n Which should be summed
        :param p Probability that random var is true
        """

        # save params
        assert 0 <= p <= 1
        assert 1 <= n
        self.p = p
        self.n = n

        # create distribution for sampling
        self.UG = UniformDist()
        super().__init__(DiscreteSpace(1, np.inf))
    def __init__(self, n=1, p=0.5):
        """Create Bin(n, p) distribution.

        :param n Which should be summed
        :param p Probability that random var is true
        """

        # save params
        assert 0 <= p <= 1
        assert 1 <= n
        self.p = p
        self.n = n

        # create distribution for sampling
        self.BG = BernDist(p)
        super().__init__(DiscreteSpace(np.arange(n + 1)))
Ejemplo n.º 6
0
    def __init__(self, alpha, A):
        """Create DPH(alpha, A) distribution.

        :param alpha probability vector 1xm
        :param A mxm matrix such that (I - A) is invertible.
        """

        # save params
        assert np.sum(alpha) == 1
        assert np.shape(A)[0] == np.shape(A)[1] == len(alpha)
        self.alpha = np.expand_dims(alpha, 0)
        self.A = np.array(A)
        self.m = np.shape(A)[1]

        # create distribution for sampling
        self.UG = UniformDist()
        super().__init__(DiscreteSpace(1, np.inf))
    def __init__(self, r=10, p=0.5):
        """Create NegBin(r, p) distribution.

        :param r Which should be summed
        :param p Probability that random var is true
        """

        # save params
        assert 0 <= p <= 1
        assert 0 <= r
        self.r = r
        self.p = p

        # create distribution for sampling
        self.GG = GammaDist(r, p / (1 - p))
        self.PG = PoissonDist(0.1)
        super().__init__(DiscreteSpace(0, np.inf))
    def __init__(self, n=20, r=150, N=300):
        """Create Hyp(n, r, N) distribution.

        :param n offset vars
        :param r binomaial offset
        :param N biggest number.
        """

        # save params
        self.r = r
        self.n = n
        self.N = N

        # generate upper and lower bound
        lb = np.maximum(0, r + n - N)
        ub = np.minimum(n, r)

        # create distribution for sampling
        self.UG = UniformDist()
        super().__init__(DiscreteSpace(lb, ub + 1))