Basic

for 100, 1_000, 10_000 -> $N {
    say "size: $N";
    my @data = rand xx $N;
    printf "mean: %f\n", my $mean = $N R/ [+] @data;
    printf "stddev: %f\n", sqrt
    $mean**2 R- $N R/ [+] @data »**» 2;
    printf "%.1f %s\n", .key, '=' x (500 * .value.elems / $N)
        for sort @data.classify: (10 * *).Int / 10;
    say '';
}

Output:

size: 100
mean: 0.52518699464629726
stddev: 0.28484207464779548
0.0     ==============================
0.1     ======================================================================
0.2     ===================================
0.3     ==================================================
0.4     ============================================================
0.5     =============================================
0.6     ====================
0.7     ===========================================================================
0.8     ======================================================================
0.9     =============================================

size: 1000
mean: 0.51043974182914975
stddev: 0.29146336553431618
0.0     ==============================================
0.1     ==================================================
0.2     ===========================================
0.3     ========================================================
0.4     ===================================================
0.5     =======================================
0.6     ===========================================================
0.7     ====================================================
0.8     ==============================================
0.9     ========================================================

size: 10000
mean: 0.50371817503544458
stddev: 0.2900716333092252
0.0     ===================================================
0.1     =================================================
0.2     =============================================
0.3     ====================================================
0.4     ==============================================
0.5     ====================================================
0.6     ================================================
0.7     ===================================================
0.8     ====================================================
0.9     ==================================================

Last updated