def _simulate(self): # Note: the features matrix already exists, and is created by # the super class features = self.features n_samples, n_features = features.shape link = self.link u = features.dot(self.weights) # Add the intercept if necessary if self.intercept is not None: u += self.intercept # Compute the intensities if link == "identity": if np.any(u <= 0): raise ValueError(("features and weights leads to ,", "non-negative intensities for ", "Poisson.")) intensity = u else: intensity = np.exp(u) # Simulate the Poisson variables. We want it in float64 for # later computations, hence the next line. labels = np.empty(n_samples) labels[:] = poisson(intensity) self._set("labels", labels) return features, labels
def poisson(mean, shape=[]): """poisson(mean) or poisson(mean, [n, m, ...]) returns array of poisson distributed random integers with specified mean.""" if shape == []: shape = None return mt.poisson(mean, shape)
def test_scatter(self): """gnuplot.scatter test (interactive only)""" from numpy.random.mtrand import poisson if self.local: self.p = scatter(poisson(50, (1000, 2)))
def test_scatter(self): """gnuplot.scatter test (interactive only)""" from numpy.random.mtrand import poisson if self.local: self.p = scatter( poisson(50,(1000,2)) )