Ask Your Question

Revision history [back]

It seems DiscreteGaussianDistributionPolynomialSampler is flexible enough to accept the quotient ring in the question instead of a polynomial ring over the integers.

So one could do directly:

sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler

sage: R.<X> = PolynomialRing(GF(13))
sage: Y.<x> = R.quotient(X^1024 + 1)
sage: Y
Univariate Quotient Polynomial Ring in x over Finite Field of size 13 with modulus X^1024 + 1

sage: Q = DiscreteGaussianDistributionPolynomialSampler(Y, 8, 3.0)()
sage: Q
2*x^6 + 10*x^5 + 2*x^4 + 5*x^3 + 9*x + 7
sage: Q.parent()
Univariate Quotient Polynomial Ring in x over Finite Field of size 13 with modulus X^1024 + 1

Or, having started with ZZ['x'], one could convert to Y afterwards as in @castor's answer.

sage: P = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)()
sage: Q = Y(P)

sage: P
-6*x^7 - x^6 - 2*x^5 - 3*x^4 - 3*x^3 + 3*x + 2
sage: Q
7*x^7 + 12*x^6 + 11*x^5 + 10*x^4 + 10*x^3 + 3*x + 2

sage: P.parent()
Univariate Polynomial Ring in x over Integer Ring
sage: Q.parent()
Univariate Quotient Polynomial Ring in x over Finite Field of size 13 with modulus X^1024 + 1

sage: Q = DiscreteGaussianDistributionPolynomialSampler(Y, 8, 3.0)()
sage: Q
2*x^6 + 10*x^5 + 2*x^4 + 5*x^3 + 9*x + 7
sage: Q.parent()
Univariate Quotient Polynomial Ring in x over Finite Field of size 13 with modulus X^1024 + 1