Probability Filter

template<typename T, uint8_t Percent>
struct Probability

Filter that accepts with a given probability percentage.

This filter randomly accepts or rejects changes based on the specified percentage, useful for probabilistic sampling or statistical monitoring.

Since

v0.1.0

// Example: Accept 25% of changes randomly
Signal<int, 10, Probability<int, 25>> sample(0);

Note

Non-deterministic, results vary on each call.

Warning

  • Percent must be between 0 and 100.

  • Uses random() function.

Template Parameters:
typename T

Any type.

uint8_t Percent

Acceptance probability (0-100).

Public Functions

inline bool operator()(const T &old_value, const T &new_value) const

See Also