Sampling and Aliasing: Understanding Sampling Theory

Proper sampling is critical for accurately representing time series data. This guide explains sampling fundamentals, the Nyquist theorem, aliasing, and how Phoenix helps you avoid common pitfalls.

What is Sampling?

Sampling is the process of converting continuous signals into discrete data points by measuring at specific time intervals.

Continuous vs. Discrete

Continuous Signal (Reality): - Exists at every instant in time - Infinite time resolution - Example: Temperature varies smoothly throughout the day

Discrete (Sampled) Signal (Digital): - Values recorded at specific timestamps only - Finite time resolution - Example: Temperature recorded every 10 minutes

Key Sampling Concepts

Sampling Frequency (f_s) - How many samples per second (Hz) - Higher frequency = more samples = better resolution - Example: 10 Hz = 10 samples per second

Sampling Period / Time Step (Δt) - Time between consecutive samples (seconds) - Inverse of sampling frequency: Δt = 1/f_s - Example: 0.1 second time step = 10 Hz sampling

Relationship:

Sampling Frequency (Hz) = 1 / Time Step (seconds)
Time Step (seconds) = 1 / Sampling Frequency (Hz)

Examples:
1 Hz = 1 second time step
10 Hz = 0.1 second time step
0.1 Hz = 10 second time step

The Nyquist-Shannon Sampling Theorem

The Nyquist theorem is the fundamental rule for sampling oscillating signals.

Nyquist Frequency

Definition: The Nyquist frequency is half the sampling frequency:

f_Nyquist = f_sampling / 2

Nyquist Theorem Statement:

To accurately represent a signal, the sampling frequency must be at least twice the highest frequency component in that signal.

f_sampling ≥ 2 × f_max

Or equivalently:
f_max ≤ f_Nyquist

Why This Matters

Proper Sampling (f_sampling ≥ 2 × f_signal): - Signal accurately represented - Oscillations clear and correct - Can reconstruct original signal

Undersampling (f_sampling < 2 × f_signal): - Signal misrepresented (aliasing) - Oscillations appear at wrong frequency - Cannot reconstruct original signal

What is Aliasing?

Aliasing occurs when a signal is undersampled, causing it to appear as a different (lower) frequency in the sampled data.

Aliasing Example

Scenario: Sampling a 15 Hz signal at 20 Hz

Signal Frequency: 15 Hz
Sampling Frequency: 20 Hz
Nyquist Frequency: 10 Hz

15 Hz > 10 Hz → ALIASING OCCURS

Aliased Frequency: |15 - 20| = 5 Hz
The 15 Hz signal appears as a 5 Hz signal in the data!

[Screenshot Instructions: Aliasing Example] 1. Configure: - Mean: 0, Noise: 0 - Oscillation: Frequency=15 Hz, Amplitude=1 - Duration: 2 seconds, Sampling: 20 Hz 2. Preview (will show aliasing warning) 3. Capture: Chart showing apparent 5 Hz signal (not 15 Hz) 4. Compare with proper sampling (60 Hz) 5. Purpose: Visually demonstrate aliasing artifact

Visual Analogy: Wagon Wheel Effect

Aliasing is the same phenomenon as the "wagon wheel effect" in movies: - Wheel spins at high speed (high frequency) - Camera samples at fixed frame rate (sampling frequency) - Wheel appears to spin backwards or slowly (aliased frequency)

Aliasing Formula

When undersampling, the apparent frequency is:

f_alias = |f_signal - n × f_sampling|

Where n is chosen to make f_alias ≤ f_Nyquist

Most common case (n=1):
f_alias = |f_signal - f_sampling|

Phoenix Aliasing Detection

Phoenix automatically checks for aliasing and provides two levels of warnings:

Error Level (Red Badge)

Condition: Oscillation frequency > Nyquist frequency

Example:
Oscillation: 60 Hz
Sampling: 100 Hz
Nyquist: 50 Hz

60 Hz > 50 Hz → ERROR

Meaning: Definite aliasing will occur. The oscillation WILL be misrepresented.

Action Required: Increase sampling frequency or decrease oscillation frequency.

Warning Level (Yellow Badge)

Condition: Oscillation frequency > Nyquist/2

Example:
Oscillation: 35 Hz
Sampling: 100 Hz
Nyquist: 50 Hz

35 Hz > 25 Hz (Nyquist/2) → WARNING

Meaning: Approaching the Nyquist limit. While technically not aliased, you're in a risky zone with poor signal representation.

Action Recommended: Increase sampling frequency for better signal quality.

[Screenshot Required: Aliasing Warnings] 1. Configure to trigger error: - Oscillation: 60 Hz - Sampling: 100 Hz 2. Capture: Red error badge with aliasing message 3. Configure to trigger warning: - Oscillation: 35 Hz - Sampling: 100 Hz 4. Capture: Yellow warning badge 5. Purpose: Show Phoenix aliasing detection interface

Suggested Minimum Sampling

Phoenix calculates a suggested minimum sampling frequency:

Suggested f_sampling = 2.5 × f_oscillation

This provides a safety margin above the theoretical minimum (2×).

Proper Sampling Guidelines

The 2× Rule (Absolute Minimum)

Sample at at least 2× the highest frequency:

Signal: 30 Hz
Minimum Sampling: 2 × 30 = 60 Hz

This is the theoretical minimum to avoid aliasing.

Sample at 2.5× the highest frequency for better representation:

Signal: 30 Hz
Recommended Sampling: 2.5 × 30 = 75 Hz

Provides safety margin and better signal quality.

The 10× Rule (High Quality)

Sample at 10× the highest frequency for high-quality representation:

Signal: 30 Hz
High-Quality Sampling: 10 × 30 = 300 Hz

Used for critical applications or when signal shape details matter.

Multiple Oscillations

When signal has multiple frequencies, use the highest frequency:

Oscillations:
- 10 Hz, Amplitude: 3
- 30 Hz, Amplitude: 1
- 50 Hz, Amplitude: 0.5

Highest: 50 Hz
Minimum Sampling: 2 × 50 = 100 Hz
Recommended Sampling: 2.5 × 50 = 125 Hz

Common Sampling Scenarios

Slow Phenomena (Daily, Hourly)

Daily Temperature Cycle:

Oscillation Period: 86400 seconds (24 hours)
Frequency: 1/86400 ≈ 0.0000116 Hz

Minimum Sampling: 2 × 0.0000116 ≈ 0.000023 Hz
Recommended: 0.00003 Hz (1 sample every ~9 hours)
Practical: 0.000278 Hz (1 sample every 60 minutes)

For slow phenomena, practical considerations (data volume, storage) often dominate over Nyquist requirements.

Moderate Phenomena (Minutes, Seconds)

Process Control Loop (1-minute cycles):

Period: 60 seconds
Frequency: 1/60 ≈ 0.0167 Hz

Minimum: 2 × 0.0167 = 0.033 Hz (1 sample every 30 seconds)
Recommended: 0.042 Hz (1 sample every 24 seconds)
Practical: 0.1 Hz (1 sample every 10 seconds)

Fast Phenomena (Hz range)

Rotating Machinery at 1800 RPM:

Rotation Frequency: 1800/60 = 30 Hz

Minimum: 2 × 30 = 60 Hz
Recommended: 2.5 × 30 = 75 Hz
High Quality: 10 × 30 = 300 Hz

Very Fast Phenomena (kHz range)

Power Line at 60 Hz with harmonics up to 5th (300 Hz):

Highest Frequency: 300 Hz

Minimum: 2 × 300 = 600 Hz
Recommended: 2.5 × 300 = 750 Hz
High Quality: 10 × 300 = 3000 Hz

Note: Phoenix point limit (10,000 points) constrains high-frequency, long-duration signals.

Sampling Trade-offs

Higher Sampling Frequency

Advantages: - Better signal representation - Captures fast transients - Avoids aliasing - More data for analysis

Disadvantages: - More data points (hits 10,000 limit faster) - Larger file sizes - More processing required - May be unnecessary for slow signals

Lower Sampling Frequency

Advantages: - Fewer data points (longer durations possible) - Smaller files - Faster processing - Sufficient for slow phenomena

Disadvantages: - Risk of aliasing - Miss fast transients - Poor signal representation - Cannot capture high frequencies

Balancing Duration vs. Sampling

With Phoenix's 10,000-point limit, you must balance:

Total Points = Duration (seconds) × Sampling (Hz)

For 10 Hz sampling:
Maximum Duration = 10,000 / 10 = 1,000 seconds (16.7 minutes)

For 0.1 Hz sampling:
Maximum Duration = 10,000 / 0.1 = 100,000 seconds (27.8 hours)

Strategy: 1. Identify highest oscillation frequency needed 2. Calculate minimum sampling (2× or 2.5×) 3. Calculate maximum duration from point limit 4. Adjust as needed

Troubleshooting Aliasing Issues

Problem: Aliasing Error Appears

Symptoms: Red error badge, message indicates oscillation > Nyquist

Solutions (choose one):

Option 1: Increase Sampling Frequency

Current: Oscillation=50 Hz, Sampling=80 Hz → ERROR
Fix: Increase sampling to 125 Hz (2.5 × 50)

Option 2: Decrease Oscillation Frequency

Current: Oscillation=50 Hz, Sampling=80 Hz → ERROR
Fix: Reduce oscillation to 30 Hz (below Nyquist=40)

Option 3: Remove High-Frequency Oscillation

Current: 3 oscillations (10 Hz, 30 Hz, 50 Hz)
Fix: Remove the 50 Hz oscillation, keep 10 and 30 Hz
Adjust sampling for new maximum (30 Hz)

Problem: Aliasing Warning Appears

Symptoms: Yellow warning badge

Recommended Action: - Increase sampling frequency slightly (20-50% increase) - Provides better signal quality - Optional but recommended

Can Ignore If: - You understand the limitation - Signal quality sufficient for your use case - Point limit prevents higher sampling

Problem: Signal Looks Wrong/Choppy

Possible Cause: Sampling too low (aliased or poorly represented)

Check: 1. Look for aliasing warnings 2. Calculate: Is sampling ≥ 2.5× highest frequency? 3. Zoom in on chart - should see smooth sine waves

Fix: Increase sampling frequency

Problem: Can't Increase Sampling (Point Limit)

Cause: Higher sampling would exceed 10,000 points

Solutions:

Option 1: Reduce Duration

Problem: 1 hour at 100 Hz = 360,000 points
Fix: 100 seconds at 100 Hz = 10,000 points

Option 2: Use Lower Frequencies

Problem: Need 100 Hz sampling for 50 Hz signal
Fix: Use 20 Hz signal instead, sample at 50 Hz

Option 3: Use Fewer Channels (multi-channel)

Problem: 5 channels at 50 Hz for 1 hour = 900,000 points
Fix: 2 channels at 50 Hz for 1 hour = 360,000 points (still too high)
Fix: 2 channels at 10 Hz for 1 hour = 72,000 points (still too high)
Fix: 2 channels at 1 Hz for 1 hour = 7,200 points ✓

Advanced Sampling Topics

Anti-Aliasing Filters

In real systems, anti-aliasing filters (analog low-pass filters) remove high frequencies before sampling:

Real System:
Signal → Anti-Alias Filter → Sample at f_s

Phoenix (Synthetic):
No anti-aliasing needed (you control all frequencies)

Phoenix doesn't need anti-aliasing filters because you explicitly configure all frequency components.

Oversampling

Sampling well above 2× minimum is called oversampling:

Benefits: - Better signal representation - Captures transients - Easier digital filtering later - Reduces quantization noise effects

Example:

Signal: 10 Hz
Nyquist Minimum: 20 Hz
Oversampling: 100 Hz (10× signal, 5× minimum)

Downsampling

If you generate at high sampling rate, you can downsample later:

Generate: 1000 Hz sampling
Export and downsample: Keep every 10th point → 100 Hz

Phoenix doesn't have built-in downsampling, but you can do this in external tools.

Irregular Sampling

Phoenix generates regular (uniform) sampling intervals. Real-world data sometimes has irregular sampling:

Regular (Phoenix):
t = 0.0, 1.0, 2.0, 3.0, 4.0 seconds

Irregular (some real systems):
t = 0.0, 0.9, 2.1, 3.0, 4.2 seconds

Use Phoenix for regular sampling, then add irregularity externally if needed for testing.

Real-World Examples

Example 1: Motor Vibration Analysis

Scenario: Monitor motor at 1800 RPM for bearing defects

Analysis:

Motor Frequency: 30 Hz
Expected Harmonics: 60 Hz, 90 Hz, 120 Hz
Bearing Defects: Up to 200 Hz

Highest Frequency: 200 Hz
Minimum Sampling: 400 Hz
Recommended: 500 Hz (2.5×)
High Quality: 2000 Hz (10×)

Chosen: 500 Hz

Duration Limit:
Max Duration = 10,000 points / 500 Hz = 20 seconds

Configuration:

Duration: 10 seconds
Sampling: 500 Hz
Oscillation 1: 30 Hz (motor), Amplitude: 2
Oscillation 2: 60 Hz (2× harmonic), Amplitude: 0.5
Oscillation 3: 150 Hz (bearing tone), Amplitude: 0.3

Example 2: Temperature Monitoring

Scenario: Daily temperature variation over one week

Analysis:

Oscillation Period: 86400 seconds (24 hours)
Frequency: 0.0000116 Hz

Nyquist Minimum: 0.000023 Hz
Practical: 0.000278 Hz (1 sample per hour)

Duration: 7 days = 604,800 seconds
Points: 604,800 × 0.000278 = 168 points ✓

Configuration:

Duration: 7 days
Sampling: 0.000278 Hz (approx 1/hour)
Oscillation: Period=86400, Amplitude: 5°C
Mean: 20°C
Noise: 0.5°C

Example 3: Power Quality Monitoring

Scenario: 60 Hz power with 3rd and 5th harmonics

Analysis:

Fundamental: 60 Hz
3rd Harmonic: 180 Hz
5th Harmonic: 300 Hz

Highest: 300 Hz
Minimum: 600 Hz
Recommended: 750 Hz

Duration Limit:
Max = 10,000 / 750 = 13.3 seconds

Configuration:

Duration: 10 seconds
Sampling: 750 Hz
Oscillation 1: 60 Hz, Amplitude: 170 (peak voltage)
Oscillation 2: 180 Hz, Amplitude: 15
Oscillation 3: 300 Hz, Amplitude: 10

Quick Reference

Sampling Frequency Calculation

1. Find highest oscillation frequency (f_max)
2. Calculate minimum: f_min = 2 × f_max
3. Use recommended: f_recommended = 2.5 × f_max
4. Check point limit: Points = Duration × Sampling
5. Adjust duration or sampling if needed

Common Sampling Rates

Phenomenon              Typical Frequency    Sampling Rate
─────────────────────────────────────────────────────────
Daily cycles            0.00001 Hz           0.0001 Hz
Hourly cycles           0.0003 Hz            0.001 Hz
Slow process (minutes)  0.01 Hz              0.025 Hz
Fast process (seconds)  1 Hz                 2.5 Hz
Rotating machinery      10-100 Hz            25-250 Hz
Vibration analysis      100-1000 Hz          250-2500 Hz
Power systems           50-300 Hz            125-750 Hz
High-speed machinery    1-10 kHz             2.5-25 kHz*

* May exceed Phoenix point limits for reasonable durations

Aliasing Quick Check

✓ SAFE:  f_sampling ≥ 2.5 × f_oscillation
⚠ MARGINAL: 2.0 × f_osc ≤ f_sampling < 2.5 × f_osc
✗ ALIASED: f_sampling < 2.0 × f_oscillation

Summary

Key points for proper sampling in Phoenix:

  • Nyquist Theorem: Sample at least 2× the highest frequency
  • Recommended: Sample at 2.5× for safety margin
  • Aliasing: Occurs when undersampling, creates false frequencies
  • Phoenix Detection: Automatic warnings for aliasing issues
  • Trade-off: Balance sampling rate vs. duration within 10,000-point limit
  • Multiple Frequencies: Use highest frequency for sampling calculation

Next Steps


Understanding sampling and aliasing is essential for generating high-quality synthetic time series data that accurately represents real-world phenomena.