Mamdani fan controller
An old-school rule of thumb: hot and humid, run the fan hard; cold, leave it off. Fuzzy control takes it more or less as-is. The temperature and humidity get read as how cold, warm or hot and how dry, comfortable or humid it is (all at once, in partial amounts), each of the seven rules fires about as hard as its conditions are true, and the fan speed is where their votes balance out (technically the centroid of the shape they make together, which is the bottom chart).
The math runs server-side in Fugue.Fuzzy,
which used to be Hazy, a Haskell library this page called over HTTP;
it's plain Elixir now. Drag the sliders and watch which rules light up.
A full Mamdani controller: fuzzify, fire every rule, clip each consequent, aggregate the envelope, then defuzzify by centroid. The rule set is plain data, so changing a rule doesn't mean changing any code. -> mamdani.ex
Top row shows each input fuzzified into its term set, with a dashed crisp line and dots marking the degree of membership at that input. Middle shows each rule's firing strength, colored by the fan speed term it votes for. Bottom layers each rule's clipped consequent underneath the aggregated envelope; the white marker is the centroid.
source fugue