Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <array>
#include <cassert>
constexpr auto sample_per_u = 10;
constexpr auto iteration_count = 200;
constexpr auto sample_range_begin = 1.000;
constexpr auto sample_range_end = 4.000;
constexpr auto delta_u = 0.001;
auto sample_after_iteration(double u) {
// Firstly, let's do some iterations.
double x_curr = 0.01;
for(int i = 0; i < iteration_count; ++i) {
assert(x_curr > 0 && x_curr < 1);
x_curr = u * x_curr * (1 - x_curr);
}
// And then, take some samples.
std::array<double, sample_per_u> samples;
for(int i = 0; i < sample_per_u; ++i) {
samples[i] = x_curr;
x_curr = u * x_curr * (1 - x_curr);
}
return samples;
}
void print_points() {
for(auto curr_u = sample_range_begin; curr_u <= sample_range_end; curr_u += delta_u) {
auto samples = sample_after_iteration(curr_u);
for(auto &&sample : samples) {
std::cout << curr_u << ' ' << sample << std::endl;
}
}
}
int main() {
print_points();
}