MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kinesis::Stochastic::Stochastic Class Reference

Unified generative infrastructure for stochastic and procedural algorithms. More...

#include <Stochastic.hpp>

+ Collaboration diagram for MayaFlux::Kinesis::Stochastic::Stochastic:

Public Member Functions

 Stochastic (Algorithm algo=Algorithm::UNIFORM)
 Constructs generator with specified algorithm.
 
void seed (uint64_t seed)
 Seeds entropy source.
 
void set_algorithm (Algorithm algo)
 Changes active algorithm.
 
Algorithm get_algorithm () const
 Gets current algorithm.
 
void configure (const std::string &key, std::any value)
 Configures algorithm-specific parameters.
 
std::optional< std::any > get_config (const std::string &key) const
 Gets configuration parameter.
 
double operator() (double min, double max)
 Generates single value in range.
 
double at (double x, double y=0.0, double z=0.0)
 Multi-dimensional generation (Perlin, spatial noise)
 
std::vector< double > batch (double min, double max, size_t count)
 Batch generation.
 
void reset_state ()
 Resets internal state for stateful algorithms.
 
const GeneratorStatestate () const
 Gets current internal state.
 
GeneratorStatestate_mutable ()
 Gets mutable internal state.
 

Private Member Functions

double generate_memoryless (double min, double max)
 
double generate_stateful (double min, double max)
 
double generate_perlin_impl (double x, double y, double z)
 
double generate_gendy_impl (double min, double max)
 
double generate_brownian_impl (double min, double max)
 
double generate_colored_noise_impl (double min, double max)
 
void validate_range (double min, double max) const
 
void rebuild_distributions_if_needed (double min, double max)
 
double fast_uniform () noexcept
 

Private Attributes

std::mt19937 m_engine
 
uint64_t m_xorshift_state
 
Algorithm m_algorithm
 
GeneratorState m_state
 
std::map< std::string, std::any > m_config
 
std::normal_distribution< double > m_normal_dist { 0.0, 1.0 }
 
std::exponential_distribution< double > m_exponential_dist { 1.0 }
 
double m_cached_min { 0.0 }
 
double m_cached_max { 1.0 }
 
bool m_dist_dirty { true }
 

Detailed Description

Unified generative infrastructure for stochastic and procedural algorithms.

Provides mathematical primitives for controlled randomness and procedural generation across all computational domains. Unlike traditional random number generators focused on independent samples, Stochastic embraces both memoryless distributions and stateful processes that evolve over time.

Architectural Philosophy

Treats stochastic generation as fundamental mathematical infrastructure rather than domain-specific processing. The same primitives that generate sonic textures can drive visual phenomena, parametric modulation, or data synthesis - the numbers themselves are discipline-agnostic.

Algorithm Categories

Memoryless Distributions (each call independent):

  • UNIFORM: Flat probability across range
  • NORMAL: Gaussian distribution
  • EXPONENTIAL: Exponential decay
  • POISSON: Discrete event distribution

Stateful Processes (evolution over successive calls):

  • PERLIN: Coherent gradient noise with spatial/temporal continuity
  • GENDY: Xenakis dynamic stochastic synthesis (pitch/amplitude breakpoints)
  • BROWNIAN: Random walk (integrated white noise)
  • PINK: 1/f noise (equal energy per octave)
  • BLUE: Rising spectral energy

Usage Patterns

Memoryless generation:

double value = gen(0.0, 1.0);
Unified generative infrastructure for stochastic and procedural algorithms.

Stateful evolution:

walker.configure("step_size", 0.01);
for (int i = 0; i < 1000; ++i) {
double pos = walker(0.0, 1.0);
}

Multi-dimensional generation:

double noise_2d = perlin.at(x, y);
double noise_3d = perlin.at(x, y, z);
double at(double x, double y=0.0, double z=0.0)
Multi-dimensional generation (Perlin, spatial noise)
Stochastic perlin(int octaves=4, double persistence=0.5)
Creates Perlin noise generator.
Note
Thread-unsafe for maximum performance. Use separate instances per thread.

Definition at line 117 of file Stochastic.hpp.


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