12 #ifndef THRILL_API_BERNOULLI_SAMPLE_HEADER 13 #define THRILL_API_BERNOULLI_SAMPLE_HEADER 26 template <
typename ValueType>
29 static const bool debug =
false;
36 assert(p >= 0.0 && p <= 1.0);
39 skip_dist_ = std::geometric_distribution<SkipDistValueType>(p);
49 template <
typename Emitter>
50 inline void operator () (
const ValueType& item, Emitter&& emit) {
55 LOG <<
"sampled item " << item;
66 LOG <<
"sampled item " << item;
83 std::default_random_engine
rng_ { std::random_device { } () };
85 std::geometric_distribution<SkipDistValueType>
skip_dist_;
89 template <
typename ValueType,
typename Stack>
93 size_t new_id = context().next_dia_id();
95 node_->context().logger_
97 <<
"label" <<
"BernoulliSample" 99 <<
"event" <<
"create" 105 node_, new_stack, new_id,
"BernoulliSample");
111 #endif // !THRILL_API_BERNOULLI_SAMPLE_HEADER
DIA is the interface between the user and the Thrill framework.
Type[] Array
A template to make writing temporary arrays easy: Array<int>{ 1, 2, 3 }.
std::default_random_engine rng_
SkipDistValueType skip_remaining_
BernoulliSampleNode(double p)
auto BernoulliSample(double p) const
Each item of a DIA is copied into the output DIA with success probability p (an independent Bernoulli...
std::geometric_distribution< SkipDistValueType > skip_dist_
#define LOG
Default logging method: output if the local debug variable is true.
std::bernoulli_distribution simple_dist_
void operator()(const ValueType &item, Emitter &&emit)