Stateless, position-keyed, spatially-correlated Gaussian random field. More...
#include "spatial-gaussian-field.h"
Classes | |
| struct | Window |
| Filter window of one sampling position (grid origin, separable weights and their L2 normalization), computed once with ComputeWindow() and reusable with SampleWindow() for every field sampled at that position. More... | |
Public Types | |
| enum class | CellGenerator { BoxMuller , IrwinHall } |
| Per-cell N(0,1) generator of the white-noise background. More... | |
| enum class | Salt : uint64_t { LOS_NLOS_STATE = 1 , O2I_STATE = 2 , SHADOW_FADING = 3 , O2I_PENETRATION = 4 , CHANNEL_PARAMETERS = 5 } |
| Salts of the fields of every model sampling a SpatialGaussianField. More... | |
Public Member Functions | |
| SpatialGaussianField (Salt salt, CellGenerator generator=CellGenerator::BoxMuller) | |
| Construct a field. | |
| double | Sample (uint64_t fieldKey, const Vector &position, double corrDist) const |
| Sample the spatially-correlated field at a position; a non-positive correlation distance degrades to an uncorrelated, position-repeatable draw. | |
| double | SampleUniform (uint64_t fieldKey, const Vector &position, double corrDist) const |
| Sample the field at a position and map it to a U(0,1) variate through the standard normal CDF, which preserves the spatial correlation of the underlying Gaussian field. | |
| double | SampleWindow (uint64_t fieldKey, const Window &window) const |
| Sample the field through a precomputed filter window. | |
Static Public Member Functions | |
| static Window | ComputeWindow (const Vector &position, double corrDist) |
| Compute the filter window of a sampling position. | |
Static Public Attributes | |
| static constexpr std::size_t | WINDOW_CELLS = 14 |
| Number of grid cells per dimension of a filter window. | |
Private Member Functions | |
| double | CellFromPrefix (uint64_t prefix, int64_t ix, int64_t iy) const |
| Deterministic N(0,1) value of one cell of the field. | |
| uint64_t | Prefix (uint64_t fieldKey) const |
| Hash prefix of one field, mixing the global RNG seed and run, the salt and the field key once for all cells (see CellFromPrefix()). | |
| double | SampleWindowFromPrefix (uint64_t prefix, const Window &window) const |
| Sample the field through a precomputed filter window. | |
Static Private Member Functions | |
| static uint64_t | SplitMix64 (uint64_t x) |
| SplitMix64 mixing round. | |
Private Attributes | |
| CellGenerator | m_generator |
| per-cell N(0,1) generator | |
| uint64_t | m_salt |
| class-specific salt | |
Stateless, position-keyed, spatially-correlated Gaussian random field.
The value at a point is a pure function of its coordinates, the global RNG seed and run, a class-specific salt and a per-field key, so every instance and every call observes the same realization, even when the models sampling it are regenerated (e.g. by a REM generator). This suits the drop-based spatial consistency of 3GPP TR 38.901 Sec. 7.6.3.1, and the absence of mutable state makes the field thread-safe.
The field is white noise on a fixed grid (one hashed N(0,1) value per cell) filtered with a separable exponential kernel, L2-normalized so that every position has an exactly N(0,1) marginal, with the decay length scaled so that the autocorrelation equals 1/e at the correlation distance as the exp(-d/dcor) of TR 38.901.
Definition at line 43 of file spatial-gaussian-field.h.
|
strong |
Per-cell N(0,1) generator of the white-noise background.
| Enumerator | |
|---|---|
| BoxMuller | Box-Muller transform of two 53-bit uniforms. |
| IrwinHall | Standardized sum of the four 16-bit chunks of the hashed state (Irwin-Hall), cheaper than Box-Muller; the windowed sum of Sample() restores a Gaussian marginal. |
Definition at line 47 of file spatial-gaussian-field.h.
|
strong |
Salts of the fields of every model sampling a SpatialGaussianField.
The salt is hashed into every cell, so fields of different salts are statistically independent even when keyed on the same field key (e.g. the same site). Listing them in one place keeps them distinct.
| Enumerator | |
|---|---|
| LOS_NLOS_STATE | LOS/NLOS state, ThreeGppChannelConditionModel. |
| O2I_STATE | Indoor state and building type, ThreeGppChannelConditionModel. |
| SHADOW_FADING | Shadow fading, ThreeGppPropagationLossModel. |
| O2I_PENETRATION | Indoor distance and penetration loss, ThreeGppPropagationLossModel. |
| CHANNEL_PARAMETERS | LSP, cluster and ray variables, ThreeGppChannelModel. |
Definition at line 79 of file spatial-gaussian-field.h.
|
explicit |
Construct a field.
| salt | Salt of the model owning the field, see Salt. |
| generator | The per-cell N(0,1) generator. |
Definition at line 20 of file spatial-gaussian-field.cc.
References m_generator, and m_salt.
|
private |
Deterministic N(0,1) value of one cell of the field.
| prefix | Hash prefix of the field, see Prefix(). |
| ix | Integer grid x-coordinate of the cell. |
| iy | Integer grid y-coordinate of the cell. |
Definition at line 45 of file spatial-gaussian-field.cc.
References BoxMuller, m_generator, and SplitMix64().
Referenced by Sample(), and SampleWindowFromPrefix().
|
static |
Compute the filter window of a sampling position.
| position | The sampling position (only x and y are used). |
| corrDist | The correlation distance, must be positive. |
Definition at line 68 of file spatial-gaussian-field.cc.
References ns3::SpatialGaussianField::Window::invL2Norm, ns3::SpatialGaussianField::Window::ix, ns3::SpatialGaussianField::Window::iy, WINDOW_CELLS, ns3::SpatialGaussianField::Window::wx, and ns3::SpatialGaussianField::Window::wy.
Referenced by ns3::tests::SpatialGaussianFieldDeterminismTestCase::DoRun(), ns3::tests::SpatialGaussianFieldStatisticsTestCase::ExactAutocorrelation(), Sample(), and ns3::ThreeGppChannelModel::SampleSpatiallyCorrelatedNormal().
|
private |
Hash prefix of one field, mixing the global RNG seed and run, the salt and the field key once for all cells (see CellFromPrefix()).
| fieldKey | Per-field key, see Sample(). |
Definition at line 36 of file spatial-gaussian-field.cc.
References ns3::RngSeedManager::GetRun(), ns3::RngSeedManager::GetSeed(), m_salt, and SplitMix64().
Referenced by Sample(), and SampleWindow().
| double ns3::SpatialGaussianField::Sample | ( | uint64_t | fieldKey, |
| const Vector & | position, | ||
| double | corrDist ) const |
Sample the spatially-correlated field at a position; a non-positive correlation distance degrades to an uncorrelated, position-repeatable draw.
| fieldKey | Per-field key selecting one independent realization (e.g. packed site id and slot). |
| position | The sampling position (only x and y are used). |
| corrDist | The correlation distance at which the autocorrelation equals 1/e. |
Definition at line 127 of file spatial-gaussian-field.cc.
References CellFromPrefix(), ComputeWindow(), Prefix(), and SampleWindowFromPrefix().
Referenced by ns3::tests::SpatialGaussianFieldDeterminismTestCase::DoRun(), ns3::ThreeGppPropagationLossModel::GetO2iHighPenetrationLoss(), ns3::ThreeGppPropagationLossModel::GetO2iLowPenetrationLoss(), ns3::ThreeGppPropagationLossModel::SampleSpatiallyCorrelatedNormal(), and SampleUniform().
| double ns3::SpatialGaussianField::SampleUniform | ( | uint64_t | fieldKey, |
| const Vector & | position, | ||
| double | corrDist ) const |
Sample the field at a position and map it to a U(0,1) variate through the standard normal CDF, which preserves the spatial correlation of the underlying Gaussian field.
| fieldKey | Per-field key, see Sample(). |
| position | The sampling position (only x and y are used). |
| corrDist | The correlation distance, see Sample(). |
Definition at line 145 of file spatial-gaussian-field.cc.
References Sample().
Referenced by ns3::ThreeGppChannelConditionModel::ComputeChannelCondition(), ns3::ThreeGppChannelConditionModel::ComputeO2i(), and ns3::tests::SpatialGaussianFieldDeterminismTestCase::DoRun().
Sample the field through a precomputed filter window.
| fieldKey | Per-field key selecting one independent realization (e.g. packed site id and slot). |
| window | The filter window, see ComputeWindow(). |
Definition at line 103 of file spatial-gaussian-field.cc.
References Prefix(), and SampleWindowFromPrefix().
Referenced by ns3::tests::SpatialGaussianFieldDeterminismTestCase::DoRun().
|
private |
Sample the field through a precomputed filter window.
| prefix | Hash prefix of the field, see Prefix(). |
| window | The filter window, see ComputeWindow(). |
Definition at line 109 of file spatial-gaussian-field.cc.
References CellFromPrefix(), ns3::SpatialGaussianField::Window::invL2Norm, ns3::SpatialGaussianField::Window::ix, ns3::SpatialGaussianField::Window::iy, WINDOW_CELLS, ns3::SpatialGaussianField::Window::wx, and ns3::SpatialGaussianField::Window::wy.
Referenced by Sample(), and SampleWindow().
|
staticprivate |
SplitMix64 mixing round.
| x | The state to mix. |
Definition at line 27 of file spatial-gaussian-field.cc.
References x.
Referenced by CellFromPrefix(), and Prefix().
|
private |
per-cell N(0,1) generator
Definition at line 177 of file spatial-gaussian-field.h.
Referenced by SpatialGaussianField(), and CellFromPrefix().
|
private |
class-specific salt
Definition at line 176 of file spatial-gaussian-field.h.
Referenced by SpatialGaussianField(), and Prefix().
|
staticconstexpr |
Number of grid cells per dimension of a filter window.
Definition at line 56 of file spatial-gaussian-field.h.
Referenced by ComputeWindow(), ns3::tests::SpatialGaussianFieldStatisticsTestCase::ExactAutocorrelation(), and SampleWindowFromPrefix().