# BytesMinHash

Defined in: [packages/scalar-sketch/src/minhash.ts:81](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L81)

A MinHash signature specialized for byte arrays.

## Extends

* [`MinHashMetadata`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/)
* `MinHashOperations`<`Uint8Array`, `BytesMinHash`>

## Properties

### kind

> `readonly` **kind**: `"minhash"`

Defined in: [packages/scalar-sketch/src/minhash.ts:15](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L15)

#### Inherited from

[`MinHashMetadata`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/).[`kind`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/#kind)

***

### signatureSize

> `readonly` **signatureSize**: `number`

Defined in: [packages/scalar-sketch/src/minhash.ts:18](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L18)

Number of ordered 64-bit coordinate minima.

#### Inherited from

[`MinHashMetadata`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/).[`signatureSize`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/#signaturesize)

***

### stateByteLength

> `readonly` **stateByteLength**: `number`

Defined in: [packages/scalar-sketch/src/minhash.ts:20](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L20)

Bytes occupied by paired low/high coordinate words, excluding object and hash-instance overhead.

#### Inherited from

[`MinHashMetadata`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/).[`stateByteLength`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/#statebytelength)

***

### maximumStandardError

> `readonly` **maximumStandardError**: `number`

Defined in: [packages/scalar-sketch/src/minhash.ts:22](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L22)

Worst-case standard error of the Jaccard estimate, `1 / (2 * sqrt(signatureSize))`.

#### Inherited from

[`MinHashMetadata`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/).[`maximumStandardError`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/#maximumstandarderror)

***

### seed

> `readonly` **seed**: `bigint`

Defined in: [packages/scalar-sketch/src/minhash.ts:24](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L24)

XXH64 base seed that participates in comparison and merge compatibility.

#### Inherited from

[`MinHashMetadata`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/).[`seed`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/#seed)

***

### seedSchedule

> `readonly` **seedSchedule**: [`SeedScheduleIdentity`](/reference/knotkit/scalar-sketch/type-aliases/seedscheduleidentity/)

Defined in: [packages/scalar-sketch/src/minhash.ts:26](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L26)

Prefix-stable coordinate-seed schedule that participates in comparison and merge compatibility.

#### Inherited from

[`MinHashMetadata`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/).[`seedSchedule`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/#seedschedule)

***

### snapshot

> `readonly` **snapshot**: () => `Uint32Array`

Defined in: [packages/scalar-sketch/src/minhash.ts:37](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L37)

Return a fresh copy of the signature in O(signatureSize).

The array holds two Uint32 words per coordinate, low word first, in the same order as the serialized signature. Every word is `0xffff_ffff` when the sketch is empty. Mutating the copy leaves the sketch unchanged.

#### Returns

`Uint32Array`

#### Inherited from

`MinHashOperations.snapshot`

***

### update

> **update**: (`value`) => `void`

Defined in: [packages/scalar-sketch/src/minhash.ts:43](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L43)

Add one value to the set summary. Repeated values are idempotent. O(signatureSize).

#### Parameters

##### value

`Uint8Array`

#### Returns

`void`

#### Throws

From `knotkit/hash` for an invalid scalar value.

#### Inherited from

`MinHashOperations.update`

***

### similarity

> **similarity**: (`other`) => `number`

Defined in: [packages/scalar-sketch/src/minhash.ts:57](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L57)

Estimate Jaccard similarity as the fraction of equal ordered coordinates. O(signatureSize).

Two empty signatures compare as `1`; exactly one empty signature compares as `0`. Otherwise, under the model assumption that domain-separated seeded XXH64 coordinates behave as independent min-wise hashes, the estimate has standard error `sqrt(J * (1 - J) / signatureSize)` and worst-case error metadata in [MinHashMetadata.maximumStandardError](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/#maximumstandarderror).

#### Parameters

##### other

`BytesMinHash`

#### Returns

`number`

#### See

[Min-wise independent permutations](https://www.cs.princeton.edu/courses/archive/spring05/cos598E/bib/broder98minwise.pdf)

#### Throws

With `FOREIGN_STRUCTURE`, `WRONG_FAMILY`, or `INCOMPATIBLE_SKETCH` for a non-comparable signature.

#### Inherited from

`MinHashOperations.similarity`

***

### merge

> **merge**: (`other`) => `void`

Defined in: [packages/scalar-sketch/src/minhash.ts:65](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L65)

Summarize the set union by taking each compatible coordinate minimum. O(signatureSize).

Self-merge is idempotent and the source is never mutated.

#### Parameters

##### other

`BytesMinHash`

#### Returns

`void`

#### Throws

With `FOREIGN_STRUCTURE`, `WRONG_FAMILY`, or `INCOMPATIBLE_SKETCH`.

#### Inherited from

`MinHashOperations.merge`

***

### reduce

> **reduce**: (`targetSignatureSize`) => `BytesMinHash`

Defined in: [packages/scalar-sketch/src/minhash.ts:72](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L72)

Return a new signature containing an ordered coordinate prefix. O(targetSignatureSize).

The target must be a supported power of two no larger than the current size.

#### Parameters

##### targetSignatureSize

`number`

#### Returns

`BytesMinHash`

#### Throws

With `INVALID_REDUCTION` for an unsupported target.

#### Inherited from

`MinHashOperations.reduce`

***

### scalarKind

> `readonly` **scalarKind**: `"bytes"`

Defined in: [packages/scalar-sketch/src/minhash.ts:82](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/minhash.ts#L82)

#### Overrides

[`MinHashMetadata`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/).[`scalarKind`](/reference/knotkit/scalar-sketch/interfaces/minhashmetadata/#scalarkind)
