|
bi-kappa 3.0.0
Monte Carlo particle samplers for plasma velocity and position distributions
|
Public Member Functions | |
| __init__ (self, int dimension, List[float] lower_bounds, List[float] upper_bounds, Callable density_function, int probe_points=4096, int max_reject_tries=200000) | |
| np.ndarray | __call__ (self, np.random.Generator rng) |
Public Attributes | |
| dimension = dimension | |
| lower_bounds = lower | |
| upper_bounds = upper | |
| density_function = density_function | |
| max_reject_tries = max_reject_tries | |
| float | density_upper_bound = self._estimate_density_upper_bound(probe_points) |
Static Public Attributes | |
| int | PROBE_SEED = 1337 |
Protected Member Functions | |
| float | _density (self, np.ndarray x) |
| float | _estimate_density_upper_bound (self, int probe_points) |
Samples positions in 1D/2D/3D from a user density rho(x) by rejection sampling. The domain is the axis-aligned box lower_bounds <= x <= upper_bounds, a hard support. density_function takes a list of length ``dimension`` and returns a finite, non-negative value, positive somewhere in the box; it need not be normalized. The rejection envelope is the largest density found at probe_points uniform points, drawn from a fixed seed so that two identical constructions give the same envelope, times a 5% margin. A peak narrow enough to fall between the probes is undersampled without warning. Each call returns an array of length ``dimension``.
Definition at line 85 of file general_generators.py.
| general_generators.GeneralPositionGenerator.__init__ | ( | self, | |
| int | dimension, | ||
| List[float] | lower_bounds, | ||
| List[float] | upper_bounds, | ||
| Callable | density_function, | ||
| int | probe_points = 4096, | ||
| int | max_reject_tries = 200000 ) |
Definition at line 100 of file general_generators.py.
| np.ndarray general_generators.GeneralPositionGenerator.__call__ | ( | self, | |
| np.random.Generator | rng ) |
Generate one position, an array of length ``dimension``.
Definition at line 148 of file general_generators.py.
References _density(), density_upper_bound, dimension, lower_bounds, max_reject_tries, general_generators.GeneralVelocityGenerator.max_reject_tries, and upper_bounds.
|
protected |
Definition at line 129 of file general_generators.py.
References density_function.
Referenced by __call__(), and _estimate_density_upper_bound().
|
protected |
Largest density at probe_points uniform points in the box, with a 5% margin.
Definition at line 138 of file general_generators.py.
References _density(), dimension, lower_bounds, PROBE_SEED, and upper_bounds.
| general_generators.GeneralPositionGenerator.density_function = density_function |
Definition at line 122 of file general_generators.py.
Referenced by _density().
| float general_generators.GeneralPositionGenerator.density_upper_bound = self._estimate_density_upper_bound(probe_points) |
Definition at line 125 of file general_generators.py.
Referenced by __call__().
| general_generators.GeneralPositionGenerator.dimension = dimension |
Definition at line 119 of file general_generators.py.
Referenced by __call__(), and _estimate_density_upper_bound().
| general_generators.GeneralPositionGenerator.lower_bounds = lower |
Definition at line 120 of file general_generators.py.
Referenced by __call__(), and _estimate_density_upper_bound().
| general_generators.GeneralPositionGenerator.max_reject_tries = max_reject_tries |
Definition at line 123 of file general_generators.py.
Referenced by general_generators.FieldAlignedVelocityGenerator.__call__(), __call__(), and general_generators.FieldAlignedVelocityGenerator.sample_speed_sq().
|
static |
Definition at line 98 of file general_generators.py.
Referenced by _estimate_density_upper_bound().
| general_generators.GeneralPositionGenerator.upper_bounds = upper |
Definition at line 121 of file general_generators.py.
Referenced by __call__(), and _estimate_density_upper_bound().