line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
2854
|
use v5.24; |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
5
|
use Test::More; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
215
|
use Q::S::L; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
269
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub is_with_precision |
7
|
|
|
|
|
|
|
{ |
8
|
3
|
|
|
3
|
|
35
|
my ($num, $exp, $note) = @_; |
9
|
3
|
|
|
|
|
41
|
is sprintf("%.5f", $num), sprintf("%.5f", $exp), $note; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $dataset = |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# numbers from 1 to 9, with weights from 9 to 1 |
15
|
|
|
|
|
|
|
superpos(map { [$_, 10 - $_] } 1 .. 9) |
16
|
|
|
|
|
|
|
* |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# even numbers from 100 to 200, with weight from 1 to 25 to 1 |
19
|
|
|
|
|
|
|
superpos(map { [25 - abs(25 - $_), 100 + $_ * 2] } 1 .. 49) |
20
|
|
|
|
|
|
|
; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $stats = $dataset->stats; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
note "most probable outcome: " . $stats->most_probable->to_ket_notation; |
25
|
|
|
|
|
|
|
note "least probable outcome: " . $stats->least_probable->to_ket_notation; |
26
|
|
|
|
|
|
|
note "median: " . $stats->median; |
27
|
|
|
|
|
|
|
note "expected value: " . $stats->expected_value . " ± " . $stats->standard_deviation; |
28
|
|
|
|
|
|
|
note "random roll: " . $dataset->collapse; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
is_with_precision $stats->median, 360, "median ok"; |
31
|
|
|
|
|
|
|
is_with_precision $stats->mean, 550, "mean ok"; |
32
|
|
|
|
|
|
|
is_with_precision $stats->most_probable->states->[0]->weight, "0.008", "most probable weight ok"; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
done_testing; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |