<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mathematical Foundations on Corebaseit — POS · EMV · Payments · AI · Telecommunications</title><link>https://corebaseit.com/categories/mathematical-foundations/</link><description>Recent content in Mathematical Foundations on Corebaseit — POS · EMV · Payments · AI · Telecommunications</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><managingEditor>contact@corebaseit.com (Vincent Bevia)</managingEditor><webMaster>contact@corebaseit.com (Vincent Bevia)</webMaster><lastBuildDate>Fri, 08 May 2026 12:00:00 +0200</lastBuildDate><atom:link href="https://corebaseit.com/categories/mathematical-foundations/index.xml" rel="self" type="application/rss+xml"/><item><title>Nyquist is not Shannon: why more samples does not mean more information</title><link>https://corebaseit.com/corebaseit_posts/nyquist_is_not_shannon/</link><pubDate>Fri, 08 May 2026 12:00:00 +0200</pubDate><author>contact@corebaseit.com (Vincent Bevia)</author><guid>https://corebaseit.com/corebaseit_posts/nyquist_is_not_shannon/</guid><description>&lt;p>Digital engineers are trained to treat &amp;ldquo;more&amp;rdquo; as a default win: higher clock rates, wider bandwidths, deeper bit depths. Applied to analog-to-digital conversion, the intuition follows naturally. Sample faster, capture more points per second, and the digital record should carry more information about the signal.&lt;/p>
&lt;p>That intuition breaks in a specific way. A receiver can ingest samples at gigahertz rates and still fail to recover the message. The waveform may be digitized faithfully while the symbols remain indistinguishable. Sampling governs representation. Channel capacity governs recoverable information. Those are related problems in a receiver chain, but they answer different questions.&lt;/p>
&lt;h2 id="two-limits-two-questions">Two limits, two questions
&lt;/h2>&lt;p align="center">
&lt;img src="https://corebaseit.com/diagrams/NyquistAndShannon.png" alt="Nyquist and Shannon: two limits, two questions. Nyquist path: analog signal, anti-aliasing filter, ADC sampling, digital samples — was the waveform preserved without aliasing? Shannon path: channel bandwidth, signal-to-noise ratio, modulation and coding, achievable data rate — can the message be recovered reliably?" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>&lt;strong>Nyquist&lt;/strong> (more precisely, the Nyquist–Shannon sampling theorem) sets the conditions under which a bandlimited continuous-time signal can be represented by discrete samples and reconstructed without aliasing. The sampling rate \(f_s\) must exceed twice the highest frequency \(f_{\max}\) in the signal. In practice, anti-aliasing filters enforce a usable band so that energy above \(f_s/2\) never reaches the ADC.&lt;/p>
&lt;p>&lt;strong>Shannon channel capacity&lt;/strong> sets the maximum rate at which information can be transmitted reliably over a noisy channel with bandwidth \(B\) and signal-to-noise ratio \(\mathrm{SNR}\):&lt;/p>
$$
C = B \log_2(1 + \mathrm{SNR})
$$&lt;p>Nyquist is about the analog–digital boundary: sample rate, filter transition bands, and spectral folding. Shannon is about the communication path: how many bits per second the channel can support given noise.&lt;/p>
&lt;p>A system can satisfy Nyquist and still fail at the Shannon layer. An ADC may capture the passband waveform with high fidelity, but if channel SNR is too low, constellation points smear across decision boundaries. The receiver has samples. It lacks evidence to pick the correct symbol. The waveform is preserved; the message is not recoverable at the target rate.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;/th>
&lt;th>Nyquist (sampling)&lt;/th>
&lt;th>Shannon (capacity)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Primary concern&lt;/td>
&lt;td>Waveform representation at the ADC&lt;/td>
&lt;td>Reliable information rate over a noisy channel&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Key variables&lt;/td>
&lt;td>\(f_s\), anti-aliasing filter, signal bandwidth&lt;/td>
&lt;td>Channel bandwidth \(B\), \(\mathrm{SNR}\)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Typical failure&lt;/td>
&lt;td>Aliasing: spectral overlap in the digitized band&lt;/td>
&lt;td>Symbol errors: noise dominates decision regions&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Fix direction&lt;/td>
&lt;td>Raise \(f_s\) or tighten the analog filter&lt;/td>
&lt;td>More power, better coding, wider channel, lower noise&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="aliasing-is-structural-damage">Aliasing is structural damage
&lt;/h2>&lt;p>When \(f_s \le 2f_{\max}\), high-frequency content folds into lower bands. That is aliasing: distinct spectral components become indistinguishable in the sampled sequence.&lt;/p>
&lt;p>Once overlap lands inside the band you intend to process, the mixture is not invertible. DSP, blind source separation, and forward error correction operate on the samples you already have. They cannot reconstruct which energy came from which original frequency component. FEC adds redundancy to survive bit errors; it does not undo a frequency-domain fold that happened at the sampler.&lt;/p>
&lt;p>This is why the anti-aliasing filter sits at the front of the chain. Its job is to keep out-of-band energy below the ADC so the first stored sample is not already corrupted.&lt;/p>
&lt;p>&lt;strong>Confirmed:&lt;/strong> Aliasing below the Nyquist rate is a sampling-theorem violation with no post-hoc digital fix.&lt;/p>
&lt;p>&lt;strong>Nuance:&lt;/strong> If you oversample and aliased images fall entirely outside the band of interest, digital filters can remove them. The irreversibility applies when folded energy overlaps the signal band you need to recover.&lt;/p>
&lt;h2 id="the-oversampling-fallacy-about-shannon-capacity">The oversampling fallacy about Shannon capacity
&lt;/h2>&lt;p>A common mistake is to treat a higher ADC sample rate \(f_s\) as if it were extra Shannon bandwidth. It is not.&lt;/p>
&lt;p>Shannon&amp;rsquo;s \(B\) is the bandwidth of the physical channel (or the effective information-bearing band after filtering), not the converter clock. Raising \(f_s\) without increasing usable bandwidth or SNR at the channel does not raise \(C\). Sampling a 10 MHz channel at 100 GHz with poor SNR gives you a dense record of a signal buried in noise. The sample count increases. The recoverable information rate does not.&lt;/p>
&lt;p>Oversampling also does not create independent observations of the channel. Samples taken faster than the signal bandwidth are correlated. Averaging them after proper filtering can improve implementation SNR in specific architectures, but the spectral-efficiency ceiling for the band is still set by Shannon&amp;rsquo;s formula on that band&amp;rsquo;s \(B\) and \(\mathrm{SNR}\).&lt;/p>
&lt;h2 id="what-oversampling-actually-buys-you">What oversampling actually buys you
&lt;/h2>&lt;p>Oversampling is an architecture lever, not a capacity multiplier.&lt;/p>
&lt;p>At the minimum Nyquist rate, the analog anti-aliasing filter must approximate a brick wall: very sharp rolloff, tight transition band, difficult phase and group-delay control. High-order analog filters are expensive, sensitive to component tolerance, and prone to passband ripple and group-delay variation. That group-delay flatness matters when you run high-order QAM: phase distortion at band edges directly hurts EVM.&lt;/p>
&lt;p>Sampling well above Nyquist widens the gap between the signal band and the first aliased image around \(f_s - f_{\max}\). The analog filter can roll off gently. The steep rejection moves to digital filters, where coefficients are exact, repeatable, and field-updatable.&lt;/p>
&lt;p>Oversampling also buys margin in the digital domain: more samples per symbol for timing recovery, simpler interpolation in clock recovery loops, and headroom against clock jitter in mobile links. These are implementation advantages. They simplify hardware and improve robustness. They do not rewrite the Shannon limit on the RF or wired channel feeding the receiver.&lt;/p>
&lt;h2 id="quantization-noise-spread-shape-filter">Quantization noise: spread, shape, filter
&lt;/h2>&lt;p>The other major payoff appears inside the ADC itself.&lt;/p>
&lt;p>A finite-resolution quantizer injects quantization noise. For a rough first-order model, total quantization noise power is set by step size and full-scale range. When you oversample by factor \(M\), that noise power spreads across a wider Nyquist band (up to \(f_s/2\)). Noise power spectral density in the original signal band drops by approximately \(M\), giving roughly 3 dB of in-band SNR improvement per doubling of sample rate for white quantization noise. That trades sample rate for effective resolution (often quoted as ENOB improvement). This is process gain against quantization noise, not an increase in Shannon channel capacity.&lt;/p>
&lt;p>Delta–sigma converters push further. A feedback loop shapes quantization noise out of the band of interest and into high frequencies where the oversampling headroom lives. A digital decimation filter then removes the shaped noise. The analog front end can stay coarse; precision emerges from digital filtering and noise shaping rather than from an impractically linear multi-bit analog quantizer at the input.&lt;/p>
&lt;p>Typical sequence:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Oversample&lt;/strong> — spread quantization noise across a wide band.&lt;/li>
&lt;li>&lt;strong>Shape&lt;/strong> — move noise energy out of the signal band (delta–sigma loop).&lt;/li>
&lt;li>&lt;strong>Decimate and filter&lt;/strong> — keep the signal band, discard the shaped noise.&lt;/li>
&lt;/ol>
&lt;h2 id="layered-constraints-in-real-receivers">Layered constraints in real receivers
&lt;/h2>&lt;p>Modern receivers in cellular base stations, Wi-Fi access points, and satellite modems hit both layers. Nyquist failures corrupt the waveform before baseband processing starts. Shannon failures leave the waveform intact but the link rate unsupportable at the target modulation and coding scheme.&lt;/p>
&lt;p>Useful design questions stay separate:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Nyquist layer:&lt;/strong> Did we band-limit and sample so the digitized waveform preserves the intended spectrum?&lt;/li>
&lt;li>&lt;strong>Shannon layer:&lt;/strong> Given channel \(B\) and \(\mathrm{SNR}\), can this modulation and code rate operate at the target BER or BLER?&lt;/li>
&lt;/ul>
&lt;p>Confusing the two produces expensive mistakes: chasing sample rate when the link is SNR-limited, or squeezing the analog filter while ignoring aliasing risk.&lt;/p>
&lt;p>In receiver work I have seen both failure modes. A lab trace with clean time-domain samples and a constellation plot that looks like a fuzzy disk is a Shannon-layer problem. A spectrum with folded interferers sitting on top of the wanted channel is a Nyquist-layer problem. The debug path differs completely.&lt;/p>
&lt;p>Oversampling belongs in the toolkit for filter relaxation, timing margin, and quantization noise management. Shannon&amp;rsquo;s formula still defines how much information the channel can carry. Nyquist still defines whether the ADC output is a faithful starting point. Keep the layers separate and the architecture gets easier to reason about.&lt;/p>
&lt;h2 id="references">References
&lt;/h2>&lt;ol>
&lt;li>
&lt;p>H. Nyquist, &amp;ldquo;Certain topics in telegraph transmission theory,&amp;rdquo; &lt;em>Transactions of the American Institute of Electrical Engineers&lt;/em>, vol. 47, no. 2, pp. 617–644, 1928.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>C. E. Shannon, &amp;ldquo;Communication in the presence of noise,&amp;rdquo; &lt;em>Proceedings of the IRE&lt;/em>, vol. 37, no. 1, pp. 10–21, Jan. 1949. (Shannon capacity formula for bandlimited AWGN channels.)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>C. E. Shannon, &amp;ldquo;A mathematical theory of communication,&amp;rdquo; &lt;em>Bell System Technical Journal&lt;/em>, vol. 27, pp. 379–423, 623–656, 1948.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>A. V. Oppenheim and R. W. Schafer, &lt;em>Discrete-Time Signal Processing&lt;/em>, 3rd ed. Pearson, 2010. (Sampling, aliasing, and discrete-time analysis.)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>J. G. Proakis and M. Salehi, &lt;em>Digital Communications&lt;/em>, 5th ed. McGraw-Hill, 2008. (Channel capacity, modulation, and receiver performance.)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>R. G. Lyons, &lt;em>Understanding Digital Signal Processing&lt;/em>, 3rd ed. Pearson, 2011. (Oversampling, decimation, and practical ADC considerations.)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>R. Schreier and G. C. Temes, &lt;em>Understanding Delta-Sigma Data Converters&lt;/em>. IEEE Press, 2005. (Noise shaping and oversampled converter architectures.)&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="further-reading">Further reading
&lt;/h2>&lt;ul>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/snr-qpsk/" >SNR: the number that decides whether a signal survives&lt;/a> — how noise shows up in receiver decisions&lt;/li>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/why-your-internet-has-speed-limit/" >Why your internet has a speed limit&lt;/a> — thermal noise and the physical noise floor&lt;/li>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/stochastic-entropy-ai/" >Stochastic, entropy &amp;amp; AI&lt;/a> — Shannon&amp;rsquo;s information-theoretic foundations in broader context&lt;/li>
&lt;/ul></description></item><item><title>FIR Filter Design on FPGA: Manual Engineering vs AI-Assisted Workflows</title><link>https://corebaseit.com/corebaseit_posts/fir-filter-fpga-manual-vs-ai-workflows/</link><pubDate>Tue, 05 May 2026 17:12:00 +0200</pubDate><author>contact@corebaseit.com (Vincent Bevia)</author><guid>https://corebaseit.com/corebaseit_posts/fir-filter-fpga-manual-vs-ai-workflows/</guid><description>&lt;p>Designing an FIR filter on FPGA still starts with fundamentals: convolution, z-domain structure, fixed-point limits, and synthesis constraints. AI can accelerate the workflow, but it does not remove the need for engineering judgment. In practice, the speed gains only hold when the output is verified with the same rigor used in a manual flow.&lt;/p>
&lt;p>This post walks through both paths using the same 8-tap low-pass example:&lt;/p>
&lt;ul>
&lt;li>Manual path: derive and validate the math, implement C reference code, write synthesizable Verilog, and verify behavior.&lt;/li>
&lt;li>AI-assisted path: use an agent to generate and iterate quickly, then validate outputs against deterministic checks.&lt;/li>
&lt;/ul>
&lt;h2 id="companion-document">Companion document
&lt;/h2>&lt;p>For the full engineering reference (extended derivations, full C and Verilog listings, and workflow comparison tables), download the companion PDF:&lt;/p>
&lt;p>&lt;strong>&lt;a class="link" href="https://corebaseit.com/downloads/fir-filter-manual-and-ai-reference.pdf" >Download the PDF -&amp;gt;&lt;/a>&lt;/strong>&lt;/p>
&lt;h2 id="the-baseline-what-must-be-correct-before-writing-rtl">The baseline: what must be correct before writing RTL
&lt;/h2>&lt;p>For a causal FIR of length \(N\):&lt;/p>
\[
y[n] = \sum_{k=0}^{N-1} h[k]\,x[n-k]
\]&lt;p>and&lt;/p>
\[
H(z) = \sum_{k=0}^{N-1} h[k] z^{-k}
\]&lt;p>If you rewrite \(H(z)\) as \(P(z)/z^{N-1}\), the denominator gives \(N-1\) poles at \(z=0\). That part is structural. The design behavior is driven by the zeros of \(P(z)\).&lt;/p>
&lt;p>For the coefficient set used here (Q15):&lt;/p>
\[
h = [1024, 2048, 4096, 8192, 8192, 4096, 2048, 1024]
\]&lt;p>Key properties:&lt;/p>
&lt;ul>
&lt;li>Symmetric taps \(h[k]=h[N-1-k]\) give linear phase.&lt;/li>
&lt;li>Group delay is constant: \((N-1)/2 = 3.5\) samples.&lt;/li>
&lt;li>DC gain is \(\sum h / 32768 = 31744/32768 \approx 0.969\).&lt;/li>
&lt;li>Nyquist response is zero for this set, confirming low-pass behavior.&lt;/li>
&lt;/ul>
&lt;p>These are fast checks and they catch many implementation mistakes early.&lt;/p>
&lt;h2 id="pole-zero-analysis-manual-c-vs-generated-code">Pole-zero analysis: manual C vs generated code
&lt;/h2>&lt;p>For \(N=8\), the numerator polynomial is degree 7, so closed-form roots are not practical. A numerical root finder (for example, Durand-Kerner) is the right engineering move.&lt;/p>
&lt;p>In a manual flow, writing and debugging the complex arithmetic takes time but gives full control over convergence and diagnostics. In an AI-assisted flow, the same solver is typically generated in seconds.&lt;/p>
&lt;p>The trade-off is straightforward:&lt;/p>
&lt;ul>
&lt;li>Manual: slower, but you understand every line and failure mode.&lt;/li>
&lt;li>AI-assisted: much faster draft, but you must verify normalization, convergence tolerance, and root interpretation.&lt;/li>
&lt;/ul>
&lt;p>For symmetric palindromic FIR polynomials, zeros appear in reciprocal-conjugate pairs. In this coefficient set, zeros lie on the unit circle, which matches stopband notch behavior.&lt;/p>
&lt;h2 id="rtl-architecture-choice-direct-form-or-transpose-form">RTL architecture choice: direct form or transpose form
&lt;/h2>&lt;p>Both forms are valid. The right choice depends on clock target and debug priorities.&lt;/p>
&lt;p>Direct form is often easier to inspect in simulation because the delay line is explicit. Transpose form usually closes timing at higher frequencies on modern FPGA DSP slices due to cascade-friendly accumulation.&lt;/p>
&lt;p>For Xilinx UltraScale+ devices, transpose form maps naturally to DSP48E2 cascade paths (PCIN/PCOUT), reducing fabric routing pressure in the accumulator chain.&lt;/p>
&lt;p>Practical rule:&lt;/p>
&lt;ul>
&lt;li>If you are iterating quickly or tap count is modest, direct form is easier to debug.&lt;/li>
&lt;li>If Fmax is tight, transpose form is usually the safer production architecture.&lt;/li>
&lt;/ul>
&lt;h2 id="fixed-point-discipline-is-not-optional">Fixed-point discipline is not optional
&lt;/h2>&lt;p>A reliable accumulator width rule is:&lt;/p>
\[
ACC\_WIDTH \ge DATA\_WIDTH + COEF\_WIDTH + \lceil \log_2(N) \rceil
\]&lt;p>For 16-bit data, 16-bit coefficients, and \(N=8\):&lt;/p>
\[
ACC\_WIDTH \ge 16 + 16 + 3 = 35
\]&lt;p>Using 40 bits gives practical margin and simplifies edge-case handling when pre-adders and saturation logic are included.&lt;/p>
&lt;p>Before touching synthesis reports, validate three items in software:&lt;/p>
&lt;ol>
&lt;li>Impulse response reproduces coefficients in order.&lt;/li>
&lt;li>DC and Nyquist points match expected values.&lt;/li>
&lt;li>Overflow behavior is explicit and deterministic.&lt;/li>
&lt;/ol>
&lt;p>This avoids burning time in RTL debug for issues that are purely numeric.&lt;/p>
&lt;h2 id="what-ai-changes-in-the-engineering-loop">What AI changes in the engineering loop
&lt;/h2>&lt;p>AI is strong at producing boilerplate and first-pass implementations:&lt;/p>
&lt;ul>
&lt;li>C99 FIR helpers (frequency response, coefficient generation, fixed-point simulation)&lt;/li>
&lt;li>Parameterized Verilog modules and testbenches&lt;/li>
&lt;li>Documentation and consistency checks across artifacts&lt;/li>
&lt;/ul>
&lt;p>AI is weaker where project context and hardware constraints dominate:&lt;/p>
&lt;ul>
&lt;li>Timing closure decisions&lt;/li>
&lt;li>Device-specific synthesis behavior&lt;/li>
&lt;li>Numerical edge cases at format boundaries&lt;/li>
&lt;li>Silent assumptions in prompt wording&lt;/li>
&lt;/ul>
&lt;p>The practical operating model is:&lt;/p>
&lt;ul>
&lt;li>Use AI for acceleration.&lt;/li>
&lt;li>Keep deterministic verification as gate criteria.&lt;/li>
&lt;li>Treat generated code as untrusted until it passes the same checks as handwritten code.&lt;/li>
&lt;/ul>
&lt;p>That model preserves velocity without lowering engineering standards.&lt;/p>
&lt;h2 id="a-verification-protocol-that-scales">A verification protocol that scales
&lt;/h2>&lt;p>When using an agent for DSP + FPGA tasks, this checklist keeps quality stable:&lt;/p>
&lt;ul>
&lt;li>Confirm poles and zero magnitudes against expected structure.&lt;/li>
&lt;li>Recompute key response points independently (at least DC and Nyquist).&lt;/li>
&lt;li>Run impulse and sine tests in simulation and compare with software reference output.&lt;/li>
&lt;li>Inspect synthesis utilization to confirm intended DSP inference.&lt;/li>
&lt;li>Check timing reports for the actual critical path, not the expected one.&lt;/li>
&lt;/ul>
&lt;p>If these checks pass, AI is a clear multiplier. If they are skipped, speed gains disappear quickly.&lt;/p>
&lt;h2 id="closing-perspective">Closing perspective
&lt;/h2>&lt;p>Manual engineering and AI-assisted engineering are not competing methods. They are layered methods. The manual path builds the model in your head; the AI path compresses execution time once that model exists.&lt;/p>
&lt;p>In FIR-on-FPGA work, that distinction matters. The engineer still owns correctness, timing, and numerical integrity. AI can do a lot of work. It cannot assume responsibility.&lt;/p>
&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/FIR1.png" alt="FIR design workflow diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>This diagram summarizes the full thread of the post: start from FIR fundamentals in the z-domain, choose an RTL structure that fits timing targets, validate fixed-point behavior before synthesis, and use AI as an accelerator only after deterministic checks are in place. It is the same workflow, with and without AI; the difference is execution speed, not verification rigor.&lt;/p>
&lt;h2 id="references">References
&lt;/h2>&lt;ol>
&lt;li>A. V. Oppenheim and R. W. Schafer, &lt;em>Discrete-Time Signal Processing&lt;/em>, 3rd ed., Pearson, 2010.&lt;/li>
&lt;li>J. G. Proakis and D. G. Manolakis, &lt;em>Digital Signal Processing: Principles, Algorithms, and Applications&lt;/em>, 4th ed., Pearson, 2006.&lt;/li>
&lt;li>Xilinx, &lt;em>FIR Compiler v7.2 Product Guide (PG149)&lt;/em>, AMD/Xilinx.&lt;/li>
&lt;li>Xilinx, &lt;em>UltraScale Architecture DSP Slice User Guide (UG579)&lt;/em>, AMD/Xilinx.&lt;/li>
&lt;li>Intel, &lt;em>AN 306: Implementing FIR Filters in Intel FPGA Devices&lt;/em>, Intel Corporation.&lt;/li>
&lt;li>IEEE, &lt;em>IEEE Std 1800-2017: SystemVerilog Language Reference Manual&lt;/em>, IEEE.&lt;/li>
&lt;/ol></description></item><item><title>Adaptive Filters and Stochastic Gradient Descent: One Update Rule, Two Vocabularies</title><link>https://corebaseit.com/corebaseit_posts/lms_new_for_corebaseit/</link><pubDate>Wed, 29 Apr 2026 10:00:00 +0200</pubDate><author>contact@corebaseit.com (Vincent Bevia)</author><guid>https://corebaseit.com/corebaseit_posts/lms_new_for_corebaseit/</guid><description>&lt;p>Modern AI is often framed as a clean break from classical engineering. For anyone who has worked in adaptive signal processing, that framing is misleading. The mathematical spine of stochastic gradient descent (SGD) is the same spine that has driven adaptive filters in telecommunications since 1960, and the engineering trade-offs that made LMS-based equalizers and echo cancellers reliable in production map almost directly onto the ones that govern training a deep network today.&lt;/p>
&lt;p>This post lays out that mapping carefully. The intent is not poetry. It is to give engineers who came up through DSP a precise translation table into modern ML, and engineers who came up through ML a sense of what fifty years of adaptive filtering literature already settled.&lt;/p>
&lt;h2 id="a-continuous-lineage-not-a-new-beginning">A Continuous Lineage, Not a New Beginning
&lt;/h2>&lt;p>The historical sequence is short and well-documented. Widrow and Hoff formalized the Least Mean Squares (LMS) algorithm in 1960 for the Adaline (Adaptive Linear Neuron). Rumelhart, Hinton, and Williams scaled the same family of error-driven update rules to multi-layer networks with backpropagation in 1986. The vocabulary moved from &lt;em>adaptive filtering&lt;/em> to &lt;em>deep learning&lt;/em>, but the underlying move — iterative parameter adjustment proportional to error — was continuous across both worlds.&lt;/p>
&lt;p>The claim of this post is narrower than &amp;ldquo;AI came from DSP&amp;rdquo; and more useful: &lt;strong>for a linear model trained on mean squared error, the LMS update is exactly the SGD update&lt;/strong>. Multi-layer training adds the chain rule on top of that local move; it does not replace it.&lt;/p>
&lt;h2 id="lms-as-stochastic-gradient-descent">LMS as Stochastic Gradient Descent
&lt;/h2>&lt;p>The LMS update for a linear combiner (FIR filter or single Adaline) is:&lt;/p>
$$
\mathbf{w}(n+1) = \mathbf{w}(n) + \mu \, e(n) \, \mathbf{x}(n)
$$&lt;p>with \(\mathbf{w}(n)\) the weight vector at step \(n\), \(\mathbf{x}(n)\) the input vector (tap-delay line in DSP, feature vector in ML), \(e(n) = d(n) - y(n)\) the error between the desired response \(d(n)\) and the output \(y(n) = \mathbf{w}^\top(n)\,\mathbf{x}(n)\), and \(\mu\) the step size.&lt;/p>
&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/LMS_SGD_structural_equivalence_diagram.png" alt="LMS = SGD structural equivalence diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>The instantaneous squared error is \(\xi(n) = \tfrac{1}{2}e^2(n)\), and its gradient with respect to \(\mathbf{w}\) is \(-e(n)\,\mathbf{x}(n)\). Substituting that gradient into the standard SGD form recovers the LMS update line for line.&lt;/p>
&lt;p>The &amp;ldquo;stochastic&amp;rdquo; qualifier deserves the same scrutiny. Classical Wiener filtering minimizes the &lt;em>expected&lt;/em> squared error \(E[e^2(n)]\), which presupposes knowledge of the input statistics. LMS sidesteps that requirement by using the &lt;em>instantaneous&lt;/em> squared error \(e^2(n)\) as a high-variance, zero-cost estimator of the expectation. SGD uses the same trick at higher dimensionality: the per-batch loss is a noisy estimate of the population loss, and the noise is doing real work in shaping the optimization trajectory.&lt;/p>
&lt;p>The mapping between the two vocabularies for a linear MSE layer is one-to-one:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Symbol&lt;/th>
&lt;th>Adaptive filtering (DSP)&lt;/th>
&lt;th>Deep learning (ML)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>\(\mathbf{w}\)&lt;/td>
&lt;td>Filter coefficients / weight vector&lt;/td>
&lt;td>Weight vector / parameters&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\mathbf{x}\)&lt;/td>
&lt;td>Input vector / tap-delay line&lt;/td>
&lt;td>Feature vector / activations&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(e(n)\)&lt;/td>
&lt;td>Desired response \(d(n)\) minus output&lt;/td>
&lt;td>Target label minus prediction&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\mu\)&lt;/td>
&lt;td>Step size&lt;/td>
&lt;td>Learning rate \(\eta\)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\tfrac{1}{2}e^2\)&lt;/td>
&lt;td>Instantaneous squared error&lt;/td>
&lt;td>MSE loss on a single example&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>So if you have ever shipped an LMS equalizer or echo canceller, you have implemented the local update rule that underlies a large fraction of modern machine learning: small steps proportional to error times input. Notation in Haykin&amp;rsquo;s &lt;em>Adaptive Filter Theory&lt;/em> differs from the PyTorch docs. The mathematics does not.&lt;/p>
&lt;p>Multi-layer networks add the chain rule (backpropagation) so error can be attributed back through nonlinear layers. The local update at any linear layer trained on MSE is still the same structural move: adjust weights in proportion to error and activations. Momentum, Adam, and adaptive learning rates are engineering on top of that spine, not departures from it.&lt;/p>
&lt;h2 id="step-size-learning-rate-and-the-geometry-of-the-loss-surface">Step Size, Learning Rate, and the Geometry of the Loss Surface
&lt;/h2>&lt;p>In telecommunications, the step size \(\mu\) governs the classic compromise between convergence speed and steady-state misadjustment. Too large and the filter can diverge or oscillate. Too small and the filter cannot track a fast-fading channel or a moving echo path. Adaptive filtering textbooks devote whole chapters to stability bounds on \(\mu\), usually expressed in terms of input power and filter length, and to variants designed to fix the worst-case behavior.&lt;/p>
&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/Step_size_learning_rate_trade-off_diagram.png" alt="Step size / learning rate trade-off diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>There is a more specific geometric point worth surfacing, because it carries directly into deep learning. The allowable bounds on \(\mu\) for LMS depend on the eigenvalue spread of the input autocorrelation matrix \(\mathbf{R} = E[\mathbf{x}\mathbf{x}^\top]\). When \(\mathbf{R}\) is poorly conditioned — long tap-delay lines with strongly correlated inputs are a familiar offender — convergence in slow eigen-directions becomes painful, and a step size that is safe in one direction is too aggressive in another. Increasing the filter length tends to worsen this conditioning rather than help it.&lt;/p>
&lt;p>This is the same pathology that shows up in deep learning when the loss surface is poorly conditioned. Plain gradient descent crawls along flat directions and bounces along steep ones. Per-coordinate scaling inside Adam, preconditioners, and the entire warm-up / cosine-decay literature exist to attack different facets of that conditioning problem. The DSP community called these &lt;em>eigenvalue spread&lt;/em> problems for decades before the ML community started calling them &lt;em>ill-conditioned loss landscapes&lt;/em>.&lt;/p>
&lt;p>In deep learning, the learning rate \(\eta\) plays the same role as \(\mu\) at higher abstraction. Too high and training diverges or chatters around a minimum. Too low and you underfit or burn compute without making progress. Learning-rate schedules, warm-up, and cosine decay are all variations on a single instinct: the right step size depends on the local geometry and may need to change over time.&lt;/p>
&lt;h2 id="normalization-nlms-rmsprop-adam">Normalization: NLMS, RMSProp, Adam
&lt;/h2>&lt;p>To handle wide variations in input signal power, adaptive-filtering practitioners developed Normalized LMS (NLMS), which scales the update by the inverse of the current input energy:&lt;/p>
$$
\mathbf{w}(n+1) = \mathbf{w}(n) + \frac{\mu}{\|\mathbf{x}(n)\|^2 + \delta} \, e(n) \, \mathbf{x}(n)
$$&lt;p>with \(\delta\) a small regularizer that keeps the denominator from collapsing.&lt;/p>
&lt;p>There is a real conceptual line from NLMS to modern adaptive optimizers like RMSProp and Adam. There is also a real mechanical distinction that pop-ML writeups tend to flatten. NLMS normalizes by the &lt;em>instantaneous&lt;/em> input energy of the current sample. RMSProp and Adam normalize by an &lt;em>exponential moving average of squared gradients&lt;/em>. The intent is shared — keep the update from being driven by signal scale rather than error — but they react on different time horizons and stabilize different things in practice.&lt;/p>
&lt;p>Two further points are worth stating without dressing them up.&lt;/p>
&lt;p>First, computational cost is part of why LMS and NLMS won and stayed. Both are \(O(N)\) per update in the filter length \(N\). Recursive Least Squares (RLS) and Newton-style methods give faster theoretical convergence but cost \(O(N^2)\) or worse, which is why nobody runs full second-order optimization on a 70-billion-parameter model either. &amp;ldquo;Good enough updates, very fast&amp;rdquo; beat &amp;ldquo;perfect updates, eventually&amp;rdquo; both in real-time DSP hardware and in the GPU cluster.&lt;/p>
&lt;p>Second, normalization by signal-scale statistics is the primary defense against divergence in high-variance environments. The exact statistic differs by algorithm, but the principle is shared across NLMS, RMSProp, Adam, and most of the layer-norm / batch-norm family: bound the update magnitude using something derived from the signal, so error can drive the direction without scale dominating the magnitude.&lt;/p>
&lt;h2 id="tracking-not-convergence">Tracking, Not Convergence
&lt;/h2>&lt;p>Adaptive filters were built for non-stationary environments: multipath fading, time-varying echoes, drifting noise floors. The &amp;ldquo;true&amp;rdquo; optimal weights are not fixed; they move. The filter is not supposed to converge once and freeze. It is supposed to &lt;em>track&lt;/em>. That mindset is much closer to production ML than the static batch fit on a fixed dataset that introductory courses still tend to lead with.&lt;/p>
&lt;p>Modern systems face the same phenomenon under different labels:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Distribution shift&lt;/strong> — the input distribution drifts.&lt;/li>
&lt;li>&lt;strong>Concept drift&lt;/strong> — the input-to-target relationship drifts.&lt;/li>
&lt;li>&lt;strong>Stale features&lt;/strong> — engineered signals decay as the underlying world changes.&lt;/li>
&lt;/ul>
&lt;p>The framing change matters. In a non-stationary environment, &amp;ldquo;convergence&amp;rdquo; is the wrong success metric. The right metric is &lt;em>tracking&lt;/em>: how well the system follows the moving optimum, with what lag, and at what excess error. DSP literature has been formal about this for decades — excess mean-square error, lag noise, tracking misadjustment — while production ML still tends to discover it informally, usually after a regression has shipped.&lt;/p>
&lt;p>Research on in-context learning in linear models (Akyürek et al., 2022) even investigates which classical learning algorithms are implicitly approximated by transformers under simplified conditions. That is one more sign that the boundary between adaptive signal processing and contemporary ML is thinner than course catalogs suggest.&lt;/p>
&lt;h2 id="a-continuous-mathematical-thread">A Continuous Mathematical Thread
&lt;/h2>&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/Historical_lineage_timeline_diagram.png" alt="Historical lineage / timeline diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>The transition from digital signal processing to artificial intelligence is more a change of vocabulary than a change of fundamental principles. The engineering rigor required to stabilize an echo canceller in 1970 is the same rigor required to train a multi-billion-parameter model today: error-driven updates, step-size discipline, normalization to handle input-scale variance, and the discipline of tracking a moving target rather than converging on a fixed one.&lt;/p>
&lt;p>For engineers coming from telecommunications, the move into AI is not a career pivot. It is recognition that the tools they already carry — stability analysis, second-order statistics, non-stationary tracking, complexity-aware design — are exactly the tools the new domain still depends on. For engineers coming from ML, the DSP literature is a large, well-tested archive of solutions to problems that show up again at scale.&lt;/p>
&lt;p>If you understand LMS, you already understand a piece of what every deep learning framework is doing when it steps the weights. The rest is scale, architecture, and tooling.&lt;/p>
&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/lms_corebaseit.png" alt="Step size / learning rate trade-off diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;hr>
&lt;h2 id="references">References
&lt;/h2>&lt;ul>
&lt;li>Widrow, B., &amp;amp; Hoff, M. E. &amp;ldquo;Adaptive switching circuits.&amp;rdquo; &lt;em>IRE WESCON Convention Record&lt;/em>, 4, 96–104, 1960.&lt;/li>
&lt;li>Haykin, S. &lt;em>Adaptive Filter Theory&lt;/em> (4th ed.). Prentice Hall, 2002.&lt;/li>
&lt;li>Rumelhart, D. E., Hinton, G. E., &amp;amp; Williams, R. J. &amp;ldquo;Learning representations by back-propagating errors.&amp;rdquo; &lt;em>Nature&lt;/em>, 323, 533–536, 1986.&lt;/li>
&lt;li>Sayed, A. H. &lt;em>Adaptive Filters&lt;/em>. Wiley-IEEE Press, 2008.&lt;/li>
&lt;li>Kingma, D. P., &amp;amp; Ba, J. &amp;ldquo;Adam: A Method for Stochastic Optimization.&amp;rdquo; &lt;em>ICLR&lt;/em>, 2015. &lt;a class="link" href="https://arxiv.org/abs/1412.6980" target="_blank" rel="noopener"
>arxiv.org/abs/1412.6980&lt;/a>&lt;/li>
&lt;li>Tieleman, T., &amp;amp; Hinton, G. &amp;ldquo;Lecture 6.5 — RMSProp: Divide the gradient by a running average of its recent magnitude.&amp;rdquo; &lt;em>COURSERA: Neural Networks for Machine Learning&lt;/em>, 2012.&lt;/li>
&lt;li>Akyürek, E., Schuurmans, D., Andreas, J., Ma, T., &amp;amp; Zhou, D. &amp;ldquo;What learning algorithm is in-context learning? Investigations with linear models.&amp;rdquo; 2022. &lt;a class="link" href="https://arxiv.org/abs/2211.15661" target="_blank" rel="noopener"
>arxiv.org/abs/2211.15661&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="further-reading">Further Reading
&lt;/h2>&lt;ul>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/lms-adaptive-filters-and-neural-network-training/" >I Spent Years on Adaptive Filters. I Was Already Training Neural Networks.&lt;/a> — the same lineage, told from personal experience.&lt;/li>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/stochastic-entropy-ai/" >Stochastic, Entropy &amp;amp; AI: From Thermodynamics to Information Theory to Modern Machine Learning&lt;/a> — adjacent thread on probability, information, and ML foundations.&lt;/li>
&lt;/ul></description></item><item><title>Deriving MMSE: what the Wiener filter actually minimizes</title><link>https://corebaseit.com/corebaseit_posts/mmse-wiener-filter-derivation/</link><pubDate>Sun, 26 Apr 2026 15:00:00 +0200</pubDate><author>contact@corebaseit.com (Vincent Bevia)</author><guid>https://corebaseit.com/corebaseit_posts/mmse-wiener-filter-derivation/</guid><description>&lt;p>The Wiener filter has a clean claim: among all linear filters operating on wide-sense stationary input, it produces the minimum mean-square estimation error. That claim has a closed-form proof, and the proof is short enough to walk through completely.&lt;/p>
&lt;p>This post derives the Minimum Mean-Square Error (MMSE) starting from the cost function, through the Wiener-Hopf equation, to the final result. Every step is explicit. If you have worked with adaptive filters (LMS, NLMS, RLS), this is the deterministic optimum those algorithms approach iteratively without knowing the statistics in advance.&lt;/p>
&lt;p>A companion lab implements the full derivation in MATLAB, Python, C, and C++: &lt;a class="link" href="https://github.com/Bevia/MMSE-Wiener-Filter-Lab" target="_blank" rel="noopener"
>MMSE-Wiener-Filter-Lab&lt;/a>.&lt;/p>
&lt;h2 id="setup-and-notation">Setup and notation
&lt;/h2>&lt;p>A linear filter with weight vector \(\mathbf{w}\) of length \(N\) receives input vector \(\mathbf{x}(n)\) and produces the estimate:&lt;/p>
\[
y(n) = \mathbf{w}^T \mathbf{x}(n)
\]&lt;p>The desired (target) signal is \(d(n)\). The estimation error is:&lt;/p>
\[
e(n) = d(n) - y(n) = d(n) - \mathbf{w}^T \mathbf{x}(n)
\]&lt;p>The filter&amp;rsquo;s job is to choose \(\mathbf{w}\) so that \(e(n)\) is as small as possible in a statistical sense. For real-valued signals, the cost function is the mean-square error:&lt;/p>
\[
\xi(\mathbf{w}) = E\!\left[e^2(n)\right]
\]&lt;p>Two statistical quantities determine everything that follows:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Symbol&lt;/th>
&lt;th>Definition&lt;/th>
&lt;th>Structure&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>\(\mathbf{R}\)&lt;/td>
&lt;td>\(E[\mathbf{x}(n)\mathbf{x}^T(n)]\)&lt;/td>
&lt;td>\(N \times N\) autocorrelation matrix of the input&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\mathbf{p}\)&lt;/td>
&lt;td>\(E[\mathbf{x}(n)\,d(n)]\)&lt;/td>
&lt;td>\(N \times 1\) cross-correlation between input and desired signal&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>For a wide-sense stationary process, \(\mathbf{R}\) is Toeplitz and positive semi-definite by construction. It is positive definite when no sample in the observation window is a perfect linear combination of the others. That non-degeneracy condition is what guarantees a unique optimum.&lt;/p>
&lt;h2 id="expanding-the-cost-function">Expanding the cost function
&lt;/h2>&lt;p>Start from the definition and expand the square:&lt;/p>
\[
\xi = E\!\left[(d(n) - \mathbf{w}^T \mathbf{x}(n))^2\right]
\]\[
= E\!\left[d^2(n)\right] - 2\,\mathbf{w}^T E\!\left[\mathbf{x}(n)\,d(n)\right] + \mathbf{w}^T E\!\left[\mathbf{x}(n)\mathbf{x}^T(n)\right]\mathbf{w}
\]&lt;p>Substituting the definitions of \(\mathbf{p}\) and \(\mathbf{R}\):&lt;/p>
\[
\xi = E\!\left[d^2(n)\right] - 2\,\mathbf{w}^T \mathbf{p} + \mathbf{w}^T \mathbf{R}\,\mathbf{w}
\]&lt;p>This is a scalar-valued quadratic in \(\mathbf{w}\). The first term, \(E[d^2(n)]\), is the variance (power) of the desired signal, fixed by the data. The second and third terms depend on \(\mathbf{w}\). Because \(\mathbf{R}\) is positive definite, \(\xi(\mathbf{w})\) is strictly convex with a single global minimum. Geometrically, it is a bowl-shaped surface in \(N\)-dimensional weight space.&lt;/p>
&lt;p>The weight vector \(\mathbf{w}\) is the only thing under the designer&amp;rsquo;s control. \(\mathbf{R}\) and \(\mathbf{p}\) are determined by the signal environment.&lt;/p>
&lt;h2 id="the-wiener-hopf-equation">The Wiener-Hopf equation
&lt;/h2>&lt;p>The minimum of a differentiable convex function is where the gradient vanishes. Taking the gradient of \(\xi\) with respect to \(\mathbf{w}\):&lt;/p>
\[
\nabla_{\mathbf{w}}\,\xi = -2\,\mathbf{p} + 2\,\mathbf{R}\,\mathbf{w}
\]&lt;p>Setting to zero and solving for the optimal weight vector:&lt;/p>
\[
\mathbf{R}\,\mathbf{w}_{\text{opt}} = \mathbf{p}
\]\[
\mathbf{w}_{\text{opt}} = \mathbf{R}^{-1}\,\mathbf{p}
\]&lt;p>This is the Wiener-Hopf equation [1][2]. It has a unique solution when \(\mathbf{R}\) is positive definite (and therefore invertible). The optimal weights depend only on the second-order statistics of the input and the cross-statistics between input and desired signal. No higher-order moments are needed.&lt;/p>
&lt;p>One thing to note about practice: computing \(\mathbf{R}^{-1}\) directly is \(O(N^3)\) and numerically fragile when the eigenvalue spread of \(\mathbf{R}\) is large (ill-conditioned input). This is a primary motivation for adaptive algorithms. LMS approximates \(\mathbf{w}_{\text{opt}}\) iteratively at \(O(N)\) per update, without ever forming or inverting \(\mathbf{R}\).&lt;/p>
&lt;h2 id="deriving-the-minimum-mse">Deriving the minimum MSE
&lt;/h2>&lt;p>To find the error floor, substitute \(\mathbf{w}_{\text{opt}} = \mathbf{R}^{-1}\mathbf{p}\) back into the cost function:&lt;/p>
\[
\xi_{\min} = E\!\left[d^2(n)\right] - 2\,(\mathbf{R}^{-1}\mathbf{p})^T\,\mathbf{p} + (\mathbf{R}^{-1}\mathbf{p})^T\,\mathbf{R}\,(\mathbf{R}^{-1}\mathbf{p})
\]&lt;p>The simplification uses three properties of real-valued autocorrelation matrices. The transpose of a product reverses order: \((\mathbf{AB})^T = \mathbf{B}^T\mathbf{A}^T\). The matrix \(\mathbf{R}\) is symmetric (\(\mathbf{R} = \mathbf{R}^T\)), so its inverse is also symmetric: \((\mathbf{R}^{-1})^T = \mathbf{R}^{-1}\). And a matrix times its own inverse yields the identity: \(\mathbf{R}^{-1}\mathbf{R} = \mathbf{I}\).&lt;/p>
&lt;p>Apply these to the second term:&lt;/p>
\[
-2\,(\mathbf{R}^{-1}\mathbf{p})^T\mathbf{p} = -2\,\mathbf{p}^T(\mathbf{R}^{-1})^T\mathbf{p} = -2\,\mathbf{p}^T\mathbf{R}^{-1}\mathbf{p}
\]&lt;p>And the third term:&lt;/p>
\[
(\mathbf{R}^{-1}\mathbf{p})^T\,\mathbf{R}\,(\mathbf{R}^{-1}\mathbf{p}) = \mathbf{p}^T\mathbf{R}^{-1}\,\mathbf{R}\,\mathbf{R}^{-1}\mathbf{p} = \mathbf{p}^T\,(\mathbf{I})\,\mathbf{R}^{-1}\mathbf{p} = \mathbf{p}^T\,\mathbf{R}^{-1}\,\mathbf{p}
\]&lt;p>The second term contributes \(-2\,\mathbf{p}^T\mathbf{R}^{-1}\mathbf{p}\). The third contributes \(+\mathbf{p}^T\mathbf{R}^{-1}\mathbf{p}\). They partially cancel:&lt;/p>
\[
\boxed{\xi_{\min} = E\!\left[d^2(n)\right] - \mathbf{p}^T\,\mathbf{R}^{-1}\,\mathbf{p}}
\]&lt;p>Since \(\mathbf{R}^{-1}\mathbf{p} = \mathbf{w}_{\text{opt}}\), this is equivalently:&lt;/p>
\[
\xi_{\min} = E\!\left[d^2(n)\right] - \mathbf{p}^T\,\mathbf{w}_{\text{opt}}
\]&lt;p>The quantity \(\mathbf{p}^T \mathbf{w}_{\text{opt}}\) is a scalar, so it equals its own transpose \(\mathbf{w}_{\text{opt}}^T \mathbf{p}\). Both forms appear in the literature [2][3].&lt;/p>
&lt;h2 id="what-the-result-says">What the result says
&lt;/h2>&lt;p>The MMSE has two components. The first, \(E[d^2(n)]\), is the total power of the signal you are trying to estimate. The second, \(\mathbf{p}^T \mathbf{R}^{-1} \mathbf{p}\), is the portion of that power the filter can explain using the input data. The difference is what remains unexplained: the irreducible estimation error for any linear filter under these statistics.&lt;/p>
&lt;p>The MSE cannot go negative. If \(\mathbf{p}^T \mathbf{R}^{-1} \mathbf{p} = E[d^2(n)]\), the filter reconstructs the desired signal with zero error. That happens when \(d(n)\) lies entirely in the column span of the input observation matrix. In a channel equalization context, it means the channel distortion is fully invertible within the filter&amp;rsquo;s tap length.&lt;/p>
&lt;p>\(\xi_{\min}\) is a hard bound on linear estimators. Deviating from \(\mathbf{w}_{\text{opt}}\) by any \(\Delta\mathbf{w}\) adds a penalty of \(\Delta\mathbf{w}^T \mathbf{R}\,\Delta\mathbf{w}\) to the error. Because \(\mathbf{R}\) is positive definite, that penalty is always positive. Any weight vector other than \(\mathbf{w}_{\text{opt}}\) produces strictly higher MSE.&lt;/p>
&lt;p>One more property worth stating explicitly: the Wiener filter is optimal among linear filters under MSE without requiring the input to be Gaussian. If the input and desired signal happen to be jointly Gaussian, the conditional expectation \(E[d(n)|\mathbf{x}(n)]\) is itself linear, and the Wiener filter becomes optimal among &lt;em>all&lt;/em> estimators, linear and nonlinear [2, Ch. 2][5]. For non-Gaussian inputs, nonlinear estimators can potentially do better, but the Wiener filter remains the best you can do with a linear structure.&lt;/p>
&lt;h2 id="connection-to-lms-and-adaptive-filtering">Connection to LMS and adaptive filtering
&lt;/h2>&lt;p>The Wiener-Hopf equation requires \(\mathbf{R}\) and \(\mathbf{p}\) in closed form. In most real systems (equalizers, echo cancellers, noise reduction) you do not have these. The channel changes. The statistics drift. Estimating \(\mathbf{R}\) from finite data and inverting it is both noisy and expensive.&lt;/p>
&lt;p>LMS sidesteps the problem by replacing the expected gradient \(-2\mathbf{p} + 2\mathbf{R}\mathbf{w}\) with the instantaneous gradient \(-2\,e(n)\,\mathbf{x}(n)\), then taking a small step at each sample:&lt;/p>
\[
\mathbf{w}(n+1) = \mathbf{w}(n) + \mu\,e(n)\,\mathbf{x}(n)
\]&lt;p>This is stochastic gradient descent on \(\xi\). The noise in the gradient estimate is the cost of not needing \(\mathbf{R}\) and \(\mathbf{p}\). The step size \(\mu\) controls the trade-off between convergence speed and steady-state misadjustment, and its stability bounds depend on the eigenvalue spread of the same \(\mathbf{R}\) that the Wiener-Hopf equation inverts directly [2, Ch. 5][3].&lt;/p>
&lt;p>The Wiener filter defines the destination. LMS is one way to get there without knowing the terrain. The MMSE is the floor that LMS approaches but does not reach: for any \(\mu > 0\), the steady-state excess MSE is strictly positive. That gap is the price of real-time adaptation.&lt;/p>
&lt;h2 id="lab">Lab
&lt;/h2>&lt;p>The full derivation is implemented in MATLAB, Python, C, and C++ in the companion repository: &lt;a class="link" href="https://github.com/Bevia/MMSE-Wiener-Filter-Lab" target="_blank" rel="noopener"
>MMSE-Wiener-Filter-Lab&lt;/a>.&lt;/p>
&lt;h2 id="references">References
&lt;/h2>&lt;ul>
&lt;li>N. Wiener, &lt;em>Extrapolation, Interpolation, and Smoothing of Stationary Time Series&lt;/em>, MIT Press, 1949.&lt;/li>
&lt;li>S. Haykin, &lt;em>Adaptive Filter Theory&lt;/em>, 5th ed., Pearson, 2014.&lt;/li>
&lt;li>B. Widrow and S. D. Stearns, &lt;em>Adaptive Signal Processing&lt;/em>, Prentice Hall, 1985.&lt;/li>
&lt;li>A. V. Oppenheim and R. W. Schafer, &lt;em>Discrete-Time Signal Processing&lt;/em>, 3rd ed., Pearson, 2010.&lt;/li>
&lt;li>S. M. Kay, &lt;em>Fundamentals of Statistical Signal Processing, Vol. I: Estimation Theory&lt;/em>, Prentice Hall, 1993.&lt;/li>
&lt;/ul></description></item><item><title>Maximum Entropy Inverse Reinforcement Learning: Understanding the Trajectory Formula</title><link>https://corebaseit.com/corebaseit_posts/maximum-entropy-irl-trajectory-formula_rl_part2/</link><pubDate>Thu, 23 Apr 2026 10:00:00 +0100</pubDate><author>contact@corebaseit.com (Vincent Bevia)</author><guid>https://corebaseit.com/corebaseit_posts/maximum-entropy-irl-trajectory-formula_rl_part2/</guid><description>&lt;p>&lt;strong>Inverse reinforcement learning (IRL) asks a different question from classical RL: instead of assuming a reward function and learning a policy, you observe expert behavior and infer what reward would make that behavior look rational.&lt;/strong> One of the cleanest probabilistic formulations is the &lt;strong>maximum entropy&lt;/strong> trajectory model. This post is a practical engineering note on what the formula means, why entropy matters, and where the &lt;strong>Markov decision process (MDP)&lt;/strong> shows up under the hood.&lt;/p>
&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/maximun_entropy.png" alt="Markov Diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;hr>
&lt;h2 id="the-formula">The formula
&lt;/h2>&lt;p>Over candidate trajectories \(T_i\), the model defines:&lt;/p>
$$
P(T_i \mid \mathbf{w}) = \frac{1}{Z(\mathbf{w})} \exp\Bigl( \sum_{(s,a) \in T_i} \mathbf{w} \cdot \boldsymbol{\phi}(s,a) \Bigr)
$$&lt;ul>
&lt;li>\(T_i\) — a complete &lt;strong>trajectory&lt;/strong> (a sequence of state–action pairs).&lt;/li>
&lt;li>\(\mathbf{w}\) — a &lt;strong>weight vector&lt;/strong>; in linear IRL, \(\mathbf{w}\) parameterizes the implied reward \(R(s,a) = \mathbf{w} \cdot \boldsymbol{\phi}(s,a)\).&lt;/li>
&lt;li>\(\boldsymbol{\phi}(s,a)\) — a &lt;strong>feature vector&lt;/strong> for taking action \(a\) in state \(s\) (progress toward a goal, proximity to obstacles, smoothness, etc.).&lt;/li>
&lt;li>\(\mathbf{w} \cdot \boldsymbol{\phi}(s,a)\) — scalar &lt;strong>reward contribution&lt;/strong> for one step.&lt;/li>
&lt;li>\(\sum_{(s,a) \in T_i} \mathbf{w} \cdot \boldsymbol{\phi}(s,a)\) — &lt;strong>trajectory score&lt;/strong> (total reward along the path).&lt;/li>
&lt;li>\(Z(\mathbf{w})\) — the &lt;strong>partition function&lt;/strong>: sum of \(\exp(\text{score})\) over all trajectories so probabilities normalize to one.&lt;/li>
&lt;/ul>
&lt;h3 id="notation-at-a-glance">Notation at a glance
&lt;/h3>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Term&lt;/th>
&lt;th>Meaning&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>\(T_i\)&lt;/td>
&lt;td>One candidate trajectory, path, or behavior sequence&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\mathbf{w}\)&lt;/td>
&lt;td>Learned weights; defines the linear reward in this setup&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\boldsymbol{\phi}(s,a)\)&lt;/td>
&lt;td>Features for \((s,a)\): progress, risk, smoothness, compliance, …&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\mathbf{w} \cdot \boldsymbol{\phi}(s,a)\)&lt;/td>
&lt;td>Scalar reward for one step&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\sum_{(s,a) \in T_i}\)&lt;/td>
&lt;td>Sum of step rewards along the trajectory&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\exp(\cdot)\)&lt;/td>
&lt;td>Turns scores into positive, unnormalized masses&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(Z(\mathbf{w})\)&lt;/td>
&lt;td>Normalizer over trajectories (the hard part in large spaces)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h2 id="intuition-a-softmax-over-trajectories">Intuition: a softmax over trajectories
&lt;/h2>&lt;p>Operationally, the recipe is:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Score&lt;/strong> each trajectory by summing \(\mathbf{w} \cdot \boldsymbol{\phi}(s,a)\) along the path.&lt;/li>
&lt;li>&lt;strong>Exponentiate&lt;/strong> each score.&lt;/li>
&lt;li>&lt;strong>Divide&lt;/strong> by the sum of all exponentiated scores.&lt;/li>
&lt;/ol>
&lt;p>That is a &lt;strong>softmax&lt;/strong> over trajectories: higher-scoring paths get higher probability, but nothing is forced to probability one unless the data and weights make that inevitable.&lt;/p>
&lt;p>That matters for real experts. Demonstrations are rarely perfectly deterministic; several trajectories can be good. Maximum-entropy modeling keeps that &lt;strong>uncertainty&lt;/strong> instead of collapsing everything onto a single “best” path.&lt;/p>
&lt;hr>
&lt;h2 id="irl-mdps-and-feature-matching">IRL, MDPs, and feature matching
&lt;/h2>&lt;p>&lt;strong>Forward RL:&lt;/strong> given dynamics and reward, find a good policy. &lt;strong>IRL:&lt;/strong> given demonstrations, infer a reward (or reward parameters) that rationalizes them.&lt;/p>
&lt;p>In &lt;strong>maximum-entropy IRL&lt;/strong>, one assumes \(R(s,a) = \mathbf{w} \cdot \boldsymbol{\phi}(s,a)\). The trajectory score is the sum of per-step rewards. Expert data are treated as if they were drawn from a distribution where &lt;strong>higher-reward trajectories are exponentially more likely&lt;/strong> — exactly the Boltzmann form above.&lt;/p>
&lt;p>&lt;strong>Estimation goal:&lt;/strong> find \(\mathbf{w}\) such that observed demonstrations are &lt;strong>likely&lt;/strong> under \(P(T \mid \mathbf{w})\). In practice, that means learning what the expert seems to care about — safety, efficiency, smooth motion, rule compliance — &lt;strong>only through the features you encode&lt;/strong>.&lt;/p>
&lt;p>A standard theoretical consequence is &lt;strong>feature matching&lt;/strong> (in expectation): the model’s distribution aligns &lt;strong>expected feature counts&lt;/strong> with those implied by the demonstrations. If experts consistently avoid obstacles and move smoothly, the inferred reward should induce similar statistics. &lt;strong>Feature design is not cosmetic&lt;/strong>; it is the language in which preferences become identifiable.&lt;/p>
&lt;h3 id="where-the-mdp-enters">Where the MDP enters
&lt;/h3>&lt;p>Trajectories \(T_i\) are usually &lt;strong>feasible paths in an environment&lt;/strong>: states, actions, and transitions. In the finite case, that is a &lt;strong>finite MDP&lt;/strong>: discrete states and actions, and transitions \(P(s' \mid s, a)\) constrain which sequences are valid. The formula does not print the transition table, but &lt;strong>candidate trajectories are generated inside that structure&lt;/strong>. When the state space is huge, you cannot enumerate all trajectories; \(Z(\mathbf{w})\) is approximated with &lt;strong>dynamic programming&lt;/strong>, sampling, or other tractable surrogates — that is the central engineering bottleneck.&lt;/p>
&lt;hr>
&lt;h2 id="what-maximum-entropy-means-here">What “maximum entropy” means here
&lt;/h2>&lt;p>&lt;strong>Entropy&lt;/strong> measures how spread out a distribution is. High entropy: mass over many trajectories. Low entropy: mass concentrated on a few.&lt;/p>
&lt;p>&lt;strong>Maximum entropy&lt;/strong> means: among all distributions that satisfy chosen &lt;strong>constraints&lt;/strong> (typically, matching statistics of the demonstrations, especially feature expectations), pick the distribution that is &lt;strong>otherwise least committal&lt;/strong> — it adds no extra assumptions beyond those constraints.&lt;/p>
&lt;p>If several trajectories fit the data, probability should &lt;strong>spread&lt;/strong> across them instead of assigning one path probability one and the rest zero. The &lt;strong>exponential-family&lt;/strong> form is not arbitrary: it arises from maximizing entropy subject to &lt;strong>feature-matching&lt;/strong> constraints. The same structure appears in maximum-entropy IRL, &lt;strong>conditional random fields&lt;/strong>, &lt;strong>Gibbs distributions&lt;/strong>, and &lt;strong>softmax&lt;/strong> policies.&lt;/p>
&lt;hr>
&lt;h2 id="tiny-worked-example-features-and-weights">Tiny worked example (features and weights)
&lt;/h2>&lt;p>Suppose step-level features capture: &lt;strong>progress toward goal&lt;/strong>, &lt;strong>collision / obstacle contact&lt;/strong>, and &lt;strong>smooth motion&lt;/strong>. A weight vector might be \(\mathbf{w} = [2.0,\,-5.0,\,1.0]\): progress is good, collisions are strongly penalized, smoothness is mildly rewarded.&lt;/p>
&lt;ul>
&lt;li>Trajectory &lt;strong>A&lt;/strong> reaches the goal while avoiding obstacles → total score &lt;strong>6&lt;/strong>.&lt;/li>
&lt;li>Trajectory &lt;strong>B&lt;/strong> reaches the goal but clips an obstacle → total score &lt;strong>1&lt;/strong>.&lt;/li>
&lt;/ul>
&lt;p>Because \(\exp(6) \gg \exp(1)\), &lt;strong>A&lt;/strong> gets much higher probability under \(P(T \mid \mathbf{w})\). &lt;strong>B&lt;/strong> is not impossible — only less likely. That is the maximum-entropy mindset: &lt;strong>bias&lt;/strong> toward what explains the expert, &lt;strong>without&lt;/strong> zeroing out plausible alternatives.&lt;/p>
&lt;hr>
&lt;h2 id="python-scores-partition-function-probabilities">Python: scores, partition function, probabilities
&lt;/h2>&lt;p>The snippet below scores a &lt;strong>small finite set&lt;/strong> of candidate trajectories (enumeration is only toy-scale here).&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">import&lt;/span> math
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>w &lt;span style="color:#f92672">=&lt;/span> [&lt;span style="color:#ae81ff">0.8&lt;/span>, &lt;span style="color:#f92672">-&lt;/span>&lt;span style="color:#ae81ff">0.2&lt;/span>]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>T1 &lt;span style="color:#f92672">=&lt;/span> [[&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">0&lt;/span>], [&lt;span style="color:#ae81ff">0&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>], [&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>]]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>T2 &lt;span style="color:#f92672">=&lt;/span> [[&lt;span style="color:#ae81ff">0&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>], [&lt;span style="color:#ae81ff">0&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>], [&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">0&lt;/span>]]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>T3 &lt;span style="color:#f92672">=&lt;/span> [[&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>], [&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">0&lt;/span>]]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>trajectories &lt;span style="color:#f92672">=&lt;/span> [T1, T2, T3]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">def&lt;/span> &lt;span style="color:#a6e22e">dot&lt;/span>(u, v):
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> sum(ui &lt;span style="color:#f92672">*&lt;/span> vi &lt;span style="color:#66d9ef">for&lt;/span> ui, vi &lt;span style="color:#f92672">in&lt;/span> zip(u, v))
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">def&lt;/span> &lt;span style="color:#a6e22e">trajectory_score&lt;/span>(T, w):
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> sum(dot(w, phi) &lt;span style="color:#66d9ef">for&lt;/span> phi &lt;span style="color:#f92672">in&lt;/span> T)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>scores &lt;span style="color:#f92672">=&lt;/span> [trajectory_score(T, w) &lt;span style="color:#66d9ef">for&lt;/span> T &lt;span style="color:#f92672">in&lt;/span> trajectories]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>unnorm &lt;span style="color:#f92672">=&lt;/span> [math&lt;span style="color:#f92672">.&lt;/span>exp(score) &lt;span style="color:#66d9ef">for&lt;/span> score &lt;span style="color:#f92672">in&lt;/span> scores]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Z &lt;span style="color:#f92672">=&lt;/span> sum(unnorm)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>probs &lt;span style="color:#f92672">=&lt;/span> [u &lt;span style="color:#f92672">/&lt;/span> Z &lt;span style="color:#66d9ef">for&lt;/span> u &lt;span style="color:#f92672">in&lt;/span> unnorm]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">for&lt;/span> i, (score, prob) &lt;span style="color:#f92672">in&lt;/span> enumerate(zip(scores, probs), start&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">1&lt;/span>):
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> print(&lt;span style="color:#e6db74">f&lt;/span>&lt;span style="color:#e6db74">&amp;#34;T&lt;/span>&lt;span style="color:#e6db74">{&lt;/span>i&lt;span style="color:#e6db74">}&lt;/span>&lt;span style="color:#e6db74">: score=&lt;/span>&lt;span style="color:#e6db74">{&lt;/span>score&lt;span style="color:#e6db74">:&lt;/span>&lt;span style="color:#e6db74">.3f&lt;/span>&lt;span style="color:#e6db74">}&lt;/span>&lt;span style="color:#e6db74">, P(T&lt;/span>&lt;span style="color:#e6db74">{&lt;/span>i&lt;span style="color:#e6db74">}&lt;/span>&lt;span style="color:#e6db74">|w)=&lt;/span>&lt;span style="color:#e6db74">{&lt;/span>prob&lt;span style="color:#e6db74">:&lt;/span>&lt;span style="color:#e6db74">.3f&lt;/span>&lt;span style="color:#e6db74">}&lt;/span>&lt;span style="color:#e6db74">&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>Each step is a feature vector \(\boldsymbol{\phi}\).&lt;/li>
&lt;li>The trajectory score is \(\sum \mathbf{w} \cdot \boldsymbol{\phi}\).&lt;/li>
&lt;li>\(\exp(\text{score})\) gives an unnormalized weight; &lt;strong>\(Z\)&lt;/strong> sums them; division yields &lt;strong>valid probabilities&lt;/strong>.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="application-sketch-warehouse-navigation">Application sketch: warehouse navigation
&lt;/h2>&lt;p>A mobile robot moves to a packing station while avoiding shelves, slowing near people, and preferring smooth motion. A natural feature vector per \((s,a)\) might include: &lt;strong>moves toward goal&lt;/strong>, &lt;strong>close to obstacle&lt;/strong>, &lt;strong>near human worker&lt;/strong>, &lt;strong>smooth motion&lt;/strong>. Learned \(\mathbf{w}\) encodes implicit priorities from demonstrations (positive weights reward preferred behavior, negative weights penalize risk or inefficiency).&lt;/p>
&lt;p>&lt;strong>Pipeline (conceptual):&lt;/strong>&lt;/p>
&lt;ol>
&lt;li>Collect expert demonstrations (human teleop, planner traces, etc.).&lt;/li>
&lt;li>Represent each trajectory by summing \(\boldsymbol{\phi}(s,a)\) along the path (or equivalently summing \(\mathbf{w}\cdot\boldsymbol{\phi}\) if optimizing \(\mathbf{w}\)).&lt;/li>
&lt;li>Use \(P(T \mid \mathbf{w}) \propto \exp(\sum \mathbf{w}\cdot\boldsymbol{\phi})\) so expert-like paths get higher mass.&lt;/li>
&lt;li>Fit \(\mathbf{w}\) so demonstrated trajectories are likely and &lt;strong>expected features&lt;/strong> match the data.&lt;/li>
&lt;li>Deploy the implied reward for planning in &lt;strong>new&lt;/strong> layouts.&lt;/li>
&lt;/ol>
&lt;p>In a real warehouse, &lt;strong>many&lt;/strong> paths can be safe. Maximum entropy avoids pretending there is a single “correct” route; it learns a reward that ranks paths while &lt;strong>preserving uncertainty&lt;/strong> where data are ambiguous.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Feature (example)&lt;/th>
&lt;th>Typical meaning&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Moves toward goal&lt;/td>
&lt;td>Progress to target&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Close to obstacle&lt;/td>
&lt;td>Penalize risk near shelves or walls&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Near human worker&lt;/td>
&lt;td>Tighter safety margin&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Smooth motion&lt;/td>
&lt;td>Predictable, executable motion&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h2 id="numerical-walkthrough-two-trajectories-two-features">Numerical walkthrough (two trajectories, two features)
&lt;/h2>&lt;p>Let \(\boldsymbol{\phi}(s,a) = [\text{towardGoal}, \text{energyCost}]\) and \(\mathbf{w} = [2,\,-1]\): reward progress toward the goal, penalize energy.&lt;/p>
&lt;p>Two &lt;strong>toy&lt;/strong> three-step trajectories (chosen by hand for readability — in real IRL they would come from demos, simulation, or a planner):&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Trajectory&lt;/th>
&lt;th>Step 1 \(\boldsymbol{\phi}\)&lt;/th>
&lt;th>Step 2 \(\boldsymbol{\phi}\)&lt;/th>
&lt;th>Step 3 \(\boldsymbol{\phi}\)&lt;/th>
&lt;th>Total score \(\sum \mathbf{w}\cdot\boldsymbol{\phi}\)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>\(T_1\)&lt;/td>
&lt;td>\([1,1]\)&lt;/td>
&lt;td>\([1,0]\)&lt;/td>
&lt;td>\([1,1]\)&lt;/td>
&lt;td>&lt;strong>4&lt;/strong>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(T_2\)&lt;/td>
&lt;td>\([1,1]\)&lt;/td>
&lt;td>\([0,1]\)&lt;/td>
&lt;td>\([1,1]\)&lt;/td>
&lt;td>&lt;strong>1&lt;/strong>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Step scores for \(T_1\): \(1,\,2,\,1\) → sum &lt;strong>4&lt;/strong>. For \(T_2\): \(1,\,-1,\,1\) → sum &lt;strong>1&lt;/strong>.&lt;/p>
&lt;p>Unnormalized weights: \(\exp(4) \approx 54.60\), \(\exp(1) \approx 2.72\). So \(Z(\mathbf{w}) \approx 57.32\), and&lt;/p>
$$
P(T_1 \mid \mathbf{w}) \approx 0.953,\qquad P(T_2 \mid \mathbf{w}) \approx 0.047.
$$&lt;p>The lower-scoring trajectory is unlikely but &lt;strong>not zero&lt;/strong> — by design.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">import&lt;/span> math
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>w &lt;span style="color:#f92672">=&lt;/span> [&lt;span style="color:#ae81ff">2&lt;/span>, &lt;span style="color:#f92672">-&lt;/span>&lt;span style="color:#ae81ff">1&lt;/span>]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>T1 &lt;span style="color:#f92672">=&lt;/span> [[&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>], [&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">0&lt;/span>], [&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>]]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>T2 &lt;span style="color:#f92672">=&lt;/span> [[&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>], [&lt;span style="color:#ae81ff">0&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>], [&lt;span style="color:#ae81ff">1&lt;/span>, &lt;span style="color:#ae81ff">1&lt;/span>]]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">def&lt;/span> &lt;span style="color:#a6e22e">dot&lt;/span>(a, b):
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> sum(x &lt;span style="color:#f92672">*&lt;/span> y &lt;span style="color:#66d9ef">for&lt;/span> x, y &lt;span style="color:#f92672">in&lt;/span> zip(a, b))
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">def&lt;/span> &lt;span style="color:#a6e22e">score&lt;/span>(T, w):
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> sum(dot(w, phi) &lt;span style="color:#66d9ef">for&lt;/span> phi &lt;span style="color:#f92672">in&lt;/span> T)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>s1, s2 &lt;span style="color:#f92672">=&lt;/span> score(T1, w), score(T2, w)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>e1, e2 &lt;span style="color:#f92672">=&lt;/span> math&lt;span style="color:#f92672">.&lt;/span>exp(s1), math&lt;span style="color:#f92672">.&lt;/span>exp(s2)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Z &lt;span style="color:#f92672">=&lt;/span> e1 &lt;span style="color:#f92672">+&lt;/span> e2
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>print(round(e1 &lt;span style="color:#f92672">/&lt;/span> Z, &lt;span style="color:#ae81ff">3&lt;/span>), round(e2 &lt;span style="color:#f92672">/&lt;/span> Z, &lt;span style="color:#ae81ff">3&lt;/span>)) &lt;span style="color:#75715e"># 0.953, 0.047&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h2 id="engineering-takeaways">Engineering takeaways
&lt;/h2>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Takeaway&lt;/th>
&lt;th>Why it matters&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Feature quality dominates&lt;/strong>&lt;/td>
&lt;td>Weak or wrong features → weak or misleading inferred rewards.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Maximum entropy reduces brittleness&lt;/strong>&lt;/td>
&lt;td>Multiple near-optimal behaviors can coexist instead of a forced deterministic story.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>\(Z(\mathbf{w})\) is the hard part&lt;/strong>&lt;/td>
&lt;td>Exact enumeration is intractable in large MDPs; implementations use DP, sampling, or approximations.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>IRL targets objectives, not only actions&lt;/strong>&lt;/td>
&lt;td>A learned reward often &lt;strong>generalizes&lt;/strong> to new situations better than pure behavior cloning — when the model is right.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h2 id="where-else-this-pattern-appears">Where else this pattern appears
&lt;/h2>&lt;p>The same &lt;strong>score then normalize&lt;/strong> structure shows up wherever you need a &lt;strong>distribution over structured sequences&lt;/strong>: imitation learning under ambiguity, trajectory prediction in driving, user / gameplay sequence modeling, and &lt;strong>structured prediction&lt;/strong> in ML (exponential models over outputs). The unifying pattern: meaningful features, learned weights, trajectory scores, and a normalized probability over candidates.&lt;/p>
&lt;hr>
&lt;h2 id="bottom-line">Bottom line
&lt;/h2>&lt;p>The maximum-entropy trajectory model gives a precise way to say: &lt;strong>expert-like trajectories should be more probable when they score higher under a hidden linear reward&lt;/strong>, while the model &lt;strong>stays honest about uncertainty&lt;/strong> when the data do not support a sharper conclusion.&lt;/p>
&lt;p>For builders: &lt;strong>define features carefully&lt;/strong>, &lt;strong>infer \(\mathbf{w}\)&lt;/strong> so demonstrations and feature statistics are explained, and use the &lt;strong>maximum-entropy&lt;/strong> distribution to avoid overfitting a single story to limited data.&lt;/p>
&lt;hr>
&lt;h2 id="references">References
&lt;/h2>&lt;ul>
&lt;li>Ziebart, B. D., Maas, A. L., Bagnell, J. A., &amp;amp; Dey, A. K. &amp;ldquo;Maximum entropy inverse reinforcement learning.&amp;rdquo; &lt;em>AAAI&lt;/em>, 2008.&lt;/li>
&lt;li>Ng, A. Y., &amp;amp; Russell, S. &amp;ldquo;Algorithms for inverse reinforcement learning.&amp;rdquo; &lt;em>ICML&lt;/em>, 2000.&lt;/li>
&lt;li>Sutton, R. S., &amp;amp; Barto, A. G. &lt;em>Reinforcement Learning: An Introduction&lt;/em> (2nd ed.). MIT Press, 2018. &lt;a class="link" href="http://incompleteideas.net/book/the-book-2nd.html" target="_blank" rel="noopener"
>incompleteideas.net&lt;/a>&lt;/li>
&lt;li>Puterman, M. L. &lt;em>Markov Decision Processes: Discrete Stochastic Dynamic Programming&lt;/em>. Wiley, 1994.&lt;/li>
&lt;/ul>
&lt;h2 id="further-reading">Further reading
&lt;/h2>&lt;ul>
&lt;li>&lt;em>Markov Decision Processes: The Mathematical Foundation of Reinforcement Learning&lt;/em> — companion draft on corebaseit covering the MDP tuple, Bellman structure, and RLHF; link it here once the post is live under &lt;code>/posts/&lt;/code>.&lt;/li>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/reasoning-models-deep-reasoning-llms/" >Reasoning Models and Deep Reasoning in LLMs&lt;/a> — sequential structure and verification&lt;/li>
&lt;/ul></description></item><item><title>Markov Decision Processes: The Mathematical Foundation of Reinforcement Learning</title><link>https://corebaseit.com/corebaseit_posts/markov-decision-processes-rlhf-and-agentic-ai_rl_part1/</link><pubDate>Wed, 22 Apr 2026 10:00:00 +0100</pubDate><author>contact@corebaseit.com (Vincent Bevia)</author><guid>https://corebaseit.com/corebaseit_posts/markov-decision-processes-rlhf-and-agentic-ai_rl_part1/</guid><description>&lt;p>&lt;strong>The Markov Decision Process (MDP) is the standard formal object for sequential decision-making under uncertainty.&lt;/strong> It separates &lt;em>problem definition&lt;/em> — states, actions, how the world evolves, what you want to optimize — from &lt;em>solution methods&lt;/em> (value iteration, Q-learning, policy gradients, and their deep variants). That separation is why the same vocabulary shows up across robotics, games, RLHF-tuned language models, and tool-using agents.&lt;/p>
&lt;p>I keep coming back to this when people treat LLMs, RL, and “agents” as unrelated product categories. Implementations differ, but &lt;strong>state, action, reward, policy, and value&lt;/strong> recur for a reason: a large class of systems is still answering “what should I do next to maximize something, given what I know now?”&lt;/p>
&lt;p>This post builds the MDP core with enough precision to be useful — Markov property, the five-tuple, policies and Bellman equations, how classical methods differ, and &lt;strong>inverse reinforcement learning&lt;/strong> — then connects it to &lt;strong>LLMs, RLHF, DPO, and agentic stacks&lt;/strong>. It is not universal: many deployed models are one-shot predictors or rankers with no explicit sequential RL loop. Where the MDP applies, the mapping is operational, not metaphorical.&lt;/p>
&lt;hr>
&lt;h2 id="the-markov-property-and-the-five-tuple">The Markov Property and the Five-Tuple
&lt;/h2>&lt;p>At the center is the &lt;strong>Markov property&lt;/strong> (memorylessness): the next state depends on the recent past only through the current state and action:&lt;/p>
$$
P(s_{t+1} \mid s_t, a_t, s_{t-1}, a_{t-1}, \ldots) = P(s_{t+1} \mid s_t, a_t).
$$&lt;p>So the &lt;strong>state&lt;/strong> must summarize whatever matters for the future; if something important is missing from \(s_t\), the model is misspecified and you are really in a &lt;strong>POMDP&lt;/strong> (partial observability) — more on that when we get to context windows.&lt;/p>
&lt;p>An MDP is usually written as \((\mathcal{S}, \mathcal{A}, P, R, \gamma)\):&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Symbol&lt;/th>
&lt;th>Component&lt;/th>
&lt;th>Role&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>\(\mathcal{S}\)&lt;/td>
&lt;td>State space&lt;/td>
&lt;td>Configurations the agent can be in&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\mathcal{A}\)&lt;/td>
&lt;td>Action space&lt;/td>
&lt;td>Choices (discrete or continuous)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(P(s' \mid s, a)\)&lt;/td>
&lt;td>Transition law&lt;/td>
&lt;td>Dynamics: where you land after \((s,a)\)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(R\)&lt;/td>
&lt;td>Reward&lt;/td>
&lt;td>Immediate signal, often \(R(s,a)\) or \(R(s,a,s')\)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\gamma\)&lt;/td>
&lt;td>Discount&lt;/td>
&lt;td>\(\gamma \in [0,1]\) weights future reward vs. now&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The &lt;strong>objective&lt;/strong> is a policy \(\pi\) that maximizes &lt;strong>expected discounted return&lt;/strong> \( \mathbb{E}\big[\sum_t \gamma^t R_t\big] \). An &lt;strong>optimal policy&lt;/strong> \(\pi^*\) achieves the best achievable value from each state (under the usual regularity conditions).&lt;/p>
&lt;p>&lt;strong>State and action design&lt;/strong> is an engineering problem: too little information in \(s\) and the Markov assumption is false; too much and you fight the &lt;strong>curse of dimensionality&lt;/strong>. &lt;strong>Actions&lt;/strong> drive algorithm choice — small discrete spaces admit tabular methods; huge discrete vocabularies (e.g. tens of thousands of tokens) or continuous control push you toward &lt;strong>function approximation&lt;/strong> and &lt;strong>deep RL&lt;/strong>.&lt;/p>
&lt;p>&lt;strong>\(\gamma\)&lt;/strong> sets the effective horizon: \(\gamma = 0\) is myopic (only immediate reward); \(\gamma\) close to \(1\) cares about the long run (in infinite-horizon settings, \(\gamma &lt; 1\) keeps returns bounded). Pure \(\gamma = 1\) is typical for &lt;strong>finite-horizon&lt;/strong> episodic problems without discounting.&lt;/p>
&lt;p>&lt;strong>Rewards&lt;/strong> are the lever everyone feels in production: misspecify them and you get &lt;strong>reward hacking&lt;/strong> — policies that maximize the signal you wrote, not the outcome you wanted. That story continues unchanged in RLHF.&lt;/p>
&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/MarkovDiagram.png" alt="Markov Diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;hr>
&lt;h2 id="policies-value-functions-and-the-bellman-equation">Policies, Value Functions, and the Bellman Equation
&lt;/h2>&lt;p>A &lt;strong>policy&lt;/strong> \(\pi\) maps states to actions (deterministic: \(a = \pi(s)\)) or distributions (stochastic: \(\pi(a \mid s)\)). To rank policies, RL uses &lt;strong>value functions&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>State value&lt;/strong> \(V^\pi(s)\): expected return starting in \(s\) and following \(\pi\).&lt;/li>
&lt;li>&lt;strong>Action-value&lt;/strong> \(Q^\pi(s,a)\): expected return from taking \(a\) in \(s\), then following \(\pi\).&lt;/li>
&lt;/ul>
&lt;p>They satisfy &lt;strong>Bellman consistency&lt;/strong>. For example, for \(V^\pi\):&lt;/p>
$$
V^\pi(s) = \sum_{a} \pi(a \mid s) \sum_{s'} P(s' \mid s,a) \big[ R(s,a,s') + \gamma V^\pi(s') \big].
$$&lt;p>&lt;strong>Optimal&lt;/strong> values \(V^*\), \(Q^*\) obey the &lt;strong>Bellman optimality&lt;/strong> recursion and are the target of &lt;strong>dynamic programming&lt;/strong> when \(P\) and \(R\) are known. When the model is unknown, you fall back to &lt;strong>sample-based&lt;/strong> methods.&lt;/p>
&lt;hr>
&lt;h2 id="solution-methods-high-level">Solution Methods (High Level)
&lt;/h2>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Family&lt;/th>
&lt;th>Idea&lt;/th>
&lt;th>When it fits&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Dynamic programming&lt;/strong>&lt;/td>
&lt;td>Value / policy iteration using \(P\)&lt;/td>
&lt;td>Model known, moderate \(\|\mathcal{S}\|\)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Monte Carlo&lt;/strong>&lt;/td>
&lt;td>Return estimates from full episodes&lt;/td>
&lt;td>Episodic, no step-by-step model&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Temporal difference&lt;/strong>&lt;/td>
&lt;td>Bootstrap from current estimates (e.g. Q-learning, SARSA)&lt;/td>
&lt;td>Online learning, unknown model&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Deep RL&lt;/strong>&lt;/td>
&lt;td>Neural nets for \(Q\) or \(\pi\) (DQN, PPO, …)&lt;/td>
&lt;td>Large or continuous state spaces&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Deep RL does not change the MDP; it changes how you represent and optimize &lt;strong>value&lt;/strong> and &lt;strong>policy&lt;/strong> when tabulation is impossible — including settings as large as language.&lt;/p>
&lt;hr>
&lt;h2 id="inverse-reinforcement-learning">Inverse Reinforcement Learning
&lt;/h2>&lt;p>&lt;strong>Forward RL:&lt;/strong> given \(R\) (and dynamics), find a good \(\pi\). &lt;strong>Inverse RL (IRL)&lt;/strong> flips the problem: given &lt;strong>demonstrations&lt;/strong> from a (near-)expert, infer an \(R\) that makes those trajectories rational. That matters when rewards are hard to write down but behavior is easy to show — classic examples include imitation-style control and parsing “what the human cared about” from what they did.&lt;/p>
&lt;p>&lt;strong>Maximum-entropy IRL&lt;/strong> (Ziebart et al.) makes the expert stochastic but high reward: trajectories are scored by accumulated reward features, and probability over trajectories often takes a Boltzmann form, with a &lt;strong>partition function&lt;/strong> coupling normalization to the underlying MDP structure. The details are involved; the takeaway for this post is that &lt;strong>IRL is still built on the same sequential decision formalism&lt;/strong> — you are inferring preferences compatible with observed paths, not escaping the MDP language.&lt;/p>
&lt;hr>
&lt;h2 id="where-the-markov-assumption-meets-llms">Where the Markov Assumption Meets LLMs
&lt;/h2>&lt;p>In &lt;strong>autoregressive generation&lt;/strong>, a standard idealization is: &lt;strong>state&lt;/strong> = prompt plus all generated tokens so far; &lt;strong>action&lt;/strong> = next token; &lt;strong>transition&lt;/strong> = append token (deterministic at the string level); &lt;strong>policy&lt;/strong> = conditional distribution from the model. Then the next distribution depends only on the prefix — &lt;strong>Markov in that state representation&lt;/strong>.&lt;/p>
&lt;p>The usual engineering gap: &lt;strong>true&lt;/strong> conversational or task state may live outside the window or never be observed. That is &lt;strong>partial observability&lt;/strong> again (POMDP / belief-state view). “Lost context” is often &lt;strong>finite window&lt;/strong> or &lt;strong>wrong state summary&lt;/strong>, not a random tone failure — which is why &lt;strong>memory, retrieval, and tool traces&lt;/strong> are architecture, not cosmetics.&lt;/p>
&lt;hr>
&lt;h2 id="rlhf-dpo-and-the-same-sequential-picture">RLHF, DPO, and the Same Sequential Picture
&lt;/h2>&lt;p>&lt;strong>RLHF&lt;/strong> (InstructGPT-style): the LM is a &lt;strong>policy&lt;/strong> over tokens; a &lt;strong>reward model&lt;/strong> from human preferences scores completions; optimization (often &lt;strong>PPO-class&lt;/strong> in the original stack) increases reward while a &lt;strong>KL penalty&lt;/strong> to a reference policy limits drift. Mapping:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>MDP role&lt;/th>
&lt;th>Typical RLHF instantiation&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>State&lt;/td>
&lt;td>Prompt + generated prefix&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Action&lt;/td>
&lt;td>Next token (or chunk)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Transition&lt;/td>
&lt;td>Append; dynamics deterministic given action choice&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Reward&lt;/td>
&lt;td>Learned preference score (minus KL / auxiliary terms)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Framed this way, alignment pain is largely &lt;strong>reward specification&lt;/strong> and &lt;strong>optimization under misspecified proxy rewards&lt;/strong> — the same failure mode family as classical reward hacking. OpenAI’s &lt;strong>GPT-4o sycophancy&lt;/strong> rollback (April 2025) is a concrete example when short-term preference signals diverge from what you want long term. See also &lt;a class="link" href="https://corebaseit.com/posts/ai-sycophancy/" >AI Sycophancy&lt;/a> here.&lt;/p>
&lt;p>&lt;strong>DPO&lt;/strong> (Direct Preference Optimization) and related methods &lt;strong>avoid an explicit online RL loop&lt;/strong> by optimizing from pairwise preferences in a way derived from the RLHF objective — still &lt;strong>preference-driven alignment&lt;/strong>, but not “PPO on tokens” in implementation. The MDP is still the right mental model for &lt;em>what&lt;/em> is being aligned (sequential decisions under a goal), even when the &lt;em>optimizer&lt;/em> is not vanilla policy gradients.&lt;/p>
&lt;hr>
&lt;h2 id="a-practical-decision-landscape-not-five-silos">A Practical Decision Landscape (Not Five Silos)
&lt;/h2>&lt;p>The field is messier than any chart, but this is a useful &lt;strong>lens&lt;/strong> for choosing tooling:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Situation&lt;/th>
&lt;th>Common approach&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Known reward, safe exploration&lt;/td>
&lt;td>Forward RL (e.g. PPO, Q-learning variants)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Expert demos, unclear reward&lt;/td>
&lt;td>IRL / imitation / inverse-optimal-control style methods&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Broad open-ended language capability&lt;/td>
&lt;td>Pretrained LM (supervised / next-token objective)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Align to human taste or policy&lt;/td>
&lt;td>RLHF, DPO-class preference training, or hybrids&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Multi-step tools + retrieval + planning&lt;/td>
&lt;td>Agentic systems (often LM policy + search / ReAct-style loops)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;strong>Agentic systems&lt;/strong> stack &lt;strong>LLMs&lt;/strong> (policy / world-model substrate), &lt;strong>search or tree exploration&lt;/strong>, &lt;strong>RAG&lt;/strong> (state enrichment), and &lt;strong>tools&lt;/strong> (expanded actions). Under the hood it is still: &lt;strong>maintain state, choose actions, observe outcomes, repeat&lt;/strong> — with stochasticity from both the model and the environment.&lt;/p>
&lt;hr>
&lt;h2 id="the-engineering-takeaway">The Engineering Takeaway
&lt;/h2>&lt;p>You do not need to re-derive Bellman on a whiteboard every sprint. You &lt;strong>do&lt;/strong> need to:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Separate problem definition from algorithms&lt;/strong> — clarify \(\mathcal{S}, \mathcal{A}, R\) before debating PPO vs. DPO vs. prompts.&lt;/li>
&lt;li>&lt;strong>Treat alignment bugs&lt;/strong> as &lt;strong>reward–policy interaction&lt;/strong>, not vague “personality.”&lt;/li>
&lt;li>&lt;strong>Design memory and retrieval&lt;/strong> as &lt;strong>state construction&lt;/strong> when Markov fails.&lt;/li>
&lt;li>&lt;strong>Ask what each agent demo actually optimizes&lt;/strong> — implicit reward, success predicate, or human-in-the-loop only.&lt;/li>
&lt;/ul>
&lt;p>The MDP is not a graduate-school ornament. It is the backbone that makes much of &lt;strong>RL debuggable&lt;/strong> and much of &lt;strong>sequential AI&lt;/strong> legible — whether or not your README says “Markov.”&lt;/p>
&lt;hr>
&lt;h2 id="references">References
&lt;/h2>&lt;ul>
&lt;li>Bellman, R. &lt;em>Dynamic Programming&lt;/em>. Princeton University Press, 1957.&lt;/li>
&lt;li>Puterman, M. L. &lt;em>Markov Decision Processes: Discrete Stochastic Dynamic Programming&lt;/em>. Wiley, 1994.&lt;/li>
&lt;li>Sutton, R. S., &amp;amp; Barto, A. G. &lt;em>Reinforcement Learning: An Introduction&lt;/em> (2nd ed.). MIT Press, 2018. &lt;a class="link" href="http://incompleteideas.net/book/the-book-2nd.html" target="_blank" rel="noopener"
>incompleteideas.net&lt;/a>&lt;/li>
&lt;li>Ng, A. Y., &amp;amp; Russell, S. &amp;ldquo;Algorithms for inverse reinforcement learning.&amp;rdquo; &lt;em>ICML&lt;/em>, 2000.&lt;/li>
&lt;li>Ziebart, B. D., Maas, A. L., Bagnell, J. A., &amp;amp; Dey, A. K. &amp;ldquo;Maximum entropy inverse reinforcement learning.&amp;rdquo; &lt;em>AAAI&lt;/em>, 2008.&lt;/li>
&lt;li>Ouyang, L. et al. &amp;ldquo;Training language models to follow instructions with human feedback.&amp;rdquo; &lt;em>NeurIPS&lt;/em>, 2022. &lt;a class="link" href="https://arxiv.org/abs/2203.02155" target="_blank" rel="noopener"
>arxiv.org/abs/2203.02155&lt;/a>&lt;/li>
&lt;li>Schulman, J. et al. &amp;ldquo;Proximal Policy Optimization Algorithms.&amp;rdquo; 2017. &lt;a class="link" href="https://arxiv.org/abs/1707.06347" target="_blank" rel="noopener"
>arxiv.org/abs/1707.06347&lt;/a>&lt;/li>
&lt;li>Rafailov, R. et al. &amp;ldquo;Direct Preference Optimization: Your Language Model is Secretly a Reward Model.&amp;rdquo; &lt;em>NeurIPS&lt;/em>, 2023. &lt;a class="link" href="https://arxiv.org/abs/2305.18290" target="_blank" rel="noopener"
>arxiv.org/abs/2305.18290&lt;/a>&lt;/li>
&lt;li>Yao, S. et al. &amp;ldquo;ReAct: Synergizing Reasoning and Acting in Language Models.&amp;rdquo; &lt;em>ICLR&lt;/em>, 2023. &lt;a class="link" href="https://arxiv.org/abs/2210.03629" target="_blank" rel="noopener"
>arxiv.org/abs/2210.03629&lt;/a>&lt;/li>
&lt;li>OpenAI. &amp;ldquo;Sycophancy in GPT-4o: What happened and what we&amp;rsquo;re doing about it.&amp;rdquo; April 2025. &lt;a class="link" href="https://openai.com/index/sycophancy-in-gpt-4o/" target="_blank" rel="noopener"
>openai.com&lt;/a>&lt;/li>
&lt;li>Kaelbling, L. P., Littman, M. L., &amp;amp; Cassandra, A. R. &amp;ldquo;Planning and acting in partially observable stochastic domains.&amp;rdquo; &lt;em>Artificial Intelligence&lt;/em>, 101(1–2), 99–134, 1998.&lt;/li>
&lt;/ul>
&lt;h2 id="further-reading">Further reading
&lt;/h2>&lt;ul>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/ai-sycophancy/" >AI Sycophancy: Your Model Is Trained to Please You, Not to Be Right&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/stochastic-entropy-ai/" >Stochastic, Entropy &amp;amp; AI&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/reasoning-models-deep-reasoning-llms/" >Reasoning Models and Deep Reasoning in LLMs&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>SNR: the number that decides whether a signal survives</title><link>https://corebaseit.com/corebaseit_posts/snr-qpsk/</link><pubDate>Thu, 16 Apr 2026 14:00:00 +0200</pubDate><author>contact@corebaseit.com (Vincent Bevia)</author><guid>https://corebaseit.com/corebaseit_posts/snr-qpsk/</guid><description>&lt;p>Every communication system starts with the same goal: move a signal from one place to another and recover its meaning at the far end. In practice the signal passes through copper, air, fiber, antennas, amplifiers, filters, and ADCs. At each stage it picks up thermal noise, interference, quantization error, phase noise, and distortion.&lt;/p>
&lt;p>By the time the waveform reaches the receiver, the question is not whether something arrived. The question is whether the useful signal is strong enough relative to the noise for the receiver to decide what was sent. That ratio is signal-to-noise ratio (SNR).&lt;/p>
&lt;p align="center">
&lt;img src="https://corebaseit.com/diagrams/snr-qpsk-qam.png" alt="SNR overview: signal plus noise at the receiver, SNR in dB, QPSK constellation spreading at high/medium/low SNR, BPSK/QPSK versus 16-QAM and 64-QAM noise margins, related metrics (SINR, EVM, BER, Eb/N0), and Shannon capacity C = B log2(1 + SNR)" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>The diagram above ties the pieces together: SNR as a power ratio, what falling SNR does to a QPSK constellation, why higher-order QAM needs more margin, and where Shannon capacity sets the ceiling.&lt;/p>
&lt;h2 id="what-snr-measures">What SNR measures
&lt;/h2>&lt;p>SNR compares signal power to noise power:&lt;/p>
$$
\mathrm{SNR} = \frac{P_s}{P_n}
$$&lt;p>When \(P_s \gg P_n\), symbol decisions are reliable. When the two powers are comparable, the receiver is guessing. When noise dominates, the message is buried.&lt;/p>
&lt;p>SNR is therefore both a measurement and a statement about decision confidence. Communication receivers are, at bottom, machines that infer which symbol or bit was transmitted from a noisy observation.&lt;/p>
&lt;h2 id="why-engineers-use-decibels">Why engineers use decibels
&lt;/h2>&lt;p>Power ratios in radio links span enormous dynamic range. Expressing SNR in decibels keeps the arithmetic manageable:&lt;/p>
$$
\mathrm{SNR}_{\mathrm{dB}} = 10 \log_{10}\left(\frac{P_s}{P_n}\right)
$$&lt;p>Each 10 dB step is a tenfold change in power ratio:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: right">Linear SNR&lt;/th>
&lt;th style="text-align: right">SNR (dB)&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: right">10&lt;/td>
&lt;td style="text-align: right">10&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: right">100&lt;/td>
&lt;td style="text-align: right">20&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: right">1,000&lt;/td>
&lt;td style="text-align: right">30&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Link budgets, antenna gains, cable losses, and amplifier noise figures are almost always handled in dB for this reason. The underlying idea stays simple: higher SNR means the signal stands farther above the noise floor.&lt;/p>
&lt;h2 id="the-received-signal-and-the-qpsk-picture">The received signal and the QPSK picture
&lt;/h2>&lt;p>A simplified continuous-time model of what the receiver sees is:&lt;/p>
$$
r(t) = s(t) + n(t)
$$&lt;p>The receiver must map each observation \(r(t)\) (or its sampled form) to the most likely transmitted symbol. Small noise keeps the sample near the correct decision region. Large noise pushes it toward a neighbor. That is where bit errors start.&lt;/p>
&lt;p align="center">
&lt;img src="https://corebaseit.com/diagrams/QPSK-constellation.png" alt="QPSK constellation in the I/Q plane: four symbol points at 45-degree phases, decision boundaries shown as dashed lines dividing the plane into four regions" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>QPSK maps two bits to one of four phases in the I/Q plane. At high SNR, received points cluster tightly around the ideal corners. As SNR falls, the clouds spread. Points cross the I/Q axes that separate symbols, and the demodulator starts flipping bits. The symbol energy is still present; the evidence for which symbol it was is not.&lt;/p>
&lt;p>&lt;strong>Confirmed:&lt;/strong> Constellation spreading with falling SNR is the standard AWGN intuition for square QAM and PSK families.&lt;/p>
&lt;p>&lt;strong>Nuance:&lt;/strong> Real channels add fading, frequency offset, and ISI. Constellation diagrams then show rotation, elliptical spreading, or smeared trajectories — not just larger circular clouds. SNR alone does not fully describe those impairments.&lt;/p>
&lt;h2 id="snr-and-data-rate">SNR and data rate
&lt;/h2>&lt;p>SNR also limits how aggressively a link can modulate.&lt;/p>
&lt;p>BPSK and QPSK place constellation points far apart relative to bits per symbol. They tolerate lower SNR. Higher-order formats — 16-QAM, 64-QAM, 256-QAM — pack more bits into the same bandwidth by moving points closer together. Spectral efficiency rises. Noise margin falls.&lt;/p>
&lt;p>That trade-off shows up in adaptive modulation and coding (AMC) in Wi-Fi, LTE, and 5G: when measured SNR (or SINR) is high, the link selects a higher-order modulation and a stronger code rate; when it drops, the stack retreats to a robust mode. That fallback is not waste. It is the system staying inside a BER or BLER target.&lt;/p>
&lt;h2 id="connection-to-shannon-capacity">Connection to Shannon capacity
&lt;/h2>&lt;p>SNR enters Shannon&amp;rsquo;s capacity formula for an AWGN channel with bandwidth \(B\):&lt;/p>
$$
C = B \log_2(1 + \mathrm{SNR})
$$&lt;p>Here \(\mathrm{SNR}\) is a &lt;strong>linear&lt;/strong> power ratio, not a dB value. Bandwidth and SNR both lift capacity, but the log term means returns diminish: doubling transmit power does not double capacity. At high SNR, capacity grows roughly as \(\log_2(\mathrm{SNR})\).&lt;/p>
&lt;p>&lt;strong>Confirmed:&lt;/strong> Shannon&amp;rsquo;s bound sets a theoretical ceiling for reliable rate on a noisy channel [1][2].&lt;/p>
&lt;p>&lt;strong>Interpretation:&lt;/strong> Pushing more bits per second through a fixed band requires more SNR, more bandwidth, stronger coding gain, or some combination. There is no free margin once you are near the bound.&lt;/p>
&lt;p>In deployed systems, raising transmit power is only one lever — and often not the best. Regulatory EIRP limits, battery drain, PA nonlinearity, and co-channel interference all cap how far &amp;ldquo;turn it up&amp;rdquo; can go. Filtering, FEC, MIMO, equalization, and better channel estimation usually share the workload with power.&lt;/p>
&lt;h2 id="not-every-snr-is-the-same-number">Not every &amp;ldquo;SNR&amp;rdquo; is the same number
&lt;/h2>&lt;p>SNR is quoted at many points in a receiver chain:&lt;/p>
&lt;ul>
&lt;li>At the antenna port&lt;/li>
&lt;li>After the LNA&lt;/li>
&lt;li>After channel filtering&lt;/li>
&lt;li>At the ADC&lt;/li>
&lt;li>After digital gain and correction&lt;/li>
&lt;/ul>
&lt;p>Related metrics answer slightly different questions:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Metric&lt;/th>
&lt;th>What it emphasizes&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>\(\mathrm{SINR}\)&lt;/td>
&lt;td>Signal vs. noise &lt;strong>plus interference&lt;/strong>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\mathrm{EVM}\)&lt;/td>
&lt;td>How far received symbols deviate from ideal constellation points&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(\mathrm{BER}\) / \(\mathrm{PER}\)&lt;/td>
&lt;td>End-to-end error rate after demodulation and decoding&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>\(E_b/N_0\)&lt;/td>
&lt;td>Bit energy relative to noise spectral density \(N_0\)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>\(E_b/N_0\) is the usual figure for comparing modulation and coding schemes on an AWGN reference channel. It ties to SNR through data rate and bandwidth; they are not interchangeable without stating assumptions.&lt;/p>
&lt;p>A headline SNR can look acceptable while the link still fails — for example, when phase noise rotates the constellation, timing error shifts samples, co-channel interference raises the effective noise floor, or channel-estimation error smears the reference. EVM, BER, and SINR often localize the failure better than a single RF SNR number.&lt;/p>
&lt;h2 id="what-falling-snr-looks-like-in-practice">What falling SNR looks like in practice
&lt;/h2>&lt;p>On a QPSK link, high SNR gives four separated clusters and negligible errors. Medium SNR widens the clusters; most symbols still decode, but edge cases near boundaries fail. Low SNR produces overlapping clouds: the demodulator runs, yet BER climbs, packets retry, and throughput collapses. To the user it feels like a slow connection. To the receiver it is a maximum-likelihood decision with weak evidence.&lt;/p>
&lt;p>The same pattern appears across domains — Wi-Fi rate adaptation, cellular handover margins, satellite link closures in rain fade, optical OSNR limits, and ADC dynamic range before quantization noise dominates.&lt;/p>
&lt;h2 id="references">References
&lt;/h2>&lt;ol>
&lt;li>
&lt;p>C. E. Shannon, &amp;ldquo;Communication in the presence of noise,&amp;rdquo; &lt;em>Proceedings of the IRE&lt;/em>, vol. 37, no. 1, pp. 10–21, Jan. 1949.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>J. G. Proakis and M. Salehi, &lt;em>Digital Communications&lt;/em>, 5th ed. McGraw-Hill, 2008. (SNR, modulation, and AWGN channel performance.)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>B. Sklar, &lt;em>Digital Communications: Fundamentals and Applications&lt;/em>, 2nd ed. Prentice Hall, 2001. (Constellation diagrams, \(E_b/N_0\), and link budgets.)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>D. Tse and P. Viswanath, &lt;em>Fundamentals of Wireless Communication&lt;/em>. Cambridge University Press, 2005. (SINR, fading, and adaptive modulation.)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>R. G. Lyons, &lt;em>Understanding Digital Signal Processing&lt;/em>, 3rd ed. Pearson, 2011. (SNR in sampled and quantized systems.)&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="further-reading">Further reading
&lt;/h2>&lt;ul>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/nyquist-is-not-shannon/" >Nyquist is not Shannon: why more samples does not mean more information&lt;/a> — sampling vs. channel capacity&lt;/li>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/why-your-internet-has-speed-limit/" >Why your internet has a speed limit&lt;/a> — thermal noise and the physical noise floor&lt;/li>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/mmse-wiener-filter-derivation/" >Deriving MMSE: what the Wiener filter actually minimizes&lt;/a> — optimal linear estimation under noise&lt;/li>
&lt;/ul></description></item><item><title>I Spent Years on Adaptive Filters. I Was Already Training Neural Networks.</title><link>https://corebaseit.com/corebaseit_posts_in_review/digital-comm/lms/lms-adaptive-filters-and-neural-network-training/</link><pubDate>Tue, 14 Apr 2026 10:00:00 +0100</pubDate><author>contact@corebaseit.com (Vincent Bevia)</author><guid>https://corebaseit.com/corebaseit_posts_in_review/digital-comm/lms/lms-adaptive-filters-and-neural-network-training/</guid><description>&lt;p>&lt;strong>I spent years implementing LMS-based equalizers and echo cancellers in telecommunications. Only later did I fully appreciate what I had been doing mathematically: the same family of update rules that powers neural network training today.&lt;/strong>&lt;/p>
&lt;p>Not as a loose analogy — as the same structure of optimization. Widrow and Hoff formalized the Least Mean Squares (LMS) algorithm in 1960 for the Adaline. Rumelhart, Hinton, and Williams scaled related ideas through multi-layer networks with backpropagation in 1986. The vocabulary changed from &lt;em>adaptive filtering&lt;/em> to &lt;em>deep learning&lt;/em>, but the core idea — adjust parameters in the direction that reduces error, one small step at a time — is continuous across both worlds.&lt;/p>
&lt;p>This post is my attempt to make that lineage explicit: what LMS actually is, why it is structurally the same rule as stochastic gradient descent on a linear model, how the engineering trade-offs line up, and why non-stationarity remains the hard problem in both domains.&lt;/p>
&lt;hr>
&lt;h2 id="lms-is-not-a-metaphor-for-training--it-is-the-algorithm">LMS Is Not a Metaphor for Training — It Is the Algorithm
&lt;/h2>&lt;p>The LMS update for a linear combiner (FIR filter or single Adaline) is:&lt;/p>
$$
\mathbf{w}(n+1) = \mathbf{w}(n) + \mu \, e(n) \, \mathbf{x}(n)
$$&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/LMS_SGD_structural_equivalence_diagram.png" alt="LMS = SGD structural equivalence diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>Here \(\mathbf{w}(n)\) is the weight vector at time \(n\), \(\mathbf{x}(n)\) is the input vector (tap-delay line or feature vector), \(e(n) = d(n) - y(n)\) is the error between the desired response \(d(n)\) and the output \(y(n) = \mathbf{w}^\top(n)\mathbf{x}(n)\), and \(\mu\) is the step size.&lt;/p>
&lt;p>That is &lt;strong>stochastic gradient descent&lt;/strong> on the instantaneous squared error \(\frac{1}{2}e^2(n)\) with respect to \(\mathbf{w}\). The gradient of \(\frac{1}{2}(d - \mathbf{w}^\top\mathbf{x})^2\) with respect to \(\mathbf{w}\) is \(-e\,\mathbf{x}\). Walking in the opposite direction of the gradient (or equivalently, in the direction \(+e\,\mathbf{x}\) when you define the update as above) is exactly the LMS rule.&lt;/p>
&lt;p>So if you have ever shipped an LMS equalizer or echo canceller, you have implemented the foundational learning rule that underlies a huge fraction of modern machine learning: &lt;strong>small steps proportional to error times input&lt;/strong>. The notation in Haykin&amp;rsquo;s &lt;em>Adaptive Filter Theory&lt;/em> differs from PyTorch docs; the mathematics does not.&lt;/p>
&lt;p>Multi-layer networks add the chain rule (backpropagation) to compute how error propagates to earlier layers, but the &lt;strong>local&lt;/strong> update at a linear layer trained with mean squared error is still the same structural move: adjust weights in proportion to error and activations. Everything else — momentum, Adam, adaptive learning rates — is engineering on top of that spine.&lt;/p>
&lt;hr>
&lt;h2 id="the-engineering-trade-offs-are-the-same-trade-offs">The Engineering Trade-Offs Are the Same Trade-Offs
&lt;/h2>&lt;p>In telecommunications, the step size \(\mu\) controls the classic compromise: &lt;strong>convergence speed versus steady-state misadjustment&lt;/strong>. Too large — the filter can diverge or oscillate. Too small — the filter cannot track a fast-fading channel or a moving echo path. Entire chapters of adaptive filtering textbooks are devoted to stability bounds on \(\mu\) (often expressed in terms of input power and filter length) and to variants that fix the worst-case behavior.&lt;/p>
&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/Step_size_learning_rate_trade-off_diagram.png" alt="Step size / learning rate trade-off diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>In deep learning, the learning rate \(\eta\) plays the same role at a higher level: too high and training diverges or chatters around a minimum; too low and you underfit or burn compute without making progress. The community talks about learning-rate schedules, warm-up, and cosine decay — different names for the same instinct: &lt;strong>the right step size depends on the landscape and may need to change over time&lt;/strong>.&lt;/p>
&lt;p>&lt;strong>Normalized LMS (NLMS)&lt;/strong> scales the update by the inverse of the input energy \(\|\mathbf{x}(n)\|^2\) (with a small regularizer to avoid division by zero). The goal is stable convergence when input power varies — the same motivation that shows up in adaptive optimizers that normalize updates by running statistics of gradients (RMSProp-style normalization is not identical to NLMS, but the &lt;em>intent&lt;/em> — tame the step when the signal scale changes — is shared). The DSP community spent decades refining these ideas for real-time hardware; ML rediscovered many of the same pressures when training became unstable at scale.&lt;/p>
&lt;hr>
&lt;h2 id="non-stationarity-was-always-the-real-problem--and-still-is">Non-Stationarity Was Always the Real Problem — and Still Is
&lt;/h2>&lt;p>Adaptive filters were built for &lt;strong>non-stationary&lt;/strong> environments: multipath fading, time-varying echoes, drifting noise floors. The “true” optimal weights are not fixed; they move. The filter is not supposed to converge once and freeze — it is supposed to &lt;strong>track&lt;/strong>. That mindset is closer to production ML than a static batch fit on a fixed dataset.&lt;/p>
&lt;p>Modern systems face the same phenomenon under different labels: &lt;strong>distribution shift&lt;/strong>, &lt;strong>concept drift&lt;/strong>, stale features, changing user behavior, adversarial drift in inputs. The model that was optimal last month is not guaranteed to be optimal this month. Retraining on a schedule, online updates, monitoring, and guardrails are the engineering response — conceptually in the same family as “never assume the channel is static.”&lt;/p>
&lt;p>Research on in-context learning in linear models (for example Akyürek et al., 2022) even investigates which learning algorithms are implicitly approximated by transformers under simplified settings — another reminder that the boundary between classical adaptive signal processing and contemporary ML is thinner than course catalogs suggest.&lt;/p>
&lt;hr>
&lt;h2 id="the-bigger-picture">The Bigger Picture
&lt;/h2>&lt;p style="text-align: center;">
&lt;img src="https://corebaseit.com/diagrams/Historical_lineage_timeline_diagram.png" alt="Historical lineage / timeline diagram" style="max-width: 900px; width: 100%;" />
&lt;/p>
&lt;p>For engineers who came up through &lt;strong>telecommunications and signal processing&lt;/strong>, the move into AI is often described as a career pivot. In my experience, it is closer to a &lt;strong>change of vocabulary&lt;/strong> on top of a continuous mathematical thread: error-driven updates, step-size discipline, stability under non-stationarity, and the centrality of second-order statistics (explicitly in LMS, implicitly in much of modern training).&lt;/p>
&lt;p>The boundary between DSP and machine learning was never as sharp as the literature implied. If you understand LMS, you already understand a piece of what every deep learning framework is doing when it steps the weights. The rest is scale, architecture, and tooling — important, but not magic.&lt;/p>
&lt;hr>
&lt;h2 id="references">References
&lt;/h2>&lt;ul>
&lt;li>Widrow, B., &amp;amp; Hoff, M. E. &amp;ldquo;Adaptive switching circuits.&amp;rdquo; &lt;em>IRE WESCON Convention Record&lt;/em>, 4, 96–104, 1960.&lt;/li>
&lt;li>Haykin, S. &lt;em>Adaptive Filter Theory&lt;/em> (4th ed.). Prentice Hall, 2002.&lt;/li>
&lt;li>Rumelhart, D. E., Hinton, G. E., &amp;amp; Williams, R. J. &amp;ldquo;Learning representations by back-propagating errors.&amp;rdquo; &lt;em>Nature&lt;/em>, 323, 533–536, 1986.&lt;/li>
&lt;li>Akyürek, E. et al. &amp;ldquo;What learning algorithm is in-context learning? Investigations with linear models.&amp;rdquo; 2022. &lt;a class="link" href="https://arxiv.org/abs/2211.15661" target="_blank" rel="noopener"
>arxiv.org/abs/2211.15661&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="further-reading">Further reading
&lt;/h2>&lt;ul>
&lt;li>&lt;a class="link" href="https://corebaseit.com/posts/stochastic-entropy-ai/" >Stochastic, Entropy &amp;amp; AI: From Thermodynamics to Information Theory to Modern Machine Learning&lt;/a> — related thread on probability, information, and ML foundations&lt;/li>
&lt;li>&lt;em>The Obsolescence Paradox: Why the Best Engineers Will Thrive in the AI Era&lt;/em> — engineering judgment as tools and vocabulary change&lt;/li>
&lt;/ul></description></item><item><title>Stochastic, Entropy &amp; AI: From Thermodynamics to Information Theory to Modern Machine Learning</title><link>https://corebaseit.com/corebaseit_posts/stochastic-entropy-ai/</link><pubDate>Sat, 07 Mar 2026 12:00:00 +0100</pubDate><author>contact@corebaseit.com (Vincent Bevia)</author><guid>https://corebaseit.com/corebaseit_posts/stochastic-entropy-ai/</guid><description>&lt;p>I was listening to a podcast the other day about AI and the mathematics behind it — especially stochastic processes, entropy, and probability — and it immediately drew me in. With a background in electrical engineering and telecommunications, I have always found this intersection fascinating, so I decided to write this article. I hope you enjoy it.&lt;/p>
&lt;p>There is a thread running through thermodynamics, information theory, and modern artificial intelligence — and it is deeper than analogy. The mathematics used to describe the disorder of a gas, the uncertainty of a message, and the optimization of a neural network are closely related. Understanding that connection is not merely academic. It clarifies why stochasticity and entropy are not bugs in AI systems, but foundational design principles.&lt;/p>
&lt;p>This post traces that thread: from Boltzmann and Shannon to cross-entropy loss, temperature settings, and elliptic curves in modern cryptography. Physics, information theory, and language models rest on deeply connected mathematical foundations.&lt;/p>
&lt;hr>
&lt;h2 id="1-stochastic-governed-by-probability">1. Stochastic: Governed by Probability
&lt;/h2>&lt;p>The word &lt;strong>stochastic&lt;/strong> comes from the Ancient Greek &lt;strong>στοχαστικός&lt;/strong> (stokhastikós), related to &lt;strong>στοχάζομαι&lt;/strong> (“to aim, to guess”) and &lt;strong>τόχος&lt;/strong> (“target”). In modern science and engineering, it means &lt;strong>governed by probability&lt;/strong>. A stochastic process is one where outcomes are not deterministic; they are drawn from a probability distribution. Given the same initial conditions, you may get a different result each time.&lt;/p>
&lt;p>The opposite is &lt;strong>deterministic&lt;/strong> — the same input always yields exactly the same output. But not all randomness is the same.&lt;/p>
&lt;h3 id="epistemic-vs-ontic-randomness">Epistemic vs. Ontic Randomness
&lt;/h3>&lt;p>A coin flip, at the level of classical mechanics, is deterministic. Given exact knowledge of initial position, velocity, air currents, and surface properties, Newtonian physics would predict the outcome with certainty. The randomness we assign to it is &lt;strong>epistemic&lt;/strong> — a product of our ignorance of initial conditions, not of any fundamental indeterminacy in nature. We model it as a fair Bernoulli trial because we cannot practically measure or control those conditions.&lt;/p>
&lt;p>Thermal noise — Johnson–Nyquist noise — is different. It arises from the random thermal agitation of charge carriers in a conductor and is rooted in quantum and statistical mechanics. At practical engineering scales, such fluctuations are treated as fundamentally irreducible and modeled statistically. This is &lt;strong>ontic&lt;/strong> randomness — intrinsic to the physical system.&lt;/p>
&lt;p>Epistemic randomness reflects our ignorance; in principle, a perfect observer could remove it. Ontic randomness is intrinsic; no amount of additional information eliminates it. This distinction matters for how we interpret probabilistic models in physics, engineering, and AI.&lt;/p>
&lt;hr>
&lt;h2 id="2-entropy-in-communications-shannons-measure-of-uncertainty">2. Entropy in Communications: Shannon&amp;rsquo;s Measure of Uncertainty
&lt;/h2>&lt;p>In 1948, Claude Shannon published &lt;em>A Mathematical Theory of Communication&lt;/em>. He defined a precise mathematical measure of uncertainty — which he called &lt;strong>entropy&lt;/strong> — deliberately borrowing the term from thermodynamics.&lt;/p>
&lt;p>Shannon entropy measures the average uncertainty of an information source:&lt;/p>
&lt;p>&lt;strong>H(X) = −∑ p(x) · log₂ p(x)&lt;/strong>&lt;/p>
&lt;p>Where &lt;em>p(x)&lt;/em> is the probability of each possible symbol. If a source always sends the same symbol, entropy is zero — no surprise, no information. If all symbols are equally likely, entropy is maximized — maximum uncertainty and maximum information per symbol.&lt;/p>
&lt;p>Shannon entropy is the theoretical lower bound on how many bits you need to encode a message without loss. It answers the question: &lt;em>how unpredictable is this source?&lt;/em> A source with low entropy can be heavily compressed. A source with high entropy cannot be compressed further — it is already maximally dense with information.&lt;/p>
&lt;p>This is the foundation of data compression and channel capacity theory. The famous Shannon limit defines the maximum rate at which information can be transmitted over a noisy channel without error.&lt;/p>
&lt;hr>
&lt;h2 id="3-thermodynamic-and-information-entropy-shared-mathematical-form">3. Thermodynamic and Information Entropy: Shared Mathematical Form
&lt;/h2>&lt;p>The relationship between Shannon&amp;rsquo;s information entropy and Boltzmann&amp;rsquo;s thermodynamic entropy is not a metaphor. It is a deep mathematical connection.&lt;/p>
&lt;p>Boltzmann defined thermodynamic entropy as:&lt;/p>
&lt;p>&lt;strong>S = k · ln(W)&lt;/strong>&lt;/p>
&lt;p>Where &lt;em>k&lt;/em> is Boltzmann&amp;rsquo;s constant and &lt;em>W&lt;/em> is the number of possible microstates a physical system can occupy. A gas with molecules spread randomly everywhere has more possible configurations — higher entropy. A perfectly ordered crystal has very few microstates — low entropy.&lt;/p>
&lt;p>When Shannon showed his formula to John von Neumann and asked what to call it, von Neumann reportedly replied: &lt;em>&amp;ldquo;Call it entropy. Nobody knows what entropy really is, so in a debate you will always have the advantage.&amp;rdquo;&lt;/em>&lt;/p>
&lt;p>Beyond the wit, Shannon recognized something profound: the formulas are closely related in structure. Both describe multiplicity, uncertainty, and the distribution of possible states. Both measure, in different domains, how much is not fully specified about a system.&lt;/p>
&lt;h3 id="landauers-principle-information-has-physical-cost">Landauer&amp;rsquo;s Principle: Information Has Physical Cost
&lt;/h3>&lt;p>Maxwell&amp;rsquo;s Demon — a thought experiment from 1867 — imagined a tiny demon sorting fast molecules from slow ones, seemingly reducing thermodynamic entropy without doing work. The resolution, formalized by Rolf Landauer, is that the demon must store information about each molecule. When it erases that information from memory, that erasure costs energy and generates heat.&lt;/p>
&lt;p>&lt;strong>Landauer&amp;rsquo;s Principle:&lt;/strong> Erasing one bit of information dissipates a minimum amount of energy and produces a corresponding increase in thermodynamic entropy.&lt;/p>
&lt;p>Information is not abstract. It has a physical cost. The second law of thermodynamics and the limits of data compression are deeply connected constraints viewed from different angles.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Thermodynamics&lt;/th>
&lt;th>Information Theory&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Physical disorder&lt;/td>
&lt;td>Message unpredictability&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Heat dissipation&lt;/td>
&lt;td>Bit erasure cost&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Second law: entropy increases&lt;/td>
&lt;td>Cannot compress below Shannon entropy&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Equilibrium tends toward high entropy&lt;/td>
&lt;td>Random noise is a maximum-entropy source&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h2 id="4-how-these-concepts-percolate-into-ai">4. How These Concepts Percolate into AI
&lt;/h2>&lt;p>Stochastic processes and entropy are structurally embedded in how neural networks are trained, how language models generate text, and how reinforcement learning agents explore.&lt;/p>
&lt;h3 id="cross-entropy-loss">Cross-Entropy Loss
&lt;/h3>&lt;p>The most widely used training objective in neural networks — especially for classification and language models — is &lt;strong>cross-entropy loss&lt;/strong>. It measures how different the model&amp;rsquo;s predicted probability distribution is from the target distribution. Minimizing cross-entropy loss is equivalent to maximizing the likelihood of correct outputs. Every time a language model trains, it is performing optimization grounded in Shannon-style information measures.&lt;/p>
&lt;h3 id="stochastic-gradient-descent">Stochastic Gradient Descent
&lt;/h3>&lt;p>Stochastic Gradient Descent (SGD) samples random mini-batches instead of computing gradients over the full dataset. The randomness this introduces is not merely a computational shortcut — it also helps models explore the loss surface more effectively than a fully deterministic optimizer would.&lt;/p>
&lt;h3 id="temperature-as-an-entropy-control">Temperature as an Entropy Control
&lt;/h3>&lt;p>When a large language model generates the next token, it samples from a probability distribution over the vocabulary. &lt;strong>Temperature&lt;/strong> directly affects the entropy of that distribution:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Low temperature&lt;/strong> — peaky distribution, near-deterministic, low entropy. The model tends to pick the highest-probability token.&lt;/li>
&lt;li>&lt;strong>High temperature&lt;/strong> — flatter distribution, more random, higher entropy. The model explores less likely but sometimes more creative options.&lt;/li>
&lt;/ul>
&lt;p>When you adjust temperature in an LLM, you are rescaling the logits, which usually makes the next‑token distribution lower‑entropy (more peaked) at low temperatures and higher‑entropy (flatter) at high temperatures. In doing so, you reshape uncertainty in the output distribution. Physics, information theory, and language models all rely on closely related mathematics.&lt;/p>
&lt;h3 id="kl-divergence-and-entropy-regularization">KL Divergence and Entropy Regularization
&lt;/h3>&lt;p>Kullback–Leibler divergence measures how one probability distribution diverges from another. It is defined in terms of entropy and is used in settings such as variational autoencoders and RLHF to keep models from drifting too far from a target distribution.&lt;/p>
&lt;p>In reinforcement learning, entropy regularization — used in algorithms like Soft Actor-Critic (SAC) — explicitly rewards a policy for maintaining high entropy, encouraging exploration rather than premature collapse into a single deterministic strategy.&lt;/p>
&lt;hr>
&lt;h2 id="5-appendix-elliptic-curve-cryptography--related-mathematical-thinking">5. Appendix: Elliptic Curve Cryptography — Related Mathematical Thinking
&lt;/h2>&lt;p>These ideas also surface in modern cryptography, where secure systems rely on mathematical structure, one-way functions, and carefully managed randomness.&lt;/p>
&lt;p>An elliptic curve is defined by the Weierstrass equation:&lt;/p>
&lt;p>&lt;strong>y² = x³ + ax + b&lt;/strong>&lt;/p>
&lt;p>In practical cryptography, elliptic curves are defined over finite fields, turning the curve into a discrete set of points with useful algebraic properties.&lt;/p>
&lt;p>&lt;img src="https://corebaseit.com/diagrams/ECC_Curve_secp256r1.png"
loading="lazy"
alt="Elliptic curve secp256r1 — point addition and key multiplication"
>&lt;/p>
&lt;p>&lt;strong>Public key Q = Private key k × G&lt;/strong>&lt;/p>
&lt;p>Where &lt;em>G&lt;/em> is a fixed public generator point and &lt;em>k&lt;/em> is a secret private integer. Point multiplication means repeated elliptic-curve addition under well-defined algebraic rules.&lt;/p>
&lt;p>&lt;strong>Why this is a one-way function:&lt;/strong> Computing &lt;em>Q&lt;/em> from &lt;em>k&lt;/em> is efficient. Recovering &lt;em>k&lt;/em> from &lt;em>Q&lt;/em> and &lt;em>G&lt;/em> is computationally infeasible. This is the Elliptic Curve Discrete Logarithm Problem (ECDLP). A 256-bit elliptic-curve key is commonly regarded as offering security comparable to a 3072-bit RSA key.&lt;/p>
&lt;p>The connection to entropy is subtle but important: digital signature schemes such as ECDSA rely on per-signature randomness. If that randomness is reused or becomes predictable, the private key may be exposed. In cryptography, randomness is not a convenience. It is a security requirement.&lt;/p>
&lt;hr>
&lt;h2 id="key-takeaways">Key Takeaways
&lt;/h2>&lt;ol>
&lt;li>
&lt;p>&lt;strong>Stochasticity is the mechanism&lt;/strong> — uncertainty is not a failure of understanding, but a fundamental feature of physical and informational systems.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Entropy is the measurement&lt;/strong> — a precise mathematical way to quantify that uncertainty.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>These domains share related mathematical structures&lt;/strong> — from Boltzmann in the nineteenth century to Shannon in the twentieth, and from there to cross-entropy loss, temperature scaling, and KL divergence in modern AI.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Information has physical cost&lt;/strong> — Landauer&amp;rsquo;s principle links information theory and thermodynamics at a physical level.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Cryptography and AI both depend on structured uncertainty&lt;/strong> — whether in probabilistic modeling, optimization, or secure randomness.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;p>The second law of thermodynamics and the limits of data compression are deeply connected constraints, viewed through different lenses. The disorder of a physical system, the uncertainty of a message, and the probabilistic behavior of a language model can all be described using closely related mathematical ideas. That is one of the most elegant continuities in the history of science.&lt;/p>
&lt;hr>
&lt;h2 id="references">References
&lt;/h2>&lt;ul>
&lt;li>Shannon, C. E. (1948). &lt;a class="link" href="https://doi.org/10.1002/j.1538-7305.1948.tb01338.x" target="_blank" rel="noopener"
>A Mathematical Theory of Communication&lt;/a>. &lt;em>Bell System Technical Journal&lt;/em>, 27(3), 379–423.&lt;/li>
&lt;li>Landauer, R. (1961). Irreversibility and Heat Generation in the Computing Process. &lt;em>IBM Journal of Research and Development&lt;/em>, 5(3), 183–191.&lt;/li>
&lt;li>Cover, T. M., &amp;amp; Thomas, J. A. (2006). &lt;em>Elements of Information Theory&lt;/em> (2nd ed.). Wiley.&lt;/li>
&lt;li>Goodfellow, I., Bengio, Y., &amp;amp; Courville, A. (2016). &lt;em>Deep Learning&lt;/em>. MIT Press. (Chapters on cross-entropy, SGD, and variational methods.)&lt;/li>
&lt;li>Hopsworks (2025). &lt;a class="link" href="https://www.hopsworks.ai/dictionary/llm-temperature" target="_blank" rel="noopener"
>LLM Temperature&lt;/a>. Covers low-T = peaked/predictable and high-T = flat/creative in LLMs.&lt;/li>
&lt;li>Gebodh, N. (2024). &lt;a class="link" href="https://ngebodh.github.io/projects/Short_dive_posts/LLM_temp/LLM_temp.html" target="_blank" rel="noopener"
>Why Does My LLM Have A Temperature?&lt;/a>. Softmax and temperature math.&lt;/li>
&lt;/ul></description></item></channel></rss>