Deming's funnel: Difference between revisions

Content added Content deleted
(Added Go)
m (→‎{{header|Perl 6}}: fix bug with anonymous state variable, output tweak)
Line 677: Line 677:


=={{header|Perl 6}}==
=={{header|Perl 6}}==
{{Works with|rakudo|2015-11-04}}
{{Works with|Rakudo|2018.10}}
<lang perl6>sub mean { @_ R/ [+] @_ }
<lang perl6>sub mean { @_ R/ [+] @_ }
sub stddev {
sub stddev {
Line 722: Line 722:


for @rule {
for @rule {
say "Rule {++state$ }:";
say "Rule $(++$):";
my $target = 0i;
my $target = 0i;
my @z = gather for @dz -> $dz {
my @z = gather for @dz -> $dz {
Line 728: Line 728:
$target = .($target, $dz)
$target = .($target, $dz)
}
}
printf "Mean x, y : %.4f %.4f\n", mean(@z».re), mean(@z».im);
printf "Mean x, y : %7.4f %7.4f\n", mean(@z».re), mean(@z».im);
printf "Std dev x, y : %.4f %.4f\n", stddev(@z».re), stddev(@z».im);
printf "Std dev x, y : %7.4f %7.4f\n", stddev(@z».re), stddev(@z».im);
}</lang>
}</lang>
{{out}}
{{out}}
<pre>Rule 1:
<pre>Rule 1:
Mean x, y : 0.0004 0.0702
Mean x, y : 0.0004 0.0702
Std dev x, y : 0.7153 0.6462
Std dev x, y : 0.7153 0.6462
Rule 2:
Rule 2:
Mean x, y : 0.0009 -0.0103
Mean x, y : 0.0009 -0.0103
Std dev x, y : 1.0371 0.8999
Std dev x, y : 1.0371 0.8999
Rule 3:
Rule 3:
Mean x, y : 0.0439 -0.0063
Mean x, y : 0.0439 -0.0063
Std dev x, y : 7.9871 4.7784
Std dev x, y : 7.9871 4.7784
Rule 4:
Rule 4:
Mean x, y : 3.1341 5.4210
Mean x, y : 3.1341 5.4210
Std dev x, y : 1.5874 3.9304</pre>
Std dev x, y : 1.5874 3.9304</pre>


=={{header|Python}}==
=={{header|Python}}==