noise

package
v1.7.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package noise provides functionality for Vald.

package noise provides a noise generator for adding noise to vectors.

package noise provides a noise generator for adding noise to vectors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func func(i uint64, vec []float32) (res []float32)

type Modifier

type Modifier interface {
	// Mod returns a function which, given a sample index and a vector,
	// produces a modified vector with noise added.
	Mod() Func
}

Modifier defines the interface for adding noise on‑the‑fly. External packages obtain the noise‑adding function via the Mod method.

func New

func New(data [][]float32, num uint64, opts ...Option) Modifier

New constructs a new noiseGenerator instance using the Functional Option Pattern. It applies the default options first, then any user‑provided options. It precomputes the noise level and noise table size based on the input dataset and test sample count, and then precomputes the noise table. It returns a Modifier interface.

type Option

type Option func(*noiseGenerator)

Option is a functional option for configuring a noiseGenerator.

func WithLevelFactor

func WithLevelFactor(f float32) Option

WithLevelFactor sets the fraction of the average standard deviation used as the noise level.

func WithMinTableSize

func WithMinTableSize(s uint64) Option

WithMinTableSize sets the minimum allowed size for the noise table.

func WithTableDivisionFactor

func WithTableDivisionFactor(f uint64) Option

WithTableDivisionFactor sets the division factor used when sizing the noise table.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL