MomentGauge.Sampler.QuadratureSampler
Contents
MomentGauge.Sampler.QuadratureSampler
#
Module Contents#
Classes#
A sampler of the 2D uniform distribution on a square area \([a_x, b_x]*[a_y, b_y]\) based on the Block-wise Gauss_Legendre quadrature |
|
A sampler of the 2D distribution \(f(u_x,u_r) \propto u_r\) on a square area \([a_x, b_x]*[0, b_r]\) based on importance sampling. |
|
A sampler of the 3D uniform distribution on a cylinder. |
- class MomentGauge.Sampler.QuadratureSampler.Gauss_Legendre_Sampler2D(n_x=8, n_y=8, B_x=16, B_y=16)#
Bases:
MomentGauge.Sampler.Base.BaseSampler
A sampler of the 2D uniform distribution on a square area \([a_x, b_x]*[a_y, b_y]\) based on the Block-wise Gauss_Legendre quadrature
See
MomentGauge.Sampler.SamplerUtility.Gauss_Legendre_Quadrature_2D_Block()
for detailed information for the Block-wise Gauss_Legendre quadrature.domain: \(\mathbf{u} \in [a_x, b_x]*[a_y, b_y]\)
likelihood: \(f(\mathbf{u}) = \frac{1}{(b_x-a_x)(b_y-a_y)}\)
- Parameters:
n_x (int) – the order of Gauss Legendre quadrature in x dimension, default = 8
n_y (int) – the order of Gauss Legendre quadrature in y dimension, default = 8
B_x (int) – how many blocks are splitted in the x dimension, default = 16
B_y (int) – how many blocks are splitted in the y dimension, default = 16
- constant#
an empty dictionary.
- Type:
dict
- sample(betas)#
Generate samples from the uniform distribution on \((a_x, b_x)\times(a_y, b_y)\) with proper weights \(w_i\) such that
\begin{equation} \int_{a_y}^{b_y}\int_{a_x}^{b_x} \phi(u_x,u_y) f(u_x,u_y) d u_x d u_y \approx \sum_{i=1}^N w_i \phi(\mathbf{u}_i); \quad \mathbf{u}_i=\{u_{x,i},u_{y,i}\}, \end{equation}in which \(N = n_x\times n_y\times B_x\times B_y\)
- Parameters:
betas (float array of shape (4)) –
an array (a_x, b_x, a_y, b_y), in which
a_x : float - lower integration limit in x dimension
b_x : float - upper integration limit in x dimension
a_y : float - lower integration limit in y dimension
b_y : float - upper integration limit in y dimension
- Returns:
A tuple containing
samples: float array of shape (N,2) - N samples of 2-dim vectors \(\mathbf{u}_i\) draw from the distribution.
weights: float array of shape (N) - N non-negative weights \(w_i\) for each samples. The summation of weights equals to 1.
log_likelihoods: float array of shape (N) - N the log-likelihoods \(\log f(\mathbf{u}_i)\) for each samples
in which N = n_x*n_y*B_x*B_y
- Return type:
Tuple
- class MomentGauge.Sampler.QuadratureSampler.Gauss_Legendre_Sampler_Polar2D(n_x=8, n_r=8, B_x=16, B_r=16)#
Bases:
MomentGauge.Sampler.Base.BaseSampler
A sampler of the 2D distribution \(f(u_x,u_r) \propto u_r\) on a square area \([a_x, b_x]*[0, b_r]\) based on importance sampling.
The importance sampling is w.r.t
Sampler.QuadratureSampler.Gauss_Legendre_Sampler2D()
.domain: \(\mathbf{u} \in \{ (u_x,u_r) \ | \ u_x \in [a_x, b_x], \ u_r \in [0, b_r] \}\)
likelihood: \(f(\mathbf{u}) = \frac{2 u_r}{(b_x-a_x)b_r^2}\)
- Parameters:
n_x (int) – the order of Gauss Legendre quadrature in x dimension, default = 8
n_r (int) – the order of Gauss Legendre quadrature in r dimension, default = 8
B_x (int) – how many blocks are splitted in the x dimension, default = 16
B_r (int) – how many blocks are splitted in the r dimension, default = 16
- constant#
an empty dictionary.
- Type:
dict
- sample(betas)#
Generate samples from the distribution \(f(\mathbf{u})\) with proper weights \(w_i\) such that
\begin{equation} \int_{0}^{b_r} \int_{a_x}^{b_x} \phi_r(u_x,u_r) f(u_x,u_r) du_x du_r \approx \sum_{i=1}^N w_i \phi_r(\mathbf{u}_i); \quad \mathbf{u}_i=\{u_{x,i},u_{r,i}\}, \end{equation}in which \(w_i, \mathbf{u}_i\) are weights and \(N = n_x\times n_r\times B_x\times B_r\).
- Parameters:
betas (float array of shape (3)) –
an array (a_x, b_x, b_r), in which
a_x : float - lower integration limit in x dimension
b_x : float - upper integration limit in x dimension
b_r : float - upper integration limit in r dimension
- Returns:
A tuple containing
samples: float array of shape (N,2) - N samples of 2-dim vectors \(\mathbf{u}_i\) draw from the distribution.
weights: float array of shape (N) - N non-negative weights \(w_i\) for each samples. The summation of weights equals to 1.
log_likelihoods: float array of shape (N) - N the log-likelihoods \(\log f(\mathbf{u}_i)\) for each samples
in which N = n_x*n_y*B_x*B_y
- Return type:
Tuple
- class MomentGauge.Sampler.QuadratureSampler.Gauss_Legendre_Sampler_Polar3D(n_x=8, n_r=8, B_x=16, B_r=16)#
Bases:
Gauss_Legendre_Sampler_Polar2D
A sampler of the 3D uniform distribution on a cylinder.
The sampling based on the Block-wise Gauss_Legendre quadrature and importance sampling.
See
Sampler.SamplerUtility.Gauss_Legendre_Quadrature_2D_Block()
for detailed information for the Block-wise Gauss_Legendre quadrature.domain: \(\mathbf{u} \in \{ (u_x,u_y,u_z) \ | \ u_x \in [a_x, b_x], u_y^2 + u_z^2 \le b_r^2 \}\)
likelihood: \(f(\mathbf{u}) = \frac{1}{\pi(b_x-a_x)b_r^2}\)
- Parameters:
n_x (int) – the order of Gauss Legendre quadrature in x dimension, default = 8
n_r (int) – the order of Gauss Legendre quadrature in r dimension, default = 8
B_x (int) – how many blocks are splitted in the x dimension, default = 16
B_r (int) – how many blocks are splitted in the r dimension, default = 16
- constant#
an empty dictionary.
- Type:
dict
- sample(betas)#
Generate samples from the uniform distribution on the cylinder \(\mathbf{D} = \{ (u_x,u_y,u_z) \ | \ u_x \in [a_x, b_x], u_y^2 + u_z^2 \le b_r^2 \}\) with proper weights \(w_i\) such that
\begin{equation} \begin{split} \int_{\mathbf{D}} \phi(\mathbf{u}) f(\mathbf{u}) d^3 \mathbf{u} &= \int_{0}^{b_r} \int_{a_x}^{b_x} 2\pi u_r \phi_r(u_x,u_r) f_r(u_x,u_r) du_x du_r\\ &\approx \sum_{i=1}^N w_i \phi(\mathbf{u}_i); \quad \mathbf{u}_i=\{u_{x,i},u_{y,i},u_{z,i}\}, \end{split} \end{equation}in which
\begin{equation} \begin{split} \phi(\mathbf{u}) &= \phi(u_x, u_y, u_z) = \phi_r(u_x, u_r(u_y,u_z)) \\ f(\mathbf{u}) &= f(u_x, u_y, u_z) = f_r(u_x, u_r(u_y,u_z)); \quad u_r(u_y,u_z) = \sqrt{u_y^2+u_z^2} \\ \end{split} \end{equation}are both polar symmetric w.r.t the x axis, and \(N = n_x\times n_r\times B_x\times B_r\).
- Parameters:
betas (float array of shape (3)) –
an array (a_x, b_x, b_r), in which
a_x : float - lower integration limit in x dimension
b_x : float - upper integration limit in x dimension
b_r : float - upper integration limit in r dimension
- Returns:
A tuple containing
samples: float array of shape (N,3) - N samples of 3-dim vectors \(\mathbf{u}_i=\{u_{x,i},u_{y,i},u_{z,i}\}\) draw from the distribution. Notably these samples have \(u_{y,i} = u_{z,i}\) due to polar symmetry.
weights: float array of shape (N) - N non-negative weights \(w_i\) for each samples. The summation of weights equals to 1.
log_likelihoods: float array of shape (N) - N the log-likelihoods \(\log f(\mathbf{u}_i)\) for each samples
in which N = n_x*n_y*B_x*B_y
- Return type:
Tuple