---
title: Radiation and noise lab
heading: Planck's integrals, Wien's constant, blackbody band fractions, simulated Johnson noise and receiver cascades in Python
eyebrow: B11 · Lesson 13 · Radiation and noise lab
xp: 50
---

::: hook
Lessons 9 to 12 used formulas whose constants come from integrals: Stefan–Boltzmann's σ from $\int x^3/(e^x - 1)$, Wien's 2898 µm·K from a transcendental equation, kT/C noise from integrating a noise spectrum through a filter. In this lab you'll compute each of those from scratch, then use them as an engineer would: how much of a lamp's light is visible, what a thermal camera's 8 to 14 µm band collects, whether a simulated resistor's noise really settles at kT/C, and what noise temperature a chain of amplifiers adds.
:::

::: play
- The curve is a blackbody's spectrum per unit wavelength, scaled to its peak, on a log wavelength axis.
- The shaded band runs between the two edge sliders, and the readout gives the fraction of all the radiated power inside it, from Planck's law integrated in closed form (step 3 does it numerically).
- Set the band to 0.4 to 0.7 µm and compare 2700 K (a warm lamp), 3000 K and 5772 K (the Sun). Then set 8 to 14 µm and 300 K: that's what a thermal camera sees.
:::

```sim plot
view: graph
x: l = 0.1..30 µm log
y: B = 0..1.05
slider: T = 200..6000 = 3000 K log
slider: a = 0.2..20 = 0.4 µm log
slider: b = 0.3..30 = 0.7 µm log
plot: ((2897.77/T)^5*(exp(4.965114) - 1))/(l^5*(exp(14387.77/(l*T)) - 1)) | label: spectral power, relative to the peak | samples: 600 | fill: a..b
marker: l = 2897.77/T | label: Wien peak
readout: fraction of power in the band = 15/pi^4*((exp(-14387.77/(b*T))*((14387.77/(b*T))^3 + 3*(14387.77/(b*T))^2 + 6*(14387.77/(b*T)) + 6) + exp(-2*14387.77/(b*T))*((14387.77/(b*T))^3/2 + 3*(14387.77/(b*T))^2/4 + 6*(14387.77/(b*T))/8 + 6/16) + exp(-3*14387.77/(b*T))*((14387.77/(b*T))^3/3 + 3*(14387.77/(b*T))^2/9 + 6*(14387.77/(b*T))/27 + 6/81)) - (exp(-14387.77/(a*T))*((14387.77/(a*T))^3 + 3*(14387.77/(a*T))^2 + 6*(14387.77/(a*T)) + 6) + exp(-2*14387.77/(a*T))*((14387.77/(a*T))^3/2 + 3*(14387.77/(a*T))^2/4 + 6*(14387.77/(a*T))/8 + 6/16) + exp(-3*14387.77/(a*T))*((14387.77/(a*T))^3/3 + 3*(14387.77/(a*T))^2/9 + 6*(14387.77/(a*T))/27 + 6/81))) | digits: 3
```

::: predict
## About what fraction of a 3000 K incandescent filament's radiation falls in the visible band, 0.4 to 0.7 µm?

- [ ] About 80%
- [ ] About 40%
- [x] About 8%
- [ ] Under 1%

::: reveal
About 8%: the filament peaks near 1 µm, in the infrared, and most of its power lies beyond 0.7 µm. That's why incandescent bulbs were so inefficient as lights. The Sun, at 5772 K, puts 37% of its power into the same band.
:::
:::

::: nameit
## Planck's integrals

Substituting $x = \frac{h\nu}{kT}$ turns every blackbody quantity into a pure number times a power of T. The total power needs $\int_0^\infty\frac{x^3}{e^x - 1}dx = \frac{\pi^4}{15}$, which gives $\sigma = \frac{2\pi^5k^4}{15h^3c^2}$. The photon count needs $\int_0^\infty\frac{x^2}{e^x - 1}dx = 2\zeta(3) = 2.404$, so the average photon carries $\frac{\pi^4/15}{2\zeta(3)}kT = 2.701kT$.

## Wien's constants

Per unit wavelength the spectrum goes as $\frac{x^5}{e^x - 1}$, which peaks where $5(1 - e^{-x}) = x$, at x = 4.965; that's $\lambda_{max}T$ = 2898 µm·K. Per unit frequency it goes as $\frac{x^3}{e^x - 1}$, peaking at x = 2.821. The two peaks don't describe the same light: the frequency peak lies at a wavelength 1.76 times longer.

## Band fractions

Expanding $\frac{1}{e^x - 1} = \sum_ne^{-nx}$ and integrating term by term, the fraction of power at wavelengths shorter than λ is

$$F(x) = \frac{15}{\pi^4}\sum_{n\ge1}e^{-nx}\left(\frac{x^3}{n} + \frac{3x^2}{n^2} + \frac{6x}{n^3} + \frac{6}{n^4}\right), \qquad x = \frac{hc}{\lambda kT},$$

and a band's share is the difference of two such values. The series converges quickly when x is a few or more.

## Noise in a simulation

To simulate a resistor's Johnson noise, draw independent Gaussian samples every Δt with variance $\frac{2kTR}{\Delta t}$, which spreads the one-sided density 4kTR evenly up to the Nyquist frequency $\frac{1}{2\Delta t}$. Passing them through a discrete RC filter should leave a variance close to kT/C. For a chain of stages, Friis's formula from lesson 12, $T_e = T_1 + \frac{T_2}{G_1} + \frac{T_3}{G_1G_2} + \cdots$, gives the total.
:::

::: example
## Compute σ from Planck's integral and check it against 5.670 × 10⁻⁸ W/(m²·K⁴).

::: solution
1. **Power per area as an integral.**
   $$\frac{P}{A} = \frac{2\pi(kT)^4}{h^3c^2}\int_0^\infty\frac{x^3}{e^x - 1}dx$$
2. **The integral.**
   $$\begin{aligned} \int_0^\infty\frac{x^3}{e^x - 1}dx &= \frac{\pi^4}{15} \\ &= 6.4939 \end{aligned}$$
3. **Check it numerically.** A numerical integral on a fine grid to x = 50 matches 6.4939 to many digits, since the integrand falls as $x^3e^{-x}$.
4. **The constant.** In W/(m²·K⁴),
   $$\begin{aligned} \sigma &= \frac{2\pi k^4}{h^3c^2} \times 6.4939 \\ &= \frac{2\pi^5k^4}{15h^3c^2} \\ &= 5.6704 \times 10^{-8} \end{aligned}$$
5. **Mean photon energy.** The same integral with $x^2$ gives 2.4041, and the ratio, 2.701, is the mean photon energy in units of kT.

**Answer:** σ = 5.6704 × 10⁻⁸ W/(m²·K⁴), matching 5.670 × 10⁻⁸.
:::
:::

::: example
## What fraction of the radiation falls in the visible band, 0.4 to 0.7 µm, for a 2700 K lamp, a 3000 K filament and the 5772 K Sun?

::: solution
1. **Limits of the band.** For the band, x runs from
   $$\frac{14\,388}{0.7T} \quad\text{to}\quad \frac{14\,388}{0.4T}$$
   and the fraction is the difference of F at the two ends.
2. **The 2700 K lamp.** 5.0%.
3. **The 3000 K filament.** 8.1%.
4. **The 5772 K Sun.** 36.6%.
5. **What it means for lighting.** A warm-white incandescent bulb turns only about 5% of its power into visible light (less in useful lumens, since the eye favors green). LEDs skip the blackbody altogether, putting nearly all their output where it's wanted.

**Answer:** 5.0% for the 2700 K lamp, 8.1% for the 3000 K filament and 36.6% for the Sun.
:::
:::

::: example
## A thermal camera looks in the 8 to 14 µm band. What fraction of a 300 K object's radiation is in that band, and how much power per cm² is that?

::: solution
1. **Limits of the band.** At 300 K,
   $$\begin{aligned} x_1 &= \frac{14\,388}{14 \times 300} \\ &= 3.43 \\ x_2 &= \frac{14\,388}{8 \times 300} \\ &= 6.00 \end{aligned}$$
2. **Fraction in the band.**
   $$F(6.00) - F(3.43) = 0.376$$
3. **Total from a blackbody at 300 K.**
   $$\sigma T^4 = 459\ \text{W/m}^2$$
4. **Power in the band.**
   $$\begin{aligned} 0.376 \times 459 &= 173\ \text{W/m}^2 \\ &= 17.3\ \text{mW/cm}^2 \end{aligned}$$
5. **Why cameras use this band.** That band also sits in a window where the atmosphere hardly absorbs, and it contains the peak of room-temperature emission (9.7 µm). Those two facts are why uncooled thermal cameras use it.

**Answer:** 0.376 of the radiation is in the band, 17.3 mW/cm².
:::
:::

::: check
kind: python

## Step 1. Write `planck_integrals()` returning a tuple `(I3, I2, sigma)`: the integrals $\int_0^\infty\frac{x^3}{e^x - 1}dx$ and $\int_0^\infty\frac{x^2}{e^x - 1}dx$ computed numerically, and σ from the first.

```python starter
import numpy as np

def planck_integrals():
    return 6.0, 2.0, 5e-8

print(planck_integrals())
```

```python solution
import numpy as np

def planck_integrals():
    x = np.linspace(1e-9, 60, 600001)
    trap = np.trapezoid if hasattr(np, "trapezoid") else np.trapz
    I3 = trap(x**3 / np.expm1(x), x)
    I2 = trap(x**2 / np.expm1(x), x)
    h, c, k = 6.62607015e-34, 2.99792458e8, 1.380649e-23
    sigma = 2 * np.pi * k**4 / (h**3 * c**2) * I3
    return float(I3), float(I2), float(sigma)

print(planck_integrals())
```

```python tests
import math
I3, I2, s = planck_integrals()
assert abs(I3 - math.pi**4 / 15) < 1e-6, f"The x³ integral is π⁴/15 = 6.493939; got {I3}"
assert abs(I2 - 2.4041138) < 1e-6, f"The x² integral is 2ζ(3) = 2.404114; got {I2}"
assert abs(s / 5.670374e-8 - 1) < 1e-6, f"σ should be 5.670374e-8; got {s}"
```

::: right
Right. Both integrals converge fast, since the integrands fall exponentially past x of about 10.
:::
:::

::: check
kind: python

## Step 2. Write `wien()` returning `(x_lambda, b, x_nu)`: the root of $5(1 - e^{-x}) = x$ by Newton's method, Wien's constant $b = \frac{hc}{kx}$ in µm·K, and the root of $3(1 - e^{-x}) = x$.

```python starter
def wien():
    return 5.0, 2900.0, 3.0

print(wien())
```

```python solution
import math

def newton(n, x):
    for _ in range(50):
        f = n * (1 - math.exp(-x)) - x
        df = n * math.exp(-x) - 1
        x -= f / df
    return x

def wien():
    h, c, k = 6.62607015e-34, 2.99792458e8, 1.380649e-23
    xl = newton(5, 5.0)
    xn = newton(3, 3.0)
    return xl, h * c / (k * xl) * 1e6, xn

print(wien())
```

```python tests
xl, b, xn = wien()
assert abs(xl - 4.965114) < 1e-6, f"The wavelength peak is at x = 4.965114; got {xl}"
assert abs(b - 2897.77) < 0.01, f"Wien's constant is 2897.77 µm·K; got {b}"
assert abs(xn - 2.821439) < 1e-6, f"The frequency peak is at x = 2.821439; got {xn}"
```

::: right
Right. Newton converges in a handful of steps from a starting guess at n, since the root sits just below it.
:::
:::

::: check
kind: python

## Step 3. Write `band_fraction(T, l1, l2)` returning the fraction of a blackbody's power between wavelengths `l1` and `l2` (µm) at temperature `T`, by integrating Planck's law numerically in x.

```python starter
def band_fraction(T, l1, l2):
    return 0.1

print(band_fraction(3000, 0.4, 0.7))
```

```python solution
import numpy as np

def band_fraction(T, l1, l2):
    c2 = 14387.77
    x1, x2 = c2 / (l2 * T), c2 / (l1 * T)
    x = np.linspace(x1, x2, 200001)
    trap = np.trapezoid if hasattr(np, "trapezoid") else np.trapz
    return float(trap(x**3 / np.expm1(x), x) * 15 / np.pi**4)

print(band_fraction(3000, 0.4, 0.7))
```

```python tests
assert abs(band_fraction(3000, 0.4, 0.7) - 0.08092) < 2e-5, f"A 3000 K filament puts 8.09% in the visible; got {band_fraction(3000, 0.4, 0.7)}"
assert abs(band_fraction(5772, 0.4, 0.7) - 0.36638) < 2e-5, "The Sun puts 36.6% in the visible."
assert abs(band_fraction(300, 8, 14) - 0.37574) < 2e-5, "A 300 K body puts 37.6% in 8 to 14 µm."
```

::: right
Right. The series formula gives the same values, which is how the sim's readout works.
:::
:::

::: check
kind: python

## Step 4. Write `rc_noise(R, C, T, n, seed)`: simulate n samples of a resistor's Johnson noise (Gaussian, variance $\frac{2kTR}{\Delta t}$ with $\Delta t = RC/50$) through the discrete filter $v \leftarrow v + \frac{\Delta t}{RC}(e - v)$, starting at 0, and return the variance of v over the second half of the run.

```python starter
import numpy as np

def rc_noise(R, C, T, n, seed):
    return 0.0

print(rc_noise(1e4, 1e-9, 300, 1000000, 1))
```

```python solution
import numpy as np

def rc_noise(R, C, T, n, seed):
    k = 1.380649e-23
    tau = R * C
    dt = tau / 50
    a = dt / tau
    rng = np.random.default_rng(seed)
    e = rng.normal(0.0, np.sqrt(2 * k * T * R / dt), n).tolist()
    v = [0.0] * n
    x = 0.0
    for i in range(n):
        x += a * (e[i] - x)
        v[i] = x
    return float(np.var(v[n // 2:]))

print(rc_noise(1e4, 1e-9, 300, 1000000, 1))
```

```python tests
k = 1.380649e-23
v1 = rc_noise(1e4, 1e-9, 300, 1000000, 1)
assert abs(v1 / (k * 300 / 1e-9) - 1) < 0.05, f"The variance should settle near kT/C = 4.14e-12 V²; got {v1}"
v2 = rc_noise(1e6, 1e-9, 300, 1000000, 2)
assert abs(v2 / v1 - 1) < 0.08, "A 100 times larger R gives the same kT/C."
```

::: right
Right. R drops out, as lesson 12 showed: the noise per hertz grows with R while the bandwidth shrinks in proportion.
:::
:::

::: check
kind: python

## Step 5. Write `cascade(stages)` for a list of `(gain_dB, noise_temperature_K)` stages, returning `(Te, NF_dB)`: the chain's noise temperature by Friis's formula and its noise figure referred to 290 K.

```python starter
def cascade(stages):
    return 0.0, 0.0

print(cascade([(20, 35.4), (-6, 1500)]))
```

```python solution
import math

def cascade(stages):
    Te = 0.0
    gain = 1.0
    for g_dB, t in stages:
        Te += t / gain
        gain *= 10 ** (g_dB / 10)
    return Te, 10 * math.log10(1 + Te / 290)

print(cascade([(20, 35.4), (-6, 1500)]))
```

```python tests
Te, NF = cascade([(20, 35.385), (-6, 1500)])
assert abs(Te - 50.385) < 1e-3, f"35.4 K + 1500/100 = 50.4 K; got {Te}"
assert abs(NF - 0.6957) < 1e-3, f"That's a 0.70 dB noise figure; got {NF}"
Te2, _ = cascade([(-6, 864.5), (20, 35.385)])
assert abs(Te2 - (864.5 + 35.385 * 10 ** 0.6)) < 1e-6, "A lossy stage first multiplies everything after it."
```

::: right
Right. The first stage's gain divides every later stage's noise, which is why the low-noise amplifier goes first.
:::
:::

::: check
kind: parts
given: T = 300 | 1000 | 5772

## A blackbody is at {T} K.

::: part
answer: 2897.77/T
unit: µm
tolerance: 0.5%

### At what wavelength does its spectrum per unit wavelength peak?

::: misses
- [any] $\lambda_{max} = \frac{2897.77\ \mu\text{m K}}{T}$.
:::
:::

::: part
answer: 2.99792458e8*6.62607015e-34/(2.821439*1.380649e-23*T)*1e6
unit: µm
tolerance: 0.5%

### Its spectrum per unit frequency peaks at $h\nu = 2.821kT$. What wavelength is that frequency?

::: misses
- [2897.77/T] The frequency peak is at a different place: x = 2.821 rather than 4.965.
- [any] $\lambda = \frac{c}{\nu} = \frac{hc}{2.821kT}$.
:::
:::
:::

::: check
given: T = 300 | 3000 | 5772
answer: 2*pi*(1.380649e-23*T)^3/((6.62607015e-34)^3*(2.99792458e8)^2)*2.4041138*1e-4
tolerance: 0.5%

## How many photons per second does each cm² of a blackbody at {T} K emit?

::: right
Right. $\frac{2\pi(kT)^3}{h^3c^2}\times2\zeta(3)$, which grows as $T^3$.
:::

::: misses
- [2*pi*(1.380649e-23*T)^3/((6.62607015e-34)^3*(2.99792458e8)^2)*2.4041138] Convert from m² to cm².
- [any] The photon integral is 2ζ(3) = 2.404.
:::
:::

::: check
given: T = 2.725 | 300 | 5772
answer: 2.70118*0.00008617333*T
unit: eV
tolerance: 0.5%

## What's the average energy of a photon in blackbody radiation at {T} K?

::: right
Right. $\frac{\pi^4/15}{2\zeta(3)}kT = 2.701kT$.
:::

::: misses
- [0.00008617333*T] It's 2.70kT, not kT.
- [2.821439*0.00008617333*T] That's the frequency peak; the mean is 2.701kT.
:::
:::

::: check
given: T = 0.02 | 4 | 300
answer: 1.380649e-23*T/6.62607015e-34/1e9
unit: GHz
tolerance: 0.5%

## At what frequency does a photon's energy hf equal kT at {T} K, where Johnson noise starts to fall below its classical value?

::: right
Right. $f = \frac{kT}{h}$, about 20.8 GHz per kelvin.
:::

::: misses
- [1.380649e-23*T/1.054571817e-34/1e9] Use h, not ħ: that's hf = kT.
- [any] $f = \frac{kT}{h}$.
:::
:::

::: explain
## Why can a single number, 2898 µm·K, give the peak wavelength of every blackbody?

::: model
Planck's law depends on wavelength and temperature only through the combination $\frac{hc}{\lambda kT}$, apart from an overall factor. Written in that variable, x, the shape of the spectrum per unit wavelength is $\frac{x^5}{e^x - 1}$ for every temperature, so its peak always falls at the same x, the root of $5(1 - e^{-x}) = x$, which is 4.965. Converting back, $\lambda_{max}T = \frac{hc}{4.965k}$ = 2898 µm·K. The same scaling makes every band fraction and every mean energy a pure number times a power of T, which is why one numerical integral serves every temperature.
:::
:::

::: practice

::: check
given: T = 500 | 800 | 1200 | 1500 | 2000 | 3000
answer: 2897.77/T
unit: µm
tolerance: 0.5%

## Wien peak at {T} K?

::: misses
- [any] $\frac{2897.77}{T}$ µm.
:::
:::

::: check
given: T = 3 | 10 | 77 | 300 | 1000 | 5800
answer: 2.70118*0.00008617333*T
unit: eV
tolerance: 0.5%

## Mean photon energy at {T} K?

::: misses
- [any] 2.701kT.
:::
:::
:::
