# Uint32CountMinSketch

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:89](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L89)

A Count-Min sketch specialized for unsigned 32-bit numbers.

## Extends

* [`CountMinSketchMetadata`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/)
* `CountMinSketchOperations`<`number`, `Uint32CountMinSketch`>

## Properties

### kind

> `readonly` **kind**: `"count-min-sketch"`

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:17](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L17)

#### Inherited from

[`CountMinSketchMetadata`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/).[`kind`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/#kind)

***

### width

> `readonly` **width**: `number`

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

Effective power-of-two column count.

#### Inherited from

[`CountMinSketchMetadata`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/).[`width`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/#width)

***

### depth

> `readonly` **depth**: `number`

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

Effective prefix-stable row count, from 1 through 32.

#### Inherited from

[`CountMinSketchMetadata`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/).[`depth`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/#depth)

***

### epsilon

> `readonly` **epsilon**: `number`

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

Model-based additive error factor `e / width`.

#### Inherited from

[`CountMinSketchMetadata`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/).[`epsilon`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/#epsilon)

***

### confidence

> `readonly` **confidence**: `number`

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

Model-based per-query confidence lower bound `1 - exp(-depth)`.

#### Inherited from

[`CountMinSketchMetadata`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/).[`confidence`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/#confidence)

***

### counterBits

> `readonly` **counterBits**: `32`

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:28](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L28)

Counter width, fixed at 32 bits.

#### Inherited from

[`CountMinSketchMetadata`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/).[`counterBits`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/#counterbits)

***

### totalWeight

> `readonly` **totalWeight**: `number`

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:30](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L30)

Accepted sum of update weights, capped at `2^32 - 1`.

#### Inherited from

[`CountMinSketchMetadata`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/).[`totalWeight`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/#totalweight)

***

### stateByteLength

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

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:32](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L32)

Bytes occupied by row-major counters, excluding object and hash-instance overhead.

#### Inherited from

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

***

### seed

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

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:34](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L34)

XXH64 base seed that participates in merge compatibility.

#### Inherited from

[`CountMinSketchMetadata`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/).[`seed`](/reference/knotkit/scalar-sketch/interfaces/countminsketchmetadata/#seed)

***

### seedSchedule

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

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:36](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L36)

Prefix-stable row-seed schedule that participates in merge compatibility.

#### Inherited from

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

***

### update

> **update**: (`value`, `weight?`) => `void`

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:48](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L48)

Add a non-negative unsigned 32-bit weight. Weight zero is a hash-free no-op.

All destination counters and the accepted total are checked before mutation.

#### Parameters

##### value

`number`

##### weight?

`number`

#### Returns

`void`

#### Throws

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

#### Throws

With `INVALID_WEIGHT`, `CAPACITY_EXCEEDED`, or `COUNTER_OVERFLOW`.

#### Inherited from

`CountMinSketchOperations.update`

***

### estimate

> **estimate**: (`value`) => `number`

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:58](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L58)

Return the minimum counter selected across all rows. Does not mutate the sketch.

For accepted non-negative streams the result never underestimates the exact frequency. The `epsilon` and `confidence` metadata are the classical model bounds, assuming the domain-separated seeded XXH64 rows behave independently.

#### Parameters

##### value

`number`

#### Returns

`number`

#### See

[An improved data stream summary: the Count-Min sketch](https://dimacs.rutgers.edu/~graham/pubs/papers/cm-full.pdf)

#### Throws

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

#### Inherited from

`CountMinSketchOperations.estimate`

***

### merge

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

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:66](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L66)

Add every counter and total from a compatible sketch into this sketch.

Self-merge uses the same additive semantics. Every overflow is rejected before mutation.

#### Parameters

##### other

`Uint32CountMinSketch`

#### Returns

`void`

#### Throws

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

#### Inherited from

`CountMinSketchOperations.merge`

***

### reduce

> **reduce**: (`targetWidth`, `targetDepth`) => `Uint32CountMinSketch`

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:73](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L73)

Return a new sketch with congruent columns summed and a deterministic row prefix retained.

The target width must divide the current width and both dimensions may only decrease.

#### Parameters

##### targetWidth

`number`

##### targetDepth

`number`

#### Returns

`Uint32CountMinSketch`

#### Throws

With `INVALID_REDUCTION` for an unsound target.

#### Inherited from

`CountMinSketchOperations.reduce`

***

### scalarKind

> `readonly` **scalarKind**: `"uint32"`

Defined in: [packages/scalar-sketch/src/count-min-sketch.ts:91](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/scalar-sketch/src/count-min-sketch.ts#L91)

#### Overrides

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