### Navigation

- index
- modules |
- next |
- previous |
- Statistics »

# Discrete Gaussian Samplers for \(\ZZ[x]\)

This class realizes oracles which returns polynomials in \(\ZZ[x]\) where each coefficient is sampled independently with a probability proportional to \(\exp(-(x-c)²/(2σ²))\).

AUTHORS:

- Martin Albrecht, Robert Fitzpatrick, Daniel Cabracas, Florian Göpfert, Michael Schneider: initial version

EXAMPLE:

    sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler
    sage: sigma = 3.0; n=1000
    sage: l = [DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 64, sigma)() for _ in xrange(n)]
    sage: l = map(lambda f: vector(f).norm().n(), l)
    sage: mean(l), sqrt(64)*sigma
    (23.83..., 24.0...)

class `sage.stats.distributions.discrete_gaussian_polynomial.``DiscreteGaussianDistributionPolynomialSampler`(P, n, sigma)

  Bases: `sage.structure.sage_object.SageObject`

  Discrete Gaussian sampler for polynomials.

  EXAMPLE:

      sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler
      sage: DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)()
      3*x^7 + 3*x^6 - 3*x^5 - x^4 - 5*x^2 + 3
      sage: gs = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)
      sage: [gs() for _ in xrange(3)]
      [4*x^7 + 4*x^6 - 4*x^5 + 2*x^4 + x^3 - 4*x + 7, -5*x^6 + 4*x^5 - 3*x^3 + 4*x^2 + x, 2*x^7 + 2*x^6 + 2*x^5 - x^4 - 2*x^2 + 3*x + 1]

  `__init__`(P, n, sigma)

    Construct a sampler for univariate polynomials of degree `n-1` where coefficients are drawn independently with standard deviation `sigma`.

    INPUT:

    - `P` - a univariate polynomial ring over the Integers
    - `n` - number of coefficients to be sampled
    - `sigma` - coefficients \(x\) are accepted with probability proportional to \(\exp(-x²/(2σ²))\). If an object of type `sage.stats.distributions.discrete_gaussian_integer.DiscreteGaussianDistributionIntegerSampler` is passed, then this sampler is used to sample coefficients.

    EXAMPLE:

        sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler
        sage: DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)()
        3*x^7 + 3*x^6 - 3*x^5 - x^4 - 5*x^2 + 3
        sage: gs = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)
        sage: [gs() for _ in xrange(3)]
        [4*x^7 + 4*x^6 - 4*x^5 + 2*x^4 + x^3 - 4*x + 7, -5*x^6 + 4*x^5 - 3*x^3 + 4*x^2 + x, 2*x^7 + 2*x^6 + 2*x^5 - x^4 - 2*x^2 + 3*x + 1]

  `__call__`()

    Return a new sample.

    EXAMPLE:

        sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler
        sage: sampler = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 12.0)
        sage: sampler()
        8*x^7 - 11*x^5 - 19*x^4 + 6*x^3 - 34*x^2 - 21*x + 9

### Navigation

- index
- modules |
- next |
- previous |
- Statistics »