categorical

Methods

Method Reference: categorical.keyHash

categorical: key = keyHash (C)
categorical: key = keyHash (C, base)

Generate a hash code for a categorical array.

key = keyHash (C) generates a uint64 scalar that represents the input array C. keyHash utilizes the 64-bit FNV-1a variant of the Fowler-Noll-Vo non-cryptographic hash function.

key = keyHash (C, base) also generates a 64-bit hash code using base as the offset basis for the FNV-1a hash algorithm. base must be a uint64 integer type scalar. Use this syntax to cascade keyHash on multiple objects for which a single hash code is required.

A categorical array is keyed on its element labels, on its ordinality, and – for an ordinal array alone – on the order of its categories, which is what its comparisons mean. Neither the Protected property nor a non-ordinal array’s category list is part of the key, so two non-ordinal arrays carrying the same labels hash alike however their categories differ or are ordered. Undefined elements are equal to one another and distinct from every category. Two arrays that keyMatch reports as the same key always hash alike.

Note that unlike MATLAB, this implementation does not use any random seed. As a result, keyHash will always generate the exact same hash key for any particular input across different workers and Octave sessions.

Source Code: categorical