:py:mod:`MomentGauge.Sampler.QuadratureSampler` =============================================== .. py:module:: MomentGauge.Sampler.QuadratureSampler Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: MomentGauge.Sampler.QuadratureSampler.Gauss_Legendre_Sampler2D MomentGauge.Sampler.QuadratureSampler.Gauss_Legendre_Sampler_Polar2D MomentGauge.Sampler.QuadratureSampler.Gauss_Legendre_Sampler_Polar3D .. py:class:: Gauss_Legendre_Sampler2D(n_x=8, n_y=8, B_x=16, B_y=16) Bases: :py:obj:`MomentGauge.Sampler.Base.BaseSampler` A sampler of the 2D uniform distribution on a square area :math:`[a_x, b_x]*[a_y, b_y]` based on the Block-wise Gauss_Legendre quadrature See :func:`MomentGauge.Sampler.SamplerUtility.Gauss_Legendre_Quadrature_2D_Block` for detailed information for the Block-wise Gauss_Legendre quadrature. **domain**: :math:`\mathbf{u} \in [a_x, b_x]*[a_y, b_y]` **likelihood**: :math:`f(\mathbf{u}) = \frac{1}{(b_x-a_x)(b_y-a_y)}` :param n_x: the order of Gauss Legendre quadrature in x dimension, default = 8 :type n_x: int :param n_y: the order of Gauss Legendre quadrature in y dimension, default = 8 :type n_y: int :param B_x: how many blocks are splitted in the x dimension, default = 16 :type B_x: int :param B_y: how many blocks are splitted in the y dimension, default = 16 :type B_y: int .. attribute:: constant an empty dictionary. :type: dict .. py:method:: sample(betas) Generate samples from the uniform distribution on :math:`(a_x, b_x)\times(a_y, b_y)` with proper weights :math:`w_i` such that .. math:: :nowrap: \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 :math:`N = n_x\times n_y\times B_x\times B_y` :param betas: 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 :type betas: float array of shape (4) :returns: A tuple containing **samples**: *float array of shape (N,2)* - N samples of 2-dim vectors :math:`\mathbf{u}_i` draw from the distribution. **weights**: *float array of shape (N)* - N non-negative weights :math:`w_i` for each samples. The summation of weights equals to 1. **log_likelihoods**: *float array of shape (N)* - N the log-likelihoods :math:`\log f(\mathbf{u}_i)` for each samples in which N = n_x*n_y*B_x*B_y :rtype: Tuple .. py:class:: Gauss_Legendre_Sampler_Polar2D(n_x=8, n_r=8, B_x=16, B_r=16) Bases: :py:obj:`MomentGauge.Sampler.Base.BaseSampler` A sampler of the 2D distribution :math:`f(u_x,u_r) \propto u_r` on a square area :math:`[a_x, b_x]*[0, b_r]` based on importance sampling. The importance sampling is w.r.t :func:`Sampler.QuadratureSampler.Gauss_Legendre_Sampler2D`. **domain**: :math:`\mathbf{u} \in \{ (u_x,u_r) \ | \ u_x \in [a_x, b_x], \ u_r \in [0, b_r] \}` **likelihood**: :math:`f(\mathbf{u}) = \frac{2 u_r}{(b_x-a_x)b_r^2}` :param n_x: the order of Gauss Legendre quadrature in x dimension, default = 8 :type n_x: int :param n_r: the order of Gauss Legendre quadrature in r dimension, default = 8 :type n_r: int :param B_x: how many blocks are splitted in the x dimension, default = 16 :type B_x: int :param B_r: how many blocks are splitted in the r dimension, default = 16 :type B_r: int .. attribute:: constant an empty dictionary. :type: dict .. py:method:: sample(betas) Generate samples from the distribution :math:`f(\mathbf{u})` with proper weights :math:`w_i` such that .. math:: :nowrap: \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 :math:`w_i, \mathbf{u}_i` are weights and :math:`N = n_x\times n_r\times B_x\times B_r`. :param betas: 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 :type betas: float array of shape (3) :returns: A tuple containing **samples**: *float array of shape (N,2)* - N samples of 2-dim vectors :math:`\mathbf{u}_i` draw from the distribution. **weights**: *float array of shape (N)* - N non-negative weights :math:`w_i` for each samples. The summation of weights equals to 1. **log_likelihoods**: *float array of shape (N)* - N the log-likelihoods :math:`\log f(\mathbf{u}_i)` for each samples in which N = n_x*n_y*B_x*B_y :rtype: Tuple .. py:class:: Gauss_Legendre_Sampler_Polar3D(n_x=8, n_r=8, B_x=16, B_r=16) Bases: :py:obj:`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 :func:`Sampler.SamplerUtility.Gauss_Legendre_Quadrature_2D_Block` for detailed information for the Block-wise Gauss_Legendre quadrature. **domain**: :math:`\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**: :math:`f(\mathbf{u}) = \frac{1}{\pi(b_x-a_x)b_r^2}` :param n_x: the order of Gauss Legendre quadrature in x dimension, default = 8 :type n_x: int :param n_r: the order of Gauss Legendre quadrature in r dimension, default = 8 :type n_r: int :param B_x: how many blocks are splitted in the x dimension, default = 16 :type B_x: int :param B_r: how many blocks are splitted in the r dimension, default = 16 :type B_r: int .. attribute:: constant an empty dictionary. :type: dict .. py:method:: sample(betas) Generate samples from the uniform distribution on the cylinder :math:`\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 :math:`w_i` such that .. math:: :nowrap: \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 .. math:: :nowrap: \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 :math:`N = n_x\times n_r\times B_x\times B_r`. :param betas: 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 :type betas: float array of shape (3) :returns: A tuple containing **samples**: *float array of shape (N,3)* - N samples of 3-dim vectors :math:`\mathbf{u}_i=\{u_{x,i},u_{y,i},u_{z,i}\}` draw from the distribution. Notably these samples have :math:`u_{y,i} = u_{z,i}` due to polar symmetry. **weights**: *float array of shape (N)* - N non-negative weights :math:`w_i` for each samples. The summation of weights equals to 1. **log_likelihoods**: *float array of shape (N)* - N the log-likelihoods :math:`\log f(\mathbf{u}_i)` for each samples in which N = n_x*n_y*B_x*B_y :rtype: Tuple