Preference Relations and Utility: Completeness, Transitivity, and Representation

Environment

Python 3.14.6, NumPy 2.5.4, SciPy 1.18.1, Matplotlib 3.11.2 (Jupyter Notebook).

This article is a rewrite of a post from around 2021, with calculations performed in the environment described above.

Overview

Before assigning numbers to preferences, check which alternatives can be compared and whether the comparisons are consistent. We test completeness and transitivity for a finite set and construct a utility representation in Python that preserves ties.

This article corresponds to Chapter 2, “Preferences and Expected Utility”, of The Theory and Practice of Decision Making. The numerical examples are illustrative, not observed data.

Setup

Run the cells in order. Round to three significant figures only when displaying results.

Check versions, import libraries, and configure plots
import sys
from pathlib import Path
from pprint import pprint

import numpy as np
import scipy
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter, ScalarFormatter
from matplotlib_inline.backend_inline import set_matplotlib_formats
from IPython.display import Math, display

# 表示だけを丸め、計算には丸める前の値を使う。
def s3(value):
    return format(float(value), "#.3g").rstrip(".")


np.set_printoptions(formatter={"float_kind": s3})
set_matplotlib_formats("svg")
plt.rcParams.update({
    "figure.figsize": (7, 4),
    "font.size": 11,
    "axes.spines.top": False,
    "axes.spines.right": False,
    "axes.grid": True,
    "grid.alpha": 0.200,
    "svg.fonttype": "path",
})
OUT_DIR = Path("104_nb_files")
OUT_DIR.mkdir(exist_ok=True)


def save_fig(fig, name):
    # 数値の目盛りだけを整形し、候補名などのラベルは保つ。
    for ax in fig.axes:
        for axis in (ax.xaxis, ax.yaxis):
            if isinstance(axis.get_major_formatter(), ScalarFormatter):
                axis.set_major_formatter(FuncFormatter(lambda x, pos: s3(x)))
    # SVGをファイルとセル出力の両方に残す。
    fig.tight_layout()
    fig.savefig(OUT_DIR / f"{name}.svg", format="svg", bbox_inches="tight")
    display(fig)
    plt.close(fig)


assert sys.version_info[:3] == (3, 14, 6), "Python 3.14.6のカーネルを選択すること"
print("実行環境: wa-src(3.14.6)")
print("Python:", sys.version.split()[0])
print("NumPy:", np.__version__, "SciPy:", scipy.__version__)
print("Matplotlib:", matplotlib.__version__)
実行環境: wa-src(3.14.6)
Python: 3.14.6
NumPy: 2.5.4 SciPy: 1.18.1
Matplotlib: 3.11.2

1. Preferences describe an ordering

The weak preference $x\succeq y$ means that $x$ is at least as desirable as $y$. Strict preference and indifference are defined as follows.

$$ \begin{aligned} x\succ y&\iff x\succeq y\ \text{and}\ \neg(y\succeq x),\\ x\sim y&\iff x\succeq y\ \text{and}\ y\succeq x. \end{aligned} $$

Incomparability differs from indifference. With incomparability, neither direction of the comparison holds. With indifference, both directions hold.

Completeness requires $x\succeq y$ or $y\succeq x$ for every $x,y$. Transitivity requires the following implication.

$$ x\succeq y,\quad y\succeq z\quad\Longrightarrow\quad x\succeq z. $$

Completeness includes the case $x=y$, so it also implies reflexivity, $x\succeq x$. A relation satisfying these two conditions is a weak order. If actual responses violate them, check for recording errors, changes in the situation, or different comparison criteria.

2. On a finite set, ranks can define utility

Consider four alternatives with $A\succ B\sim C\succ D$. A utility function $u$ is a numerical representation satisfying the following equivalence.

$$ x\succeq y\iff u(x)\geq u(y). $$

Group indifferent alternatives together and order the groups from lowest to highest: $\{D\},\{B,C\},\{A\}$. Assign the values 0, 1, and 2 to these groups. Transitivity prevents cycles between distinct groups, and completeness allows the groups to be compared.

Thus, on a finite set, completeness and transitivity yield a utility representation. This conclusion cannot be extended to every infinite set without additional assumptions. To obtain continuous utility on a continuous choice space, examine further conditions such as continuity of preferences. This distinction matters when moving from a finite table to a general theory.

labels = ["A", "B", "C", "D"]
utility = np.array([2, 1, 1, 0])
relation = utility[:, None] >= utility[None, :]


def check_relation(r):
    # r[i, j]は、iがjと同等以上であることを示す。
    r = np.asarray(r, dtype=bool)
    assert r.ndim == 2 and r.shape[0] == r.shape[1]
    complete = bool(np.all(r | r.T))
    # 整数の行列積で、i→j→kという2段階の関係を数える。
    two_steps = (r.astype(int) @ r.astype(int)) > 0
    transitive = bool(np.all(~two_steps | r))
    return {"完備性": complete, "推移性": transitive}


pprint({"関係行列": relation.astype(int), "検査": check_relation(relation)})
assert all(check_relation(relation).values())

fig, ax = plt.subplots(figsize=(5, 4))
ax.imshow(relation, cmap="Blues", vmin=0, vmax=1)
ax.set(xticks=range(4), xticklabels=labels, yticks=range(4), yticklabels=labels,
       xlabel="Compared candidate", ylabel="Candidate")
for i, j in np.ndindex(relation.shape):
    ax.text(j, i, str(int(relation[i, j])), ha="center", va="center",
            color="white" if relation[i, j] else "black")
save_fig(fig, "01_preference_relation")

# A≽B、B≽C、C≽Aという循環は、完備でも推移的ではない。
cycle = np.array([[1, 1, 0], [0, 1, 1], [1, 0, 1]], dtype=bool)
pprint({"循環する関係": check_relation(cycle)})
assert check_relation(cycle) == {"完備性": True, "推移性": False}
{'検査': {'完備性': True, '推移性': True},
 '関係行列': array([[1, 1, 1, 1],
       [0, 1, 1, 1],
       [0, 1, 1, 1],
       [0, 0, 0, 1]])}
{'循環する関係': {'完備性': True, '推移性': False}}

3. Utility differences do not measure intensity

Utility that represents only the ranking of certain alternatives is called ordinal utility. If $f$ is strictly increasing,

$$ u(x)\geq u(y)\iff f(u(x))\geq f(u(y)) $$

so $v=f\circ u$ represents the same preferences. In this example, the nonnegative utility values allow $f(t)=t^2$. The gap between A and B changes from 1 to 3, but their ranking stays the same. The numbers do not mean that A provides twice as much satisfaction as B.

An implementation must preserve ties. Simply assigning distinct integers in array order would destroy the indifference between B and C.

$$ \displaystyle u(A)=2>u(B)=u(C)=1>u(D)=0 $$

# 自分より厳密に下にある無差別類の個数を数える。
levels = np.unique(utility)
constructed = np.array([np.count_nonzero(levels < u) for u in utility])
transformed = constructed ** 2
assert np.array_equal(constructed[:, None] >= constructed[None, :], relation)
assert np.array_equal(transformed[:, None] >= transformed[None, :], relation)
pprint({"構成した効用": constructed, "二乗した効用": transformed})

fig, ax = plt.subplots()
x = np.arange(4)
ax.bar(x - 0.180, constructed, width=0.350, label="u")
ax.bar(x + 0.180, transformed, width=0.350, label="u squared")
ax.set(xticks=x, xticklabels=labels, ylabel="Utility representation")
ax.legend()
save_fig(fig, "02_ordinal_transform")
{'二乗した効用': array([4, 1, 1, 0]), '構成した効用': array([2, 1, 1, 0])}

4. Be careful when averaging ordinal utility

Even when certain outcomes keep the same ranking, averaging transformed utility can reverse the ranking of lotteries. Suppose outcome utilities are 0, 1, and 2. Lottery P gives utility 2 with probability $0.400$ and 0 otherwise. Lottery Q gives utility 1 for certain.

$$ \mathbb E[u(P)]=0.600\times0+0.400\times2=0.800<1=\mathbb E[u(Q)]. $$

After squaring utility, we obtain

$$ \mathbb E[u(P)^2]=0.600\times0+0.400\times4=1.60>1=\mathbb E[u(Q)^2]. $$

Preferences over certain outcomes alone do not determine preferences over uncertain lotteries. Expected utility theory adds axioms about preferences over lotteries themselves. Assigning utility numbers and averaging them requires these further assumptions.

u = np.array([0, 1, 2])
p_lottery = np.array([0.600, 0, 0.400])
q_lottery = np.array([0, 1, 0])
pprint({"変換前(P,Q)": (np.vstack([p_lottery, q_lottery]) @ u),
        "変換後(P,Q)": (np.vstack([p_lottery, q_lottery]) @ (u ** 2))})
assert p_lottery @ u < q_lottery @ u
assert p_lottery @ (u ** 2) > q_lottery @ (u ** 2)
{'変換前(P,Q)': array([0.800, 1.00]), '変換後(P,Q)': array([1.60, 1.00])}

Conclusion

We tested completeness and transitivity on a finite set and constructed a utility representation that preserves ties.

Ordinal utility represents rankings; differences and ratios have no fixed interpretation. Expected utility for lotteries must be distinguished from a ranking of certain alternatives.

References

Muhamet Yildiz, Theory of Choice, MIT OpenCourseWare . Reference for utility representation on finite sets and the conditions needed on more general choice spaces.