Skip to content
Snippets Groups Projects
Commit 29805722 authored by Recolic's avatar Recolic 🏡
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
generate-points
draw.py 0 → 100644
import matplotlib.pyplot as plt
import numpy as np
with open('points.log') as f:
cont = f.read()
u_arr = []
x_arr = []
for line in cont.split('\n'):
if line == '':
continue
u, x = line.split(' ')
iu, ix = float(u), float(x)
u_arr.append(iu)
x_arr.append(ix)
plt.scatter(np.array(u_arr), np.array(x_arr), s=1)
plt.show()
#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();
}
images/dense-1-to-4.png

71.6 KiB

images/dense-zoomed.png

34.4 KiB

images/normal-1-to-4.png

36.3 KiB

This diff is collapsed.
run.sh 0 → 100644
g++ generate-points.cc -O3 -o generate-points && ./generate-points | tee points.log && python draw.py
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment