'Generate random samples from the model.
Currently, this is implemented only for gaussian and tophat kernels.
Parameters
n_samples : int, optional
Number of samples to generate. Defaults to 1.
random_state : int, RandomState instance or None. default to None
If int, random_state is the seed used by the random number
generator; If RandomState instance, random_state is the random
number generator; If None, the random number generator is the
RandomState instance used by `np.random`.
Returns
X : array_like, shape (n_samples, n_features)
List of samples.'

def sample(self, n_samples=1, random_state=None):

    if (self.kernel not in ['gaussian', 'tophat']):
        raise NotImplementedError()
    data = np.asarray(self.tree_.data)
    rng = check_random_state(random_state)
    i = rng.randint(data.shape[0], size=n_samples)
    if (self.kernel == 'gaussian'):
        return np.atleast_2d(rng.normal(data[i], self.bandwidth))
    elif (self.kernel == 'tophat'):
        dim = data.shape[1]
        X = rng.normal(size=(n_samples, dim))
        s_sq = row_norms(X, squared=True)
        correction = (((gammainc((0.5 * dim), (0.5 * s_sq)) ** (1.0 / dim)) * self.bandwidth) / np.sqrt(s_sq))
        return (data[i] + (X * correction[:, np.newaxis]))
