def poisson_noise(intensity, seed=None):
    r"""Poisson distributed noise with given intensity.

    Parameters
    ----------
    intensity : `TensorSpace` or `ProductSpace` element
        The intensity (usually called lambda) parameter of the noise.

    Returns
    -------
    poisson_noise : ``intensity.space`` element
        Poisson distributed random variable.
    seed : int, optional
        Random seed to use for generating the noise.
        For ``None``, use the current seed.

    Notes
    -----
    For a Poisson distributed random variable :math:`X` with intensity
    :math:`\lambda`, the probability of it taking the value
    :math:`k \in \mathbb{N}_0` is given by

    .. math::
        \frac{\lambda^k e^{-\lambda}}{k!}

    Note that the function only takes integer values.

    See Also
    --------
    white_noise
    salt_pepper_noise
    uniform_noise
    numpy.random.poisson
    """
    from odl.space import ProductSpace

    with NumpyRandomSeed(seed):
        if isinstance(intensity.space, ProductSpace):
            values = [poisson_noise(subintensity)
                      for subintensity in intensity]
        else:
            values = np.random.poisson(intensity.asarray())

    return intensity.space.element(values)
r"""Poisson distributed noise with given intensity.

    Parameters
    ----------
    intensity : `TensorSpace` or `ProductSpace` element
        The intensity (usually called lambda) parameter of the noise.

    Returns
    -------
    poisson_noise : ``intensity.space`` element
        Poisson distributed random variable.
    seed : int, optional
        Random seed to use for generating the noise.
        For ``None``, use the current seed.

    Notes
    -----
    For a Poisson distributed random variable :math:`X` with intensity
    :math:`\lambda`, the probability of it taking the value
    :math:`k \in \mathbb{N}_0` is given by

    .. math::
        \frac{\lambda^k e^{-\lambda}}{k!}

    Note that the function only takes integer values.

    See Also
    --------
    white_noise
    salt_pepper_noise
    uniform_noise
    numpy.random.poisson