{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Example\n\nA median algebra is a set $A$ with one [[ternary operation|WC47MFR6GW]] $m$, written $\\langle x, y, z \\rangle$, such that for all $x, y, z, w \\in A$:\n\n1. $\\langle x, y, y \\rangle = y$;\n2. $\\langle x, y, z \\rangle = \\langle z, x, y \\rangle$;\n3. $\\langle x, y, z \\rangle = \\langle x, z, y \\rangle$;\n4. $\\langle \\langle x, w, y \\rangle, w, z \\rangle = \\langle x, w, \\langle y, w, z \\rangle \\rangle$.\n\nSo it is an algebra with a single operation of arity $3$, defined by identities.\n\nThe basic instance is a [[distributive lattice|0HM0HQCK6N]] $(L, \\wedge, \\vee)$ with\n$$\\langle x, y, z \\rangle = (x \\wedge y) \\vee (y \\wedge z) \\vee (z \\wedge x).$$\nOn a [[total order|0FRXBVVR03]] this is the middle one of the three elements.\nFor instance on $\\Z$ with the usual order, $\\langle 1, 5, 3 \\rangle = 3$ and $\\langle 4, 4, 9 \\rangle = 4$.\nOn $\\set{0, 1}$ it is the majority function, and on $\\set{0, 1}^n$ it is the majority taken in each coordinate.\nLaws 1 to 3 are clear for the majority function, and law 4 can be checked on $\\set{0, 1}$ by going through the cases.\n\n## Remarks\n\nIn a [[tree|062D9KXJB1]], the median of three vertices is the unique vertex that lies on all three paths between them, and this gives a median algebra on the vertex set.\nBy laws 1 to 3, $\\langle x, x, y \\rangle = \\langle x, y, x \\rangle = \\langle y, x, x \\rangle = x$.\nSo $m$ is a [[majority term|9879ZMW5AA]] for the variety of median algebras.\nThe operation $x - y + z$ on $\\Z$ is a non-example: it fails law 1, since it gives $x - y + y = x$, which differs from $y$ when $x \\ne y$.\n\n## Explanations\n\n### L1 human\n\nGiven three numbers, the median picks the one in the middle.\nA median algebra keeps only this operation and the rules it obeys.\nIf two of the three inputs agree, the answer is that common value, and the order of the inputs does not matter.\nThe same rules hold for the majority vote of three bits, and for the meeting point of three towns joined by roads that form a tree.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "instance_of": [
      "QJGPT2W0FT"
    ],
    "kind": "example",
    "msc": [
      "08A99",
      "06D99",
      "05C05"
    ],
    "name": "Median algebra as a ternary algebra",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Median_algebra"
      }
    ],
    "tag": "S0DAGR1WN7",
    "uses": [
      "WC47MFR6GW",
      "0HM0HQCK6N",
      "0FRXBVVR03",
      "062D9KXJB1",
      "9879ZMW5AA"
    ]
  },
  "kind": "example",
  "link": "https://tamnd.github.io/math2/node/S0DAGR1WN7/",
  "links": [
    {
      "field": "instance_of",
      "target": "QJGPT2W0FT"
    },
    {
      "field": "uses",
      "target": "WC47MFR6GW"
    },
    {
      "field": "uses",
      "target": "0HM0HQCK6N"
    },
    {
      "field": "uses",
      "target": "0FRXBVVR03"
    },
    {
      "field": "uses",
      "target": "062D9KXJB1"
    },
    {
      "field": "uses",
      "target": "9879ZMW5AA"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/S0DAGR1WN7.md",
  "msc": [
    "08A99",
    "06D99",
    "05C05"
  ],
  "name": "Median algebra as a ternary algebra",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/S0D/S0DAGR1WN7.md",
  "status": null,
  "tag": "S0DAGR1WN7",
  "uri": "m2://S0DAGR1WN7",
  "url": "https://tamnd.github.io/math2/wiki/median-algebra-as-a-ternary-algebra/",
  "writing": {
    "tag": "S0DAGR1WN7",
    "kind": "example",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
