Example Data Table
| Index | Sample Value | Comment |
|---|---|---|
| 0 | 0.0000 | Start |
| 1 | 0.3090 | Rising |
| 5 | 1.0000 | Near peak |
| 10 | 0.0000 | Crossing |
| 15 | -1.0000 | Near trough |
| 19 | -0.3090 | End |
Formula Used
The discrete transform for bin k uses:
X[k] = Σ x[n] · e^{-j2πkn/N}, for n = 0..N-1.
Magnitude-squared power is:
|X[k]|² = Re(X[k])² + Im(X[k])².
This tool offers two common scalings:
- Power spectral density:
P[k] = |X[k]|² / (N·fs)(approx. per hertz). - Power spectrum:
P[k] = |X[k]|² / N²(per bin).
For one-sided output of real signals, interior bins are doubled to preserve total power.
How to Use This Calculator
- Paste your uniformly sampled values into the samples box.
- Enter the sampling frequency in hertz.
- Choose a window to reduce spectral leakage.
- Select detrending to remove offsets or drift.
- Pick a scaling mode and output units.
- Optionally set a frequency range and peak count.
- Press Calculate to view the spectrum above.
- Use the download buttons to export results.
1) What a power spectrum reveals
A power spectrum describes how a signal’s energy is distributed across frequency. In vibration, you can spot rotating components by their tone frequency. In audio, harmonics show timbre. In electronics, spurs reveal interference. This calculator converts sample values into frequency bins so you can compare peaks and broadband noise objectively.
2) Sampling frequency and the Nyquist limit
The sampling frequency fs sets the highest resolvable frequency. For real-valued signals, the one-sided view runs from 0 to fs/2 (Nyquist). For example, fs = 2000 Hz captures content up to 1000 Hz. Any higher-frequency content folds back as aliasing, so use proper acquisition filtering.
3) Frequency resolution and FFT length
Bin spacing is Δf = fs / N, where N is the transform length after padding. With fs = 1000 Hz and N = 1024, Δf ≈ 0.9766 Hz. Smaller Δf helps separate nearby tones, but it does not add new information unless you also record more samples.
4) Why windowing matters
If a tone does not fall exactly on a bin center, its energy “leaks” into adjacent bins. Window functions (Hann, Hamming, Blackman) taper endpoints to reduce leakage. Rectangular window preserves amplitude best for coherent sampling, but can spread energy widely when the record is not an integer number of cycles.
5) Detrending for reliable low-frequency results
Offsets and slow drifts inflate the 0–few hertz region. Removing the mean suppresses DC bias. Removing a linear trend suppresses ramp-like drift that otherwise dominates the lowest bins. If you are analyzing very low-frequency phenomena, consider leaving detrending off and managing drift at the measurement stage.
6) Spectrum versus power spectral density
This tool provides two common scalings. A power spectrum reports power per bin, useful for identifying dominant tones. A power spectral density (PSD) approximates power per hertz, which is better for comparing noise floors across different N values. PSD units are typically “signal²/Hz”.
7) Linear and dB output for interpretation
Linear output preserves raw magnitudes and is convenient for engineering calculations. dB output compresses large dynamic ranges: 10·log10(P). For example, a 10× increase in power corresponds to +10 dB. dB views make weak tones visible beside strong carriers.
8) Practical workflow and peak reporting
Start by setting fs, selecting a window, and choosing mean removal for typical sensor data. Use one-sided output for real signals. Limit the frequency range to your band of interest and request several peaks. The peak table ranks bins by magnitude, helping you document dominant frequencies quickly.
FAQs
1) What sample spacing does this calculator assume?
It assumes uniform sampling. Enter only sample values and provide the sampling frequency. If the time steps vary, resample to a uniform grid first for meaningful frequency bins.
2) Why do I see a huge value near 0 Hz?
A strong DC offset or slow drift concentrates energy at very low frequencies. Try “Remove mean” or “Remove linear trend,” and ensure your sensor chain is not saturating.
3) Does zero padding increase accuracy?
Zero padding increases the number of displayed bins and smooths the curve, but it does not add new information. True resolution improves when you collect more samples.
4) Which window should I choose?
Hann is a strong default for general analysis. Hamming can give slightly narrower main lobes. Blackman provides stronger sidelobe suppression for leakage-heavy cases, at the cost of wider peaks.
5) When should I use PSD instead of spectrum?
Use PSD to compare noise floors between measurements with different record lengths. Use spectrum when you mainly care about identifying and ranking dominant tones.
6) What does one-sided output change?
For real-valued signals, one-sided output shows 0 to Nyquist and doubles interior bins to conserve total power. Two-sided output keeps both positive and negative frequencies.
7) Why does the strongest peak frequency look slightly off?
The peak is reported at the nearest bin center. Increase recorded samples to reduce Δf, or use padding for a smoother plot. For precise estimation, apply peak interpolation techniques.