A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::SpatialGaussianField Class Reference

Stateless, position-keyed, spatially-correlated Gaussian random field. More...

#include "spatial-gaussian-field.h"

Collaboration diagram for ns3::SpatialGaussianField:

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

Detailed Description

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.

Note
The autocorrelation is not exactly exponential: it is smooth at the origin, within about 0.04 of exp(-d/dcor) up to three correlation distances and exactly zero beyond. A spec-exact sum-of-sinusoids field (the QuaDRiGa approach) would carry a ripple of about 0.05 at every lag and cost more per sample, which was judged not worth the complexity.

Definition at line 43 of file spatial-gaussian-field.h.

Member Enumeration Documentation

◆ CellGenerator

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.

◆ Salt

enum class ns3::SpatialGaussianField::Salt : uint64_t
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.

Constructor & Destructor Documentation

◆ SpatialGaussianField()

ns3::SpatialGaussianField::SpatialGaussianField ( Salt salt,
CellGenerator generator = CellGenerator::BoxMuller )
explicit

Construct a field.

Parameters
saltSalt of the model owning the field, see Salt.
generatorThe per-cell N(0,1) generator.

Definition at line 20 of file spatial-gaussian-field.cc.

References m_generator, and m_salt.

Member Function Documentation

◆ CellFromPrefix()

double ns3::SpatialGaussianField::CellFromPrefix ( uint64_t prefix,
int64_t ix,
int64_t iy ) const
private

Deterministic N(0,1) value of one cell of the field.

Parameters
prefixHash prefix of the field, see Prefix().
ixInteger grid x-coordinate of the cell.
iyInteger grid y-coordinate of the cell.
Returns
A standard-normal value deterministic in (prefix, ix, iy).

Definition at line 45 of file spatial-gaussian-field.cc.

References BoxMuller, m_generator, and SplitMix64().

Referenced by Sample(), and SampleWindowFromPrefix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeWindow()

SpatialGaussianField::Window ns3::SpatialGaussianField::ComputeWindow ( const Vector & position,
double corrDist )
static

Compute the filter window of a sampling position.

Parameters
positionThe sampling position (only x and y are used).
corrDistThe correlation distance, must be positive.
Returns
The filter window.

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().

Here is the caller graph for this function:

◆ Prefix()

uint64_t ns3::SpatialGaussianField::Prefix ( uint64_t fieldKey) const
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()).

Parameters
fieldKeyPer-field key, see Sample().
Returns
The mixed hash state of the field.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sample()

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.

Parameters
fieldKeyPer-field key selecting one independent realization (e.g. packed site id and slot).
positionThe sampling position (only x and y are used).
corrDistThe correlation distance at which the autocorrelation equals 1/e.
Returns
A standard-normal sample.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
fieldKeyPer-field key, see Sample().
positionThe sampling position (only x and y are used).
corrDistThe correlation distance, see Sample().
Returns
A uniform sample in (0,1).

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleWindow()

double ns3::SpatialGaussianField::SampleWindow ( uint64_t fieldKey,
const Window & window ) const

Sample the field through a precomputed filter window.

Parameters
fieldKeyPer-field key selecting one independent realization (e.g. packed site id and slot).
windowThe filter window, see ComputeWindow().
Returns
A standard-normal sample.

Definition at line 103 of file spatial-gaussian-field.cc.

References Prefix(), and SampleWindowFromPrefix().

Referenced by ns3::tests::SpatialGaussianFieldDeterminismTestCase::DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleWindowFromPrefix()

double ns3::SpatialGaussianField::SampleWindowFromPrefix ( uint64_t prefix,
const Window & window ) const
private

Sample the field through a precomputed filter window.

Parameters
prefixHash prefix of the field, see Prefix().
windowThe filter window, see ComputeWindow().
Returns
A standard-normal sample.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SplitMix64()

uint64_t ns3::SpatialGaussianField::SplitMix64 ( uint64_t x)
staticprivate

SplitMix64 mixing round.

Parameters
xThe state to mix.
Returns
The mixed state.

Definition at line 27 of file spatial-gaussian-field.cc.

References x.

Referenced by CellFromPrefix(), and Prefix().

Here is the caller graph for this function:

Member Data Documentation

◆ m_generator

CellGenerator ns3::SpatialGaussianField::m_generator
private

per-cell N(0,1) generator

Definition at line 177 of file spatial-gaussian-field.h.

Referenced by SpatialGaussianField(), and CellFromPrefix().

◆ m_salt

uint64_t ns3::SpatialGaussianField::m_salt
private

class-specific salt

Definition at line 176 of file spatial-gaussian-field.h.

Referenced by SpatialGaussianField(), and Prefix().

◆ WINDOW_CELLS

std::size_t ns3::SpatialGaussianField::WINDOW_CELLS = 14
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().


The documentation for this class was generated from the following files: