1
1
# -*- coding: utf-8 -*-
2
- r""" Discrete Gaussian Samplers over Lattices
2
+ r"""
3
+ Discrete Gaussian Samplers over Lattices
3
4
4
5
This file implements oracles which return samples from a lattice following a
5
6
discrete Gaussian distribution. That is, if `\sigma` is big enough relative to
6
7
the provided basis, then vectors are returned with a probability proportional
7
8
to `\exp(-|x - c|_2^2 / (2\sigma^2))`. More precisely lattice vectors in `x \in
8
9
\Lambda` are returned with probability:
9
10
10
- `\exp(-|x - c|_2^2 / (2\sigma^2)) / (\Sigma_{x \in \Lambda} \exp(-|x|_2^2 /
11
- (2\sigma^2)))`
11
+ .. MATH::
12
+
13
+ `\frac{\exp(-|x - c|_2^2 / (2\sigma^2))}{\sum_{x \in \Lambda} \exp(-|x|_2^2 /
14
+ (2\sigma^2))}`
12
15
13
16
AUTHORS:
14
17
@@ -189,8 +192,8 @@ def compute_precision(precision, sigma):
189
192
190
193
def _normalisation_factor_zz (self , tau = None , prec = None ):
191
194
r"""
192
- This function returns an approximation of `\Sigma_ {x \in B}
193
- \exp(-|x|_2^2 / (2\sigma² ))`, i.e. the normalisation factor such that the sum
195
+ This function returns an approximation of `\sum_ {x \in B}
196
+ \exp(-|x|_2^2 / (2\sigma^2 ))`, i.e. the normalization factor such that the sum
194
197
over all probabilities is 1 for `B`, via Poisson summation.
195
198
196
199
@@ -270,7 +273,6 @@ def _normalisation_factor_zz(self, tau=None, prec=None):
270
273
...
271
274
NotImplementedError: lattice must be integral for now
272
275
"""
273
-
274
276
# If σ > 1:
275
277
# We use the Fourier transform g(t) of f(x) = exp(-k^2 / 2σ^2), but
276
278
# taking the norm of vector t^2 as input, and with norm_factor factored.
@@ -350,7 +352,7 @@ def f_or_hat(x):
350
352
@cached_method
351
353
def _maximal_r (self ):
352
354
r"""
353
- This function computes the largest value `r > 0` such that `Σ - r²BBᵀ `
355
+ This function computes the largest value `r > 0` such that `\Sigma - r^2BB^@ `
354
356
is positive definite.
355
357
356
358
This is equivalent to finding `\lambda_1(\Sigma / Q) = 1 / \lambda_n(Q
@@ -401,7 +403,7 @@ def _randomise(self, v):
401
403
402
404
def __init__ (self , B , sigma = 1 , c = 0 , r = None , precision = None , sigma_basis = False ):
403
405
r"""
404
- Construct a discrete Gaussian sampler over the lattice `\LAmbda (B)`
406
+ Construct a discrete Gaussian sampler over the lattice `\Lambda (B)`
405
407
with parameter ``sigma`` and center `c`.
406
408
407
409
INPUT:
@@ -583,7 +585,7 @@ def _precompute_data(self):
583
585
[0 1 0]
584
586
[0 0 1]
585
587
586
- .. note :
588
+ .. NOTE: :
587
589
588
590
Do not call this method directly, it is called automatically from
589
591
:func:`DiscreteGaussianDistributionLatticeSampler.__init__`.
@@ -795,7 +797,7 @@ def _call_in_lattice(self):
795
797
sage: norm(mean_L.n() - D.c()) < 0.25
796
798
True
797
799
798
- .. note ::
800
+ .. NOTE ::
799
801
800
802
Do not call this method directly, call
801
803
:func:`DiscreteGaussianDistributionLatticeSampler.__call__` instead.
@@ -815,7 +817,7 @@ def _call(self):
815
817
sage: norm(mean_L.n() - D.c()) < 0.25
816
818
True
817
819
818
- .. note ::
820
+ .. NOTE ::
819
821
820
822
Do not call this method directly, call
821
823
:func:`DiscreteGaussianDistributionLatticeSampler.__call__` instead.
@@ -837,7 +839,7 @@ def _call(self):
837
839
838
840
def add_offline_samples (self , cnt = 1 ):
839
841
"""
840
- Precompute samples from `B^{-1}D_1` to be used in :meth:`_call_non_spherical`
842
+ Precompute samples from `B^{-1}D_1` to be used in :meth:`_call_non_spherical`.
841
843
842
844
EXAMPLES::
843
845
@@ -868,7 +870,7 @@ def _call_non_spherical(self):
868
870
sage: norm(mean_L.n() - D.c()) < 0.25
869
871
True
870
872
871
- .. note ::
873
+ .. NOTE ::
872
874
873
875
Do not call this method directly, call
874
876
:func:`DiscreteGaussianDistributionLatticeSampler.__call__` instead.
0 commit comments