pisces.math_utils.random_fields.generate_white_noise_power_spectrum#
- pisces.math_utils.random_fields.generate_white_noise_power_spectrum(amplitude: float = 1.0) Callable [source]#
Generate a white-noise (flat) power spectrum function.
A white-noise spectrum is defined by a constant power at all wavenumbers \(k\), i.e.
\[P(k) = A,\]where \(A\) is the amplitude. This corresponds to a random field with equal variance contributed by all Fourier modes, independent of scale.
- Parameters:
amplitude (
float
, optional) – Constant amplitude \(A\) of the power spectrum. Default is1.0
.- Returns:
A function
P(kx, ky, ...)
that takes arrays of wavenumber components and returns the constant power spectrum evaluated on that grid.- Return type:
Callable
Examples
from pisces.math_utils.random_fields import generate_white_noise_power_spectrum L, n = 10.0, 128 k_grid = np.fft.fftfreq(n, d=L/n) * 2 * np.pi power_spectrum = generate_white_noise_power_spectrum() ps_array = power_spectrum(k_grid) import matplotlib.pyplot as plt plt.loglog(k_grid, ps_array) plt.xlabel('Wavenumber k') plt.ylabel('Power Spectrum P(k)') plt.title('White Noise Power Spectrum') plt.show()
(
Source code
,png
,hires.png
,pdf
)