Metric-Affine HDC represents concepts as D-byte vectors over Z₂₅₆ (integers 0-255). In AGISystem2, geometry = D (the number of byte channels per vector). The default is D=32, and this page illustrates that default configuration.

1. The Core Idea: Continuous Values in Compact Space

Fundamental Insight

Instead of thousands of binary bits, Metric-Affine uses just D byte channels (default D=32). Each channel is a byte (0-255), so the storage is D bytes = 8D bits. The continuous values enable fuzzy superposition where bundled concepts smoothly blend rather than voting discretely.

Definition: Metric-Affine Vector

A metric-affine vector V is a fixed-length sequence of bytes:

V = [b0, b1, ..., bD-1] where bi ∈ {0, 1, ..., 255}

Storage: D bytes (default 32 bytes = 256 bits).

Metric-Affine Vector Structure (example at D=32 bytes) 180 45 230 12 128 200 . . . 92 15 byte 0 byte 31 Storage: Uint8Array(D) (example shown at D=32 → 32 bytes) 8x smaller than Dense-Binary (4KB) with continuous values

2. The Shifted Baseline: Why 0.67, Not 0.5

Unlike binary HDC where random vectors share ~50% of bits, metric-affine vectors have a different baseline.

Theorem: Metric-Affine Baseline Similarity

For random vectors X, Y with each byte uniformly distributed over [0, 255]:

Important: Because the baseline is ~0.67 instead of 0.5, all similarity thresholds must be adjusted. A "good match" in metric-affine is ~0.75+, whereas in dense-binary it would be ~0.55+.
Similarity Distribution Comparison Dense-Binary (0.5) Metric-Affine (0.67) 0.0 0.33 0.5 0.67 1.0 Dense-Binary baseline Metric-Affine baseline

3. Binding: BIND (XOR on Bytes)

Metric-Affine implements BIND as byte-wise XOR.

Definition: BIND (byte-wise XOR)

Given vectors A and B, their binding BIND(A, B) is computed byte-by-byte:

BIND(A, B)i = Ai XOR Bi

A: 180 45 230 12 ... B: 92 200 15 128 ... XOR (XOR) BIND(A, B): 232 245 241 132 ... 180 XOR 92 = 232 45 XOR 200 = 245 230 XOR 15 = 241 Same algebraic properties as Dense-Binary: Commutative, Associative, XOR cancellation

4. Bundling: Arithmetic Mean

Unlike binary majority vote, metric-affine uses arithmetic mean for bundling.

Definition: Arithmetic Mean Bundling

Given vectors V1, V2, ..., Vk, their bundle is:

bundle(V1...Vk)i = round((V1,i + V2,i + ... + Vk,i) / k)

Result is clamped to [0, 255].

Intuition: The bundle is a "smooth blend" of all inputs. Unlike binary majority vote (all-or-nothing per bit), arithmetic mean creates a continuous interpolation. The result lies geometrically between all inputs in the space.
Arithmetic Mean Bundling A: 180 45 230 12 B: 175 52 225 18 C: 50 200 40 190 MEAN average Result: 135 99 165 73 Byte-by-Byte Averaging: Byte 0: (180+175+50)/3 = 135 Byte 1: (45+52+200)/3 = 99 Byte 2: (230+225+40)/3 = 165 Byte 3: (12+18+190)/3 = 73
Gray Convergence Warning: Unlike binary majority vote, arithmetic mean causes values to drift toward the middle (128) over repeated bundling operations. Deep nested bundling can lose concept distinctiveness.

5. Similarity: Manhattan (L1) Distance

Definition: Normalized L1 Similarity

sim(A, B) = 1 - (Σ|Ai - Bi|) / (32 × 255)

The sum of absolute byte differences, normalized to [0, 1].

0.0 Inverse 0.33 Very different 0.67 Random/Unrelated 0.80 Related 1.0 Identical

6. Strategy Comparison

Property Dense-Binary SPHDC Metric-Affine
Memory 4 KB k-sparse (varies) D bytes (default 32)
Values Binary {0, 1} BigInt exponents Bytes {0..255}
Bind XOR bitwise Cartesian XOR XOR byte-wise
Bundle Majority vote Set union Arithmetic mean
Similarity Hamming Jaccard L1 Manhattan
Baseline 0.5 ~0.01 ~0.67
Holographic Yes (classic) Limited Yes (fuzzy)
Best For General HDC Symbolic only Fuzzy reasoning

7. Use Cases

Ideal Applications

Limitations:

8. Usage

Programmatic Usage
	import { initHDC, setDefaultGeometry } from './src/hdc/facade.mjs';
	import { Session } from './src/runtime/session.mjs';

	// Initialize metric-affine strategy
	initHDC('metric-affine');
	setDefaultGeometry(32); // D in bytes (try 8/16/32/64/128)

	// Create session
	const session = new Session({ geometry: 32 }); // D in bytes

// Learn facts
session.learn('isA Dog Animal');
session.learn('isA Cat Animal');

// Query
const result = session.query('isA Dog ?what');
console.log(result);  // { success: true, bindings: { ?what: 'Animal' } }
Environment Variable
export SYS2_HDC_STRATEGY=metric-affine
node your-script.js
Need better scaling for large KBs?

Metric-Affine Elastic (EMA) extends this strategy with chunked bundling (bounded depth) to reduce gray drift under large superpositions. Geometry (D bytes) remains a manual tuning knob in both strategies. Read the EMA theory page →

9. Mathematical Properties

Key Properties of Metric-Affine HDC