<jupyter_start><jupyter_text>Problem 3 (b) from preparation exercises for partial exam 2 Sampling of a 60Hz sinusoidal noise signal<jupyter_code>%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import Math

h = 0.25 # Sampling time
ws = 2*np.pi/h
wN = ws/2
w1 = 120*np.pi
w1Alias = np.abs( (w1+wN) % ws - wN)  # 0
print w1Alias

T = 2*np.pi/w1 # Period of sinusoid

t = np.linspace(0,30*T, 1200)
y1 = np.cos(w1*t)
ya = np.cos(w1Alias*t)

ts = np.arange(3)*h
y1Sampled = np.cos(w1*ts)
yaSampled = np.cos(w1Alias*ts)

plt.figure()
plt.plot(t, y1, 'b')
plt.plot(t, ya, 'r')
plt.plot(ts, y1Sampled, 'bo', markersize=10)
plt.stem(ts, yaSampled, linefmt='r--', markerfmt='ro', basefmt = 'r-')
plt.xlabel('t [seconds]')
plt.xlim(-0., 0.5)
plt.ylim(-1.2, 1.2)

plt.show()<jupyter_output>1.42108547152e-14
{'fraction_non_alphanumeric': 0.17023809523809524, 'fraction_numerical': 0.06904761904761905, 'mean_word_length': 4.532894736842105, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '631175', 'license': 'MIT', 'n_tokens_mistral': 428, 'n_tokens_neox': 386, 'n_words': 90, 'path': 'misc-notebooks/MR2007-partial-exam-2-spring-2016.ipynb', 'repo_name': 'kjartan-at-tec/mr2007-computerized-control', 'size': '840'}