Question:
I am simulating a signal with numpy.sin in python, and i wanna simulate different sampling frequencies, the code is as follows:Answer:
Wheni
is 101, f * linear
is [0.0, 0.5, 1.0, 1.5, ...]
, so the expression np.sin(2 * np.pi * f * linear)
is sampling the sin
function at multiples of pi
. If you were working with infinite precision, the values would all be 0. These sample points, however, will not be exact multiples of pi
, because of normal floating point imprecision, so the values returned by that expression should be close to 0, but they won’t necessarily be exactly 0.If you have better answer, please add a comment about this, thank you!