NAME
Logic::Probabilistic::Distribution::Outcome - Smart outcome container with transparent dereferencing.
SYNOPSIS
fresh my $listing;
query_dist MovieListings::search_listing('adventure', 'Westwood', $listing) -> my $dist;
for my $outcome ($dist->outcomes) {
# Stringifies cleanly as "[Four Feathers, Music Hall]"
say "Outcome: $outcome with P = " . $outcome->probability;
# Direct array dereferencing when outcome is a list/tuple:
say "Film: " . $outcome->[0] . ", Theater: " . $outcome->[1];
# Direct raw Perl data structure:
my $pair = $outcome->raw; # ['Four Feathers', 'Music Hall']
}
DESCRIPTION
Logic::Probabilistic::Distribution::Outcome represents a discrete outcome from a probability distribution query.
It implements operator overloading so that:
Stringification (
"") returns the canonical display key (e.g."[Four Feathers, Music Hall]").Array dereferencing (
@{{}}) delegates directly to the underlying array reference if the raw outcome is an array/tuple (e.g.$outcome->[0]).Hash dereferencing (
%{{}}) delegates directly to the underlying hash reference if the raw outcome is a dictionary (e.g.$outcome->{field}).Numeric conversion (
0+) converts numeric keys to numbers (e.g. for dice outcomes).
METHODS
key
Returns the stringified canonical outcome key.
raw / value
Returns the underlying, unblessed Perl data structure (scalar, arrayref, or hashref).
probability / prob / pmf
Returns the numeric probability of this outcome in the distribution.
percentage / pct
Returns the probability multiplied by 100.
distribution
Returns the parent Logic::Probabilistic::Distribution instance.