quantize — ONED signal op

資料種類:signalsignal

呼叫: import fullseye as fs; fs.ledger.quantize(x, bits=8, mode='round', dither=None, seed=0)(要直接呼叫實作,import dsp; dsp.quantize(x, bits=8, mode='round', dither=None, seed=0);從台帳取用則 ops1d.get("quantize"))

用法

給出誤差模型的純量量化器(可選抖動)。

> 以下的詳細說明為原文 —— 摘要與標題已翻譯。

*bits* sets the number of levels `L = 2**bits` over the signal's own

min..max range. *mode* is `"round" (mid-tread, unbiased) or "truncate"`

(floor, the convention PIL's posterize and most fixed-point casts use).

The two differ by more than a rounding convention. With step

`Delta = range/(L-1) both have error variance Delta**2/12`, but

truncation also carries a mean of `-Delta/2`, so its mean square error is

truncate: Delta2/12 + (Delta/2)2 = Delta**2/3

round: Delta**2/12

— a factor of 4. Anything that measures a level (not just displays it)

must round.

*dither* adds noise before quantising so the error stops being a function

of the signal: `"tpdf"` (triangular, the audio standard — two uniform draws

summed, so the error's variance no longer depends on the sample value) or

`"rpdf"` (one uniform draw). Dither raises the total error power but removes

the correlation that makes quantisation audible as distortion rather than as

hiss. `seed` fixes the draw so the op stays deterministic.

Applicability. (1) The range is taken from *this* signal, so two signals

quantised separately do not share a scale. (2) `bits=1` with no dither is a

comparator, not a quantiser — the error model does not apply. (3) The error

model assumes the signal moves by more than a step between samples; on a flat

stretch the error is a constant offset, not noise.

參考(範例資料・文獻)

• 範例資料目錄(下載 URL / 授權) —— 2-D 用 skimage.data(BSD/公有領域)加合成圖,3-D 給出真實資料源(Stanford/PDS 等)的下載 URL。

• 運算子來歷與參考文獻 —— 該運算子族所依據的研究/方法出處。

• 演算法的正典(作者・年份)與用途見上面的族使用指南

可執行的範例(實際呼叫該運算子並已驗證的樣例)

poc_cold_chain_excursionpy -3.11 examples/poc_cold_chain_excursion.py

型別可銜接的下一個運算子(可接受 signal 作為輸入)

create_funct_1d_array · create_funct_1d_pairs · smooth_funct_1d_gauss · smooth_funct_1d_mean · derivate_funct_1d · integrate_funct_1d · zero_crossings_funct_1d · local_min_max_funct_1d

同類別(signal)

lowpass · highpass · bandpass · envelope · rms · local_std · companding_mu_law · resample


*Provenance: dsp.py — ONED 運算子登記表。本條目由 tools/opdocs.py md 自動產生(請勿手動編輯)。*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.