6 : m_random_engine(
std::random_device {}())
7 , m_current_start(-1.0F)
9 , m_normal_spread(4.0F)
11 , m_xorshift_state(
std::random_device {}() | (static_cast<uint64_t>(
std::random_device {}()) << 32))
12 , m_context(0.0, type, 1.0, m_current_start, m_current_end, m_normal_spread)
13 , m_context_gpu(0.0, type, 1.0, m_current_start, m_current_end, m_normal_spread, get_gpu_data_buffer())
48 std::vector<double> samples;
49 samples.reserve(num_samples);
51 for (
unsigned int i = 0; i < num_samples; ++i) {
78 std::poisson_distribution<int> dist(
90 sample = std::max(start, std::min(end, sample));
93 sample = start + sample * (end - start);
101 throw std::invalid_argument(
"Start must be less than or equal to end");
156 if (condition(ctx)) {
double m_amplitude
Base amplitude of the generator.
Utils::distribution m_type
Current probability distribution algorithm.
uint64_t m_xorshift_state
Internal state for xorshift random number generation.
std::exponential_distribution< double > m_exponential_dist
Exponential distribution with lambda = 1.
NodeContext & get_last_context() override
Gets the last created context object.
void validate_range(double start, double end) const
Validates that the specified range is mathematically valid.
double m_normal_spread
Variance parameter for normal distribution.
std::vector< double > process_batch(unsigned int num_samples) override
Generates multiple stochastic values at once.
std::vector< double > random_array(double start, double end, unsigned int num_samples)
Generates an array of stochastic values within a specified range.
StochasticContextGpu m_context_gpu
std::normal_distribution< double > m_normal_dist
Normal distribution with mean 0 and standard deviation 1.
void set_normal_spread(double spread)
Sets the variance parameter for normal distribution.
std::mt19937 m_random_engine
Mersenne Twister entropy generator.
double transform_sample(double sample, double start, double end) const
Transforms a raw value to fit within the specified range.
void printGraph() override
Visualizes the distribution characteristics.
Random(Utils::distribution type=Utils::distribution::UNIFORM)
Constructor for the stochastic generator.
void update_context(double value) override
Updates the context object with the current node state.
double m_current_start
Lower bound of the current output range.
double generate_distributed_sample()
Generates a raw value according to the current distribution.
double fast_uniform() noexcept
Fast uniform random number generator using xorshift algorithm.
double m_current_end
Upper bound of the current output range.
double random_sample(double start, double end)
Generates a stochastic value within a specified range.
void rebuild_distributions_if_needed() noexcept
Rebuilds distribution objects if parameters have changed.
StochasticContext m_context
void printCurrent() override
Outputs the current configuration parameters.
void notify_tick(double value) override
Notifies all registered callbacks about a new value.
double process_sample(double input=0.) override
Generates a single stochastic value.
Utils::distribution distribution_type
Current distribution type.
double normal_spread
Current variance parameter for normal distribution.
double amplitude
Current amplitude scaling factor.
double range_start
Current lower bound of the range.
double range_end
Current upper bound of the range.
double value
Current sample value.
Base context class for node callbacks.
std::vector< NodeHook > m_callbacks
Collection of standard callback functions.
bool m_state_saved
tracks if the node's state has been saved by a snapshot operation
bool m_networked_node
Flag indicating if the node is part of a NodeNetwork This flag is used to disable event firing when t...
double m_last_output
The most recent sample value generated by this oscillator.
bool m_fire_events_during_snapshot
Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don...
std::vector< std::pair< NodeHook, NodeCondition > > m_conditional_callbacks
Collection of conditional callback functions with their predicates.
bool m_gpu_compatible
Flag indicating if the node supports GPU processing This flag is set by derived classes to indicate w...