def sample(self, size=1):
        """Generate samples of the random variable.

        Parameters
        ----------
        size : int
            The number of samples to generate.

        Returns
        -------
        :obj:`numpy.ndarray` of int or int
            The samples of the random variable. If `size == 1`, then
            the returned value will not be wrapped in an array.
        """
        samples = scipy.stats.bernoulli.rvs(self.p, size=size)
        if size == 1:
            return samples[0]
        return samples
Generate samples of the random variable.

        Parameters
        ----------
        size : int
            The number of samples to generate.

        Returns
        -------
        :obj:`numpy.ndarray` of int or int
            The samples of the random variable. If `size == 1`, then
            the returned value will not be wrapped in an array.