41 double range_start,
double range_end,
double normal_spread)
43 , distribution_type(type)
44 , amplitude(amplitude)
45 , range_start(range_start)
46 , range_end(range_end)
47 , normal_spread(normal_spread)
93 std::span<const float> gpu_data)
94 :
StochasticContext(value, type, amplitude, range_start, range_end, normal_spread)
166 double process_sample(
double input = 0.)
override;
177 double random_sample(
double start,
double end);
187 std::vector<double> process_batch(
unsigned int num_samples)
override;
199 std::vector<double> random_array(
double start,
double end,
unsigned int num_samples);
207 void printGraph()
override;
215 void printCurrent()
override;
226 void set_normal_spread(
double spread);
241 void update_context(
double value)
override;
251 void notify_tick(
double value)
override;
263 double generate_distributed_sample();
275 [[nodiscard]]
double transform_sample(
double sample,
double start,
double end)
const;
286 void validate_range(
double start,
double end)
const;
298 m_xorshift_state ^= m_xorshift_state >> 12;
299 m_xorshift_state ^= m_xorshift_state << 25;
300 m_xorshift_state ^= m_xorshift_state >> 27;
301 return static_cast<double>(m_xorshift_state * 0x2545F4914F6CDD1DULL)
302 * (1.0 / 18446744073709551616.0);
312 void rebuild_distributions_if_needed() noexcept;
320 std::mt19937 m_random_engine;
325 Utils::distribution m_type;
330 double m_current_start;
335 double m_current_end;
343 double m_normal_spread;
346 std::normal_distribution<
double> m_normal_dist { 0.0, 1.0 };
349 std::exponential_distribution<double> m_exponential_dist { 1.0 };
357 double m_cached_start = -1.0;
358 double m_cached_end = 1.0;
359 double m_cached_spread = 4.0;
360 bool m_dist_dirty =
true;
Base class for all signal and pattern generators in Maya Flux.
uint64_t m_xorshift_state
Internal state for xorshift random number generation.
void set_type(Utils::distribution type)
Changes the probability distribution type.
~Random() override=default
Virtual destructor.
StochasticContextGpu m_context_gpu
void save_state() override
Saves the node's current state for later restoration Recursively cascades through all connected modul...
void restore_state() override
Restores the node's state from the last save Recursively cascades through all connected modulator nod...
double fast_uniform() noexcept
Fast uniform random number generator using xorshift algorithm.
StochasticContext m_context
Computational stochastic signal generator with multiple probability distributions.
StochasticContextGpu(double value, Utils::distribution type, double amplitude, double range_start, double range_end, double normal_spread, std::span< const float > gpu_data)
Utils::distribution distribution_type
Current distribution type.
StochasticContext(double value, Utils::distribution type, double amplitude, double range_start, double range_end, double normal_spread)
Constructs a StochasticContext with the current generator state.
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.
Specialized context for stochastic generator callbacks.
GPU-uploadable 1D array data interface.
Base context class for node callbacks.