concept
Expected utility
Compare probability-weighted utilities for eligible actions with complete, normalized outcome distributions. With scores 8p and 3, equality occurs at 3/8. Return all ties; uncertainty in p or utilities can change the preferred action. This is a one-step teaching interface, not a general planning engine.
Formal Syntax & Structure
artificial-intelligence syntaxartificial-intelligence
EU(a) = Σ P(o|a) × U(a,o); best_actions(p) → listWorking Example
Example Snippetartificial-intelligence
from fractions import Fraction
def expected_utility(outcomes): # Each pair is (exact probability, numeric utility). return sum(p * u for p, u in outcomes)
def best_actions(p): scores = {"A": 8 * p, "B": Fraction(3)} best = max(scores.values()) return [name for name, score in scores.items() if score == best]
for p in (Fraction(1, 4), Fraction(3, 8), Fraction(1, 2)): print(best_actions(p))