Skip to article frontmatterSkip to article content

Distribution Showcase

Some of the distributions included in the Ranx Library

Image produced in Jupyter

Normal distribution

Code
ranx::generate_n(std::begin(v1), count, ranx::bind(trng::normal_dist{50.0, 5.0},pcg32{}));
ranx::generate_n(std::begin(v2), count, ranx::bind(trng::normal_dist{50.0, 9.0},pcg32{}));
ranx::generate_n(std::begin(v3), count, ranx::bind(trng::normal_dist{50.0, 15.0},pcg32{}));
ranx::generate_n(std::begin(v4), count, ranx::bind(trng::normal_dist{25.0, 7.0},pcg32{}));
auto norm1 = make_data_block(gp, v1, 1);
auto norm2 = make_data_block(gp, v2, 1);
auto norm3 = make_data_block(gp, v3, 1);
auto norm4 = make_data_block(gp, v4, 1);

gp  << "plot"
    << norm1
    << "u (bin($1)):(1) title 'μ=50, σ=5.00' smooth kdensity w lines ls 1,"
    << norm2
    << "u (bin($1)):(1) title 'μ=50, σ=9.00' smooth kdensity w lines ls 2,"
    << norm3
    << "u (bin($1)):(1) title 'μ=50, σ=15.0' smooth kdensity w lines ls 3,"
    << norm4
    << "u (bin($1)):(1) title 'μ=25, σ=7.00' smooth kdensity w lines ls 4\n"
Output
Image produced in Jupyter
Image produced in Jupyter

Log-normal distribution

Code
std::generate_n(std::begin(v1), count, std::bind(std::lognormal_distribution{0.0, 1.3},pcg32{}));
std::generate_n(std::begin(v2), count, std::bind(std::lognormal_distribution{1.0, 1.0},pcg32{}));
std::generate_n(std::begin(v3), count, std::bind(std::lognormal_distribution{2.0, 1.0},pcg32{}));
std::generate_n(std::begin(v4), count, std::bind(std::lognormal_distribution{3.0, 1.0},pcg32{}));
auto log_norm1 = make_data_block(gp, v1, 1);
auto log_norm2 = make_data_block(gp, v2, 1);
auto log_norm3 = make_data_block(gp, v3, 1);
auto log_norm4 = make_data_block(gp, v4, 1);

gp  << "set xrange [0:10]\n"
    << "plot"
    << log_norm1
    << "u (bin($1)):(1) title 'μ=0.0, σ=1.3' smooth kdensity w lines ls 1,"
    << log_norm2
    << "u (bin($1)):(1) title 'μ=1.0, σ=1.0' smooth kdensity w lines ls 2,"
    << log_norm3
    << "u (bin($1)):(1) title 'μ=2.0, σ=1.0' smooth kdensity w lines ls 3,"
    << log_norm4
    << "u (bin($1)):(1) title 'μ=3.0, σ=1.0' smooth kdensity w lines ls 4\n"
Output
Image produced in Jupyter
Image produced in Jupyter

Poisson distribution

Code
std::generate_n(std::begin(v1), count, std::bind(std::poisson_distribution{10.0},pcg32{}));
std::generate_n(std::begin(v2), count, std::bind(std::poisson_distribution{20.0},pcg32{}));
std::generate_n(std::begin(v3), count, std::bind(std::poisson_distribution{40.0},pcg32{}));
std::generate_n(std::begin(v4), count, std::bind(std::poisson_distribution{75.0},pcg32{}));
auto poisson1 = make_data_block(gp, v1, 1);
auto poisson2 = make_data_block(gp, v2, 1);
auto poisson3 = make_data_block(gp, v3, 1);
auto poisson4 = make_data_block(gp, v4, 1);

gp  << "set xrange [0:100]\n"
    << "plot"
    << poisson1
    << "u (bin($1)):(1) title 'λ=10' smooth kdensity w lines ls 1,"
    << poisson2
    << "u (bin($1)):(1) title 'λ=20' smooth kdensity w lines ls 2,"
    << poisson3
    << "u (bin($1)):(1) title 'λ=40' smooth kdensity w lines ls 3,"
    << poisson4
    << "u (bin($1)):(1) title 'λ=75' smooth kdensity w lines ls 4\n"
Output
Image produced in Jupyter