Skip to content

Commit ad7ee31

Browse files
author
Release Manager
committed
gh-36581: `sage/stats/distributions`: Implement non-spherical Gaussian sampling over lattices I implemented non-spherical Gaussian sampling over lattices. It's useful for cryptography. ~~There are some TODOs that I hope to fix as soon as possible before merging, hence it's in draft status.~~ Done! There are some missing features e.g. when $B$ is not full-rank, or computing the normalisation factor for non-integral lattices, etc. But those should be easy to fix. Suggestions to variable naming would be appreciated too :) TODO: - [x] Finish writing doctest - [x] Support taking a basis $B$ and compute $\Sigma = BB^T$ instead. - [x] Allow setting $c$ dynamically. - [x] Fix merge conflicts :( - [x] Fix linting issues, coding style issues, ... URL: #36581 Reported by: grhkm21 Reviewer(s): grhkm21, Travis Scrimshaw
2 parents b575734 + 5c51f54 commit ad7ee31

File tree

6 files changed

+580
-138
lines changed

6 files changed

+580
-138
lines changed

src/doc/en/reference/references/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5137,6 +5137,11 @@ REFERENCES:
51375137
small Schroeder paths*, JCTA 125 (2014), 357-378,
51385138
:doi:`10.1016/j.jcta.2014.04.002`
51395139
5140+
.. [Pei2010] Peikert, C. (2010). An Efficient and Parallel Gaussian Sampler for
5141+
Lattices. In: Rabin, T. (eds) Advances in Cryptology – CRYPTO 2010.
5142+
CRYPTO 2010. Lecture Notes in Computer Science, vol 6223. Springer,
5143+
Berlin, Heidelberg. :doi:`10.1007/978-3-642-14623-7_5`
5144+
51405145
.. [Pen2012] \R. Pendavingh, On the evaluation at `(-i, i)` of the
51415146
Tutte polynomial of a binary matroid. Preprint:
51425147
:arxiv:`1203.0910`

src/sage/stats/all.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sage.stats.distributions.catalog as distributions
12

23
from .r import ttest
34
from .basic_stats import (mean, mode, std, variance, median, moving_average)

src/sage/stats/distributions/all.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# We lazy_import the following modules since they import numpy which
2+
# slows down sage startup
3+
from sage.misc.lazy_import import lazy_import
4+
lazy_import("sage.stats.distributions.discrete_gaussian_integer", ["DiscreteGaussianDistributionIntegerSampler"])
5+
lazy_import("sage.stats.distributions.discrete_gaussian_lattice", ["DiscreteGaussianDistributionLatticeSampler"])
6+
lazy_import("sage.stats.distributions.discrete_gaussian_polynomial", ["DiscreteGaussianDistributionPolynomialSampler"])
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
r"""
2+
Index of distributions
3+
4+
This catalogue includes the samplers for statistical distributions listed below.
5+
6+
Let ``<tab>`` indicate pressing the :kbd:`Tab` key. So begin by typing
7+
``algebras.<tab>`` to the see the currently implemented named algebras.
8+
9+
- :class:`distributions.discrete_gaussian_integer.DiscreteGaussianDistributionIntegerSampler
10+
<sage.stats.distributions.discrete_gaussian_integer.DiscreteGaussianDistributionIntegerSampler>`
11+
- :class:`distributions.discrete_gaussian_lattice.DiscreteGaussianDistributionLatticeSampler
12+
<sage.stats.distributions.discrete_gaussian_lattice.DiscreteGaussianDistributionLatticeSampler>`
13+
- :class:`distributions.discrete_gaussian_polynomial.DiscreteGaussianDistributionPolynomialSampler
14+
<sage.stats.distributions.discrete_gaussian_polynomial.DiscreteGaussianDistributionPolynomialSampler>`
15+
16+
To import these names into the global namespace, use::
17+
18+
sage: from sage.stats.distributions.catalog import *
19+
20+
"""
21+
#*****************************************************************************
22+
# Copyright (C) 2024 Gareth Ma <[email protected]>
23+
#
24+
# Distributed under the terms of the GNU General Public License (GPL),
25+
# version 2 or later (at your preference).
26+
#
27+
# http://www.gnu.org/licenses/
28+
#*****************************************************************************
29+
30+
from sage.misc.lazy_import import lazy_import
31+
lazy_import("sage.stats.distributions.discrete_gaussian_integer", ["DiscreteGaussianDistributionIntegerSampler"])
32+
lazy_import("sage.stats.distributions.discrete_gaussian_lattice", ["DiscreteGaussianDistributionLatticeSampler"])
33+
lazy_import("sage.stats.distributions.discrete_gaussian_polynomial", ["DiscreteGaussianDistributionPolynomialSampler"])
34+
del lazy_import

0 commit comments

Comments
 (0)