信息熵如何决定压缩的极限?
How does information entropy set the limit of compression?
香农熵量化了信源每符号的平均不确定度,单位比特。无损压缩的平均码长不可能低于熵,否则必然丢失信息或产生歧义。因此熵是理论下限,越接近它说明编码越高效。
Shannon entropy measures the average uncertainty per symbol of a source, in bits. No lossless code can average below the entropy without losing information or becoming ambiguous. Entropy is thus the theoretical lower bound; getting close to it means efficient coding.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 已核验 · Verified 2026-08-23
来源 · Source
Charles Petzold,《Code: The Hidden Language of Computer Hardware and Software》第2版,Microsoft Press,2022
C. Petzold, Code, 2nd ed., Microsoft Press, 2022; Chinese ed.《编码》
#信息熵 #香农 #下限
LZW 这类字典压缩怎么工作?
How do dictionary-based compressors like LZW work?
LZW 在扫描数据时动态建立“字符串到短码”的字典,遇到重复出现的短语就用更短的代码代替。发送端和接收端按相同规则各自重建字典,因此无需额外传字典。GIF 和早期 ZIP 都用了类似思想。
LZW builds a dictionary mapping strings to short codes on the fly, replacing repeated phrases with shorter codes. Sender and receiver rebuild the same dictionary by the same rules, so no separate dictionary is sent. GIF and early ZIP use this idea.
难度 专业 · 适合 高中(15-18)
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:此条未指向带版次的可引用著作(通识性内容、机构文件或未展开的英文书名),本库不提供独立书目出处;如需精确引用,需由编辑补全具体篇目与版次。
数据压缩
Data compression
#LZW #字典压缩 #无损
哈夫曼编码是怎么压缩数据的?
How does Huffman coding compress data?
哈夫曼编码给出现频率高的字符分配短码、频率低的分配长码,使平均码长最短。它先统计频率,再构造一棵最优二叉树,从根到叶的路径即为编码。解码端持有同样的树即可无损还原。
Huffman coding assigns short codes to frequent characters and long codes to rare ones, minimizing average code length. It counts frequencies, builds an optimal binary tree, and the path from root to leaf is the code. The decoder uses the same tree to recover data losslessly.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-10-04 · 2 条独立证据
来源 · Source
Cover 与 Thomas《信息论基础》(Elements of Information Theory, Wiley)
Cover & Thomas, Elements of Information Theory (Wiley)
独立核验依据 · Independent verification: 核验依据 1 ISBN 9780471241959 (2006) · 核验依据 2 ISBN 9780665590955 (2002)
#哈夫曼 #熵编码 #无损压缩
为什么数据不能被无限压缩?
Why can data not be compressed indefinitely?
随机、无规律的数据没有冗余可去,压缩后平均长度无法长期低于信息熵。若一种压缩对所有文件都缩小,就会有两个文件映射到同一结果,导致无法唯一还原。因此总存在压不动甚至变大的情况。
Random, patternless data has no redundancy to remove, and average length cannot stay below entropy. If one compressor shrank every file, two files would map to the same output and could not be uniquely restored. So some files simply will not compress, and may even grow.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23
来源 · Source
Charles Petzold,《Code: The Hidden Language of Computer Hardware and Software》第2版,Microsoft Press,2022
C. Petzold, Code, 2nd ed., Microsoft Press, 2022; Chinese ed.《编码》
#熵 #冗余 #不可能性
UTF-8 是如何编码文字的?
How does UTF-8 encode text?
UTF-8 用 1 到 4 个字节表示 Unicode 字符,英文字母仍占 1 字节,与 ASCII 完全兼容。它用首字节的高位标记总长度,后续字节以 10 开头以便识别。这样既节省空间又支持全球所有文字。
UTF-8 represents Unicode characters with 1 to 4 bytes; English letters stay 1 byte and remain ASCII-compatible. The leading bits of the first byte mark the total length, and continuation bytes start with 10 for easy detection. This saves space while supporting every script.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23
来源 · Source
Charles Petzold,《Code: The Hidden Language of Computer Hardware and Software》第2版,Microsoft Press,2022
C. Petzold, Code, 2nd ed., Microsoft Press, 2022; Chinese ed.《编码》
#UTF-8 #Unicode #变长编码
JPEG 图片为什么能压得很小?
Why can JPEG images be compressed so small?
JPEG 先把图像分块并转换到频率域,丢弃人眼不敏感的高频细节,再做量化与熵编码。它是有损压缩,所以体积远小于原始像素。压缩质量可调,越高保真则文件越大。
JPEG splits an image into blocks, transforms to the frequency domain, discards high-frequency details the eye barely notices, then quantizes and entropy-codes. Being lossy, it is far smaller than raw pixels. Quality is adjustable: higher fidelity means larger files.
难度 进阶 · 适合 大众
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:此条未指向带版次的可引用著作(通识性内容、机构文件或未展开的英文书名),本库不提供独立书目出处;如需精确引用,需由编辑补全具体篇目与版次。
图像压缩
Image compression
#JPEG #有损 #频率域
MP3 等音频压缩依据什么原理?
On what principle do MP3 and similar audio compressors work?
音频压缩利用心理声学,屏蔽掉人耳难以分辨的微弱声音和频率细节。再结合预测和熵编码去除冗余,可在几乎听不出差别的前提下大幅减小体积。它是有损压缩。
Audio compression uses psychoacoustics to hide faint sounds and fine frequencies the ear barely detects. Prediction and entropy coding then remove redundancy, shrinking files with little perceived difference. It is lossy.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23
来源 · Source
Charles Petzold,《Code: The Hidden Language of Computer Hardware and Software》第2版,Microsoft Press,2022
C. Petzold, Code, 2nd ed., Microsoft Press, 2022; Chinese ed.《编码》
#MP3 #心理声学 #有损
游程编码(RLE)适合什么数据?
What data is run-length encoding (RLE) good for?
游程编码把连续重复的值记成“值+重复次数”,例如把白白白黑记为 白3黑1。它对大面积同色、扫描线式的数据非常高效,如简单图标和传真。遇到频繁变化的数据反而可能越压越大。
Run-length encoding records consecutive repeats as value plus count, e.g. white white white black becomes white3 black1. It is very efficient for large uniform areas like simple icons and faxes. On frequently changing data it can even grow the size.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-11-02
来源 · Source
数据压缩入门
Compression primer
独立核验依据 · Independent verification: 核验依据 1 ISBN 9787115534170(豆瓣书目条目: 数据压缩入门)
#游程编码 #冗余 #图像
校验码(如 CRC)的作用是什么?
What is the role of a checksum such as CRC?
CRC 等校验码通过对数据做多项式运算得到一段短摘要,用于检测传输或存储中的意外错误。接收方重新计算并比对,不一致就说明数据受损。它只能发现错误,不能修复,也不是为防篡改而设计。
A checksum like CRC applies polynomial math to data to produce a short digest that detects accidental errors in transmission or storage. The receiver recomputes and compares; a mismatch means corruption. It detects but does not fix errors, and is not built to resist tampering.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23
来源 · Source
Charles Petzold,《Code: The Hidden Language of Computer Hardware and Software》第2版,Microsoft Press,2022
C. Petzold, Code, 2nd ed., Microsoft Press, 2022; Chinese ed.《编码》
#CRC #校验 #错误检测
视频为什么能被压缩到很小?
Why can video be compressed to a small size?
视频相邻帧之间变化很小,编码时只需记录与上一帧的差异,并去除空间上的重复纹理。再结合运动估计和人眼不敏感的细节丢弃,体积可缩小几十到上百倍。H.264、H.265 都是这类标准。
Adjacent video frames change little, so encoders mainly record differences from the previous frame and remove repeated texture in space. Combined with motion estimation and dropping imperceptible detail, size drops by tens to over a hundred times. H.264 and H.265 are such standards.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23
来源 · Source
Charles Petzold,《Code: The Hidden Language of Computer Hardware and Software》第2版,Microsoft Press,2022
C. Petzold, Code, 2nd ed., Microsoft Press, 2022; Chinese ed.《编码》
#视频压缩 #帧间 #编码标准
变长编码和定长编码各有什么优劣?
What are the trade-offs of variable-length vs fixed-length codes?
定长编码每个符号长度相同,简单且易随机访问,但可能浪费空间。变长编码按频率分配长短码,压缩率更高,却需要前缀无歧义的规则并增加了解析复杂度。哈夫曼码就是一种前缀码。
Fixed-length codes give every symbol the same size: simple and randomly accessible, but possibly wasteful. Variable-length codes assign short and long codes by frequency for better compression, yet need prefix-free rules and add parsing complexity. Huffman code is a prefix code.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23
来源 · Source
Charles Petzold,《Code: The Hidden Language of Computer Hardware and Software》第2版,Microsoft Press,2022
C. Petzold, Code, 2nd ed., Microsoft Press, 2022; Chinese ed.《编码》
#变长编码 #定长 #前缀码
Base64 是压缩算法吗?
Is Base64 a compression algorithm?
不是。Base64 只是把二进制数据用 64 个可打印字符表示,方便在邮件、URL 等纯文本环境传输。它反而会膨胀约 33% 的体积。它的作用是兼容而非压缩。
No. Base64 merely represents binary data with 64 printable characters so it can travel through text-only channels like email and URLs. It actually inflates size by about 33 percent. Its job is compatibility, not compression.
难度 进阶 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23
来源 · Source
Charles Petzold,《Code: The Hidden Language of Computer Hardware and Software》第2版,Microsoft Press,2022
C. Petzold, Code, 2nd ed., Microsoft Press, 2022; Chinese ed.《编码》
#Base64 #编码 #传输
奇偶校验是如何发现错误的?
How does parity check detect errors?
奇偶校验在数据中额外加一位,使 1 的总数为奇数或偶数。接收方统计后发现奇偶性不对,就知道传输出错。它只能检测单个位错误,无法定位也不能纠正。
A parity bit makes the total number of 1s odd or even. The receiver counts and, if parity is wrong, knows transmission failed. It detects only single-bit errors and cannot locate or correct them.
难度 入门 · 适合 大众
CC BY 4.0 · 已核验 · Verified 2026-08-23
来源 · Source
Charles Petzold,《Code: The Hidden Language of Computer Hardware and Software》第2版,Microsoft Press,2022
C. Petzold, Code, 2nd ed., Microsoft Press, 2022; Chinese ed.《编码》
#奇偶校验 #错误检测 #冗余位
为什么一段普通文本可以被压缩?
Why can ordinary text be compressed?
自然语言中字符和单词的出现频率很不均匀,且存在大量重复和规律。压缩算法利用这些冗余,用更短的符号表示常见内容。理想情况下数据越有规律、越冗余,压缩效果越好。
In natural language, characters and words appear with very uneven frequency and show much repetition and structure. Compression exploits this redundancy by representing common content with shorter symbols. The more regular and redundant the data, the better it compresses.
难度 入门 · 适合 大众
CC BY 4.0 · 来源待核验 · Source pending review
来源 · Source
出处备注:著录含书名,但缺版次 / 出版社 / 年份中的一部分,需编辑补全后才能做独立比对。
Shannon, C. E. (1948). 《通信的数学理论》. Bell System Technical Journal, 27(3), 379-423.
Shannon, C. E. (1948). A Mathematical Theory of Communication. Bell System Technical Journal, 27(3), 379-423.
#冗余 #频率 #编码