Hey Damian...

What is the expected output of this:

  my $x = 0|1; my $xsum = 0; my $xmean;
  my $y = 0|1;
  my $z = $x * $y; my $zsum = 0; my $zmean;

  $xsum += $x.pick for 1..1000;
  $xmean = $xsum / 1000;
  print "Expected value of \$x is $xmean\n";

  $zsum = $z.pick for 1..1000;
  $zmean =  $zsum / 1000;
  print "Expected value of \$z is $zmean\n";

I think $xmean will be 0.5, but I'm of two thoughts with $zmean.

Either $z is 0|1, and thus $zmean is 0.5,
or z is 0|0|0|1, and thus $zmean is 0.25.

What should we expect?





Reply via email to