<jupyter_start><jupyter_text>Sampling of Sinusoid* continuos sinusoid $x(t)$를 * $T_s$로 sampling 할 경우* **discrete sinusoid** $x[n]$을 얻음.$$\begin{align}x[n] &= x(nT_s)\\&= A \cos{(\omega n T_s)} \\&= A \cos{(\omega T_s n )} \\&= A \cos{ \Omega_0 n } \\\end{align}$$where,* $\Omega_0$ : 단위는 rad이며, 해당 discrete sinusoid $x[n]$의 angular freq.* $A$ : AmplitudeNote that * units of $\Omega_0$ is just **rad**, whereas units of $\omega_0$ is **rad/sec**.* $\Omega_0$ don't have any temporal information,(units: **rad**). * So, $x[n]$ is just a series(or list) of numbers.<jupyter_code>import numpy as np
import math
import matplotlib.pyplot as plt
import sys
from IPython.display import display, Markdown

t = np.arange(-1.*math.pi/4.,math.pi/2+0.01,0.001)
n = np.arange(-5,11)
A = 1

epsilon = sys.float_info.epsilon
def sinu(A,freq,n,Ts=None):
    if Ts is None:
        return A*np.cos(freq*t)
    return A*np.cos(Ts*freq*n)



freq = np.pi
Ts = 0.2
dsinu00 = sinu(A,freq,n,Ts)
sinu00 =  sinu(A,freq,t)

freq = 2.*np.pi
Ts = 0.1
dsinu01 = sinu(A,freq,n,Ts)
sinu01 =  sinu(A,freq,t)

freq = 4.*np.pi
Ts = 0.05
dsinu02 = sinu(A,freq,n,Ts)
sinu02 =  sinu(A,freq,t)

#plfigure()
plt.plot(t,sinu00,t,sinu01,t,sinu02)
plt.title='continuous'
plt.legend(('f=pi,ts=0.2','f=2pi,ts=0.1','f=4pi,ts=0.05'),loc='upper right')
plt.show()

#if np.all(dsinu00 == dsinu01) and np.all(dsinu01 == dsinu02) :
if np.all(np.isclose(dsinu00,dsinu01)) and np.all(np.isclose(dsinu00,dsinu02)) :
    display(Markdown('However, all discrete sinosoids are the same.'))
    display(Markdown('Becuase $\Omega_0$s are all the same!'))<jupyter_output><empty_output><jupyter_text>* 즉, sampling에 의해 $\Omega_0$의 discrete sinusoid를 만들 수 있는 continuous sinusoid는 무수히 많음. ($\Omega_0 = T_s\omega_0$이기 때문.)* 이는 discrete sinusoid에서 sampling 전의 continuous sinusoid를 복원할 때 문제가 됨. Even if the sampling interval, $T_s$ is known, **alias** problem remains.<jupyter_code>Ts = 0.8

freq = np.pi
dsinu00 = sinu(A,freq,n,Ts)

freq = 1.5*np.pi
dsinu01 = sinu(A,freq,n,Ts)

freq = 6.*np.pi
dsinu02 = sinu(A,freq,n,Ts)

#if np.all(abs(dsinu00-dsinu01) < 1e-10 ) and np.all(abs(dsinu00-dsinu02) < 1e-10):
if np.all(np.isclose(dsinu00,dsinu01)) and np.all(np.isclose(dsinu00,dsinu02)) :
    display(Markdown('Even if $T_s$ is known, $\Omega_0$ can be the same!'))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18447018447018448, 'fraction_numerical': 0.04676104676104676, 'mean_word_length': 4.786600496277916, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '33192', 'license': 'MIT', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1086, 'n_words': 226, 'path': '_posts/SS/07_00_sampling_of_sinusoids.ipynb', 'repo_name': 'dsaint31x/minimal-mistakes', 'size': '2331'}