This guide compares the two HDC strategies available in AGISystem2, helping you choose the right approach for your application.

Architecture Overview

Dense Binary Strategy

Traditional HDC using fixed-dimensional vectors and bitwise operations.

Properties

Performance

Sparse Polynomial HDC (SPHDC)

Sparse HDC using k BigInt exponents with Cartesian XOR binding.

Properties

Performance

Mathematical Properties Comparison

Property Dense Binary SPHDC Impact
Cancellation (XOR-based) Perfect (sim = 1.0) Perfect (XOR property) Both strategies support XOR cancellation
Associative Perfect (sim = 1.0) Perfect (XOR property) Both work perfectly
Commutative Perfect (sim = 1.0) Perfect (sim = 1.0) Preserved by deterministic sorting
Reflexive Perfect (sim = 1.0) Perfect (sim = 1.0) Both work perfectly
Symmetric Perfect (sim = 1.0) Perfect (sim = 1.0) Both work perfectly

Performance Comparison

Eval Suite Results

Metric Dense Binary SPHDC (k=4) Winner
Pass Rate 100% (126/126) 100% (126/126) Tie
Total Time 91ms 60ms SPHDC (1.5x faster)
Memory/Vector 256 bytes 32 bytes SPHDC (8x smaller)
HDC Retrieval 35% success 0% success Dense (better retrieval)

Use Case Recommendations

Choose Dense Binary when:

Choose SPHDC when:

Implementation Example

// Initialize with SPHDC strategy
import { initHDC } from './src/hdc/facade.mjs';
initHDC('sparse-polynomial');

// Create vectors
const sphdc = getStrategy('sparse-polynomial');
const vectorA = sphdc.createFromName('ConceptA', 4);  // k=4
const vectorB = sphdc.createFromName('ConceptB', 4);

// Bind vectors (Cartesian XOR)
const bound = sphdc.bind(vectorA, vectorB);

// Calculate similarity (Jaccard Index)
const similarity = sphdc.similarity(vectorA, vectorB);

// Bundle multiple vectors
const bundled = sphdc.bundle([vectorA, vectorB, vectorC]);

Advanced Topics

Hybrid Strategies

Consider combining SPHDC and dense binary strategies:

k Parameter Tuning

SPHDC performance varies with k: