Vulcan
Aerospace Engineering Utilities Built on Janus
Loading...
Searching...
No Matches
vulcan::rng Namespace Reference

Classes

class  RNG
 Vulcan Random Number Generator. More...

Functions

template<typename RNGType>
allan::IMUNoiseInput< double > generate_imu_noise (RNGType &rng)
 Generate IMU noise input for Allan variance model.
template<typename RNGType>
Eigen::Vector3d generate_noise3 (RNGType &rng)
 Generate 3-axis white noise.
template<int N, typename RNGType>
Eigen::Vector< double, N > generate_noiseN (RNGType &rng)
 Generate N-dimensional white noise.
template<int N, typename RNGType>
Eigen::Vector< double, N > generate_correlated_noise (RNGType &rng, const Eigen::Matrix< double, N, N > &L)
 Generate correlated noise with given Cholesky factor.
template<typename RNGType>
Eigen::VectorXd generate_correlated_noise (RNGType &rng, const Eigen::MatrixXd &L)
 Generate correlated noise for dynamic-size matrices.
template<typename RNGType>
void generate_turbulence_noise (RNGType &rng, double &noise_u, double &noise_v, double &noise_w)
 Generate turbulence forcing noise (3 independent channels).
uint64_t hardware_seed ()
 Generate seed from std::random_device.
std::seed_seq create_seed_seq (std::initializer_list< uint32_t > values)
 Create seed sequence from multiple values.
uint64_t seed_from_string (std::string_view name)
 Hash-based seed from string.
uint64_t stream_seed (uint64_t base_seed, uint64_t stream_index)
 Combine base seed with stream index for parallel streams.
uint64_t advance_seed (uint64_t seed, uint64_t n)
 Advance seed to skip N sequences.

Function Documentation

◆ advance_seed()

uint64_t vulcan::rng::advance_seed ( uint64_t seed,
uint64_t n )
inline

Advance seed to skip N sequences.

Useful for checkpointing: compute the seed that would result from drawing N samples.

Parameters
seedCurrent seed
nNumber of positions to advance
Returns
New seed value

◆ create_seed_seq()

std::seed_seq vulcan::rng::create_seed_seq ( std::initializer_list< uint32_t > values)
inline

Create seed sequence from multiple values.

Provides robust initialization for MT19937 which benefits from multiple seed values to initialize its large state.

Parameters
valuesInitializer list of seed values
Returns
seed_seq for RNG initialization

◆ generate_correlated_noise() [1/2]

template<int N, typename RNGType>
Eigen::Vector< double, N > vulcan::rng::generate_correlated_noise ( RNGType & rng,
const Eigen::Matrix< double, N, N > & L )

Generate correlated noise with given Cholesky factor.

For covariance matrix P, compute L = chol(P) and pass L. Returns L * w where w ~ N(0, I).

Template Parameters
NVector dimension
RNGTypeAny type with gaussian() method
Parameters
rngRandom number generator
LLower-triangular Cholesky factor of covariance
Returns
Correlated noise vector ~ N(0, P)

◆ generate_correlated_noise() [2/2]

template<typename RNGType>
Eigen::VectorXd vulcan::rng::generate_correlated_noise ( RNGType & rng,
const Eigen::MatrixXd & L )

Generate correlated noise for dynamic-size matrices.

Template Parameters
RNGTypeAny type with gaussian() method
Parameters
rngRandom number generator
LLower-triangular Cholesky factor of covariance (n×n)
Returns
Correlated noise vector ~ N(0, P) (n×1)

◆ generate_imu_noise()

template<typename RNGType>
allan::IMUNoiseInput< double > vulcan::rng::generate_imu_noise ( RNGType & rng)

Generate IMU noise input for Allan variance model.

Fills all 18 noise channels (3 axes × 2 sensors × 3 noise types) with independent N(0,1) samples.

Example:

auto noise = vulcan::allan::step(state, coeffs, input);
Vulcan Random Number Generator.
Definition RNG.hpp:37
IMUNoiseState< Scalar > init_state()
Initialize IMU noise state.
Definition AllanVarianceNoise.hpp:139
sensors::IMUNoiseSample< Scalar > step(IMUNoiseState< Scalar > &state, const IMUNoiseCoeffs &coeffs, const IMUNoiseInput< Scalar > &input)
Step the complete IMU noise model.
Definition AllanVarianceNoise.hpp:213
IMUNoiseCoeffs consumer_grade_coeffs(double dt)
Compute coefficients for consumer-grade IMU.
Definition AllanVarianceNoise.hpp:277
Definition Distributions.hpp:14
allan::IMUNoiseInput< double > generate_imu_noise(RNGType &rng)
Generate IMU noise input for Allan variance model.
Definition Distributions.hpp:37
Template Parameters
RNGTypeAny type with gaussian() method returning double
Parameters
rngRandom number generator
Returns
IMUNoiseInput with all channels filled

◆ generate_noise3()

template<typename RNGType>
Eigen::Vector3d vulcan::rng::generate_noise3 ( RNGType & rng)

Generate 3-axis white noise.

Template Parameters
RNGTypeAny type with gaussian() method
Parameters
rngRandom number generator
Returns
3D vector of independent N(0,1) samples

◆ generate_noiseN()

template<int N, typename RNGType>
Eigen::Vector< double, N > vulcan::rng::generate_noiseN ( RNGType & rng)

Generate N-dimensional white noise.

Template Parameters
NVector dimension
RNGTypeAny type with gaussian() method
Parameters
rngRandom number generator
Returns
N-dimensional vector of independent N(0,1) samples

◆ generate_turbulence_noise()

template<typename RNGType>
void vulcan::rng::generate_turbulence_noise ( RNGType & rng,
double & noise_u,
double & noise_v,
double & noise_w )

Generate turbulence forcing noise (3 independent channels).

For Dryden/von Kármán turbulence filters.

Template Parameters
RNGTypeAny type with gaussian() method
Parameters
rngRandom number generator
noise_uOutput: longitudinal noise
noise_vOutput: lateral noise
noise_wOutput: vertical noise

◆ hardware_seed()

uint64_t vulcan::rng::hardware_seed ( )
inline

Generate seed from std::random_device.

Use only for initial seeding. The returned seed should be logged for reproducibility in future runs.

Warning
Not guaranteed to be truly random on all platforms. Some implementations may fall back to PRNG.
Returns
Hardware-generated seed value

◆ seed_from_string()

uint64_t vulcan::rng::seed_from_string ( std::string_view name)
inline

Hash-based seed from string.

Useful for named simulation runs, e.g., seed_from_string("monte_carlo_run_42") Uses std::hash which provides reasonable distribution.

Parameters
nameString identifier for the simulation
Returns
Deterministic seed value

◆ stream_seed()

uint64_t vulcan::rng::stream_seed ( uint64_t base_seed,
uint64_t stream_index )
inline

Combine base seed with stream index for parallel streams.

Uses golden ratio hashing for good distribution of stream seeds. Each stream will produce an independent sequence.

Example:

uint64_t base = 42;
for (int i = 0; i < 100; ++i) {
RNG stream_rng(stream_seed(base, i));
// Independent simulation...
}
uint64_t stream_seed(uint64_t base_seed, uint64_t stream_index)
Combine base seed with stream index for parallel streams.
Definition Seeding.hpp:84
Parameters
base_seedBase seed for all streams
stream_indexIndex of this particular stream
Returns
Unique seed for this stream