MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ bernoulli_gate()

MAYAFLUX_API bool MayaFlux::Kinesis::Discrete::bernoulli_gate ( double  input,
std::span< double >  coefs 
)
noexcept

Probabilistic gate: each pulse passes with the given probability.

coefs: [threshold, latched, probability, state, pass]. The draw happens once per rise with xorshift32, so a clone with the same array repeats the same decisions.

Definition at line 129 of file Boolean.cpp.

130{
131 if (coefs.size() < 5)
132 return false;
133
134 const bool high = input > coefs[0];
135 if (rises(high, coefs[1])) {
136 uint32_t state = word_of(coefs[3]);
137 if (state == 0)
138 state = DEFAULT_SEED;
139 state = xorshift32(state);
140 coefs[3] = static_cast<double>(state);
141 coefs[4] = static_cast<double>(state) / UINT32_SPAN < coefs[2] ? 1.0 : 0.0;
142 }
143 return high && coefs[4] > 0.5;
144}
Core::GlobalInputConfig input
Definition Config.cpp:42
uint32_t xorshift32(uint32_t state) noexcept
One step of the 32-bit xorshift generator.
Definition Boolean.hpp:35

References input, and xorshift32().

+ Here is the call graph for this function: