def tets_distributions(): # not distributions d = numpy.ones((3,3)) assert(mkm.is_distribution(d) == False) d = mkm.delta_distribution(10) d[1] = 1 assert(mkm.is_distribution(d) == False) assert(mkm.is_distribution(mkm.delta_distribution(10),n=11) == False) assert(mkm.is_distribution(mkm.delta_distribution(10),n=10) == True) assert(mkm.relative_error(numpy.array([0.0001,1,1e-16]),numpy.array([0.001,1,1e-16]))>8.0)
def add_distributions(self,d): # vector shape if d.ndim == 1: if mkm.is_distribution(d) == False: raise Exception('not a probability distribution') new = {0: d} self.distributions.append(new) # matrix shape else: for i in range(d.shape[0]): if mkm.is_distribution(d[i,:]) == False: raise Exception('not a probability distribution') new = {0: d[i,:]} self.distributions.append(new)
def set_stationary(self, d): """ Set the stationary distribution. d: the stationary distribution """ if mkm.is_distribution(d) == False: raise Exception('not a probability distribution') self.sd = d
def set_stationary(self,d): """ Set the stationary distribution. d: the stationary distribution """ if mkm.is_distribution(d) == False: raise Exception('not a probability distribution') self.sd = d
def add_iteration(self, index, t, iteration): """ Add an iteration for a distribution. In the terminology of this class the iteration for a distribution at time t is defined by distribution*P^{t}. index: index of the distribution t: iteration time iteration: the iteration """ if mkm.is_distribution(iteration) == False: raise Exception('not a probability distribution') self.distributions[index][t] = iteration
def add_distributions(self, d): """ Add a number of distributions to the Markov chain. A distribution in the sense of this class is an initial distribution on the state space. d: An ndarray where each row is a distribution """ # vector shape if d.ndim == 1: if mkm.is_distribution(d) == False: raise Exception('not a probability distribution') new = {0: d} self.distributions.append(new) # matrix shape else: for i in range(d.shape[0]): if mkm.is_distribution(d[i, :]) == False: raise Exception('not a probability distribution') new = {0: d[i, :]} self.distributions.append(new)
def add_iteration(self,index,t,iteration): """ Add an iteration for a distribution. In the terminology of this class the iteration for a distribution at time t is defined by distribution*P^{t}. index: index of the distribution t: iteration time iteration: the iteration """ if mkm.is_distribution(iteration) == False: raise Exception('not a probability distribution') self.distributions[index][t] = iteration
def add_distributions(self,d): """ Add a number of distributions to the Markov chain. A distribution in the sense of this class is an initial distribution on the state space. d: An ndarray where each row is a distribution """ # vector shape if d.ndim == 1: if mkm.is_distribution(d) == False: raise Exception('not a probability distribution') new = {0: d} self.distributions.append(new) # matrix shape else: for i in range(d.shape[0]): if mkm.is_distribution(d[i,:]) == False: raise Exception('not a probability distribution') new = {0: d[i,:]} self.distributions.append(new)
def add_iteration(self,index,t,iteration): if mkm.is_distribution(iteration) == False: raise Exception('not a probability distribution') self.distributions[index][t] = iteration
def set_stationary_distribution(self,d): if mkm.is_distribution(d) == False: raise Exception('not a probability distribution') self.sd = d