Пример #1
0
def getAvgTime(delta, n, W, d_type=False):
    f = c.correlation if (d_type) else c.correlation_dict
    t = []
    N = []
    for i in range(delta):
        amount = int(10 * (i + 1))
        N.append(amount)
        x = rsg.getRandomSignal(n, W, amount)
        y = rsg.getRandomSignal(n, W, amount)
        start = time.perf_counter()
        f(x, y)
        stop = time.perf_counter()
        t.append(stop - start)
    average = sum(t) / delta
    return N, t, average
Пример #2
0
def getAvgTime(delta, n, W, myFn=True):
    fn = f.f if (myFn) else fft.fft
    t = []
    N = []
    for i in range(delta):
        amount = int(10 * (i + 1))
        N.append(amount)
        x = rsg.getRandomSignal(n, W, amount)
        start = time.perf_counter()
        fn(x)
        stop = time.perf_counter()
        t.append(stop - start)
    average = sum(t) / delta
    return N, t, average
Пример #3
0
def compareTime(n, W, N):
    my = 0.0
    nump = 0.0
    for i in range(10):
        s = rsg.getRandomSignal(n, W, N)
        start = time.perf_counter()
        f.f(s)
        stop = time.perf_counter()
        my += (stop - start)
        start = time.perf_counter()
        np.fft.fft(s)
        stop = time.perf_counter()
        nump += (stop - start)
    return my, nump
Пример #4
0
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import rsg
import correlation as corr
import additionalTask as at

n = 12
W = 2400
N = 1024
time = range(N)
x = rsg.getRandomSignal(n, W, N)
y = rsg.getRandomSignal(n, W, N)

list_N, list_T, list_avg = at.getAvgTime(50, n, W)
dict_N, dict_T, dict_avg = at.getAvgTime(50, n, W, True)

print('time for list - ' + str(list_avg) + ', time for dict - ' +
      str(dict_avg))

autocorrelation = corr.selfcorrelation(x)
correlation = corr.correlation(x, y)

corrR = list(range(int(N / 2)))

fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1)
plt.subplots_adjust(left=0.05, bottom=0.1, right=0.97, wspace=0.1)
fig.suptitle('Lab 1.2')

ax1.plot(x, color='r', label='s 1')
ax1.plot(y, color='g', label='s 2')
Пример #5
0
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import rsg
import f
import additionalTask as at

n = 12
W = 2400
N = 1024
time = range(N)
signal = rsg.getRandomSignal(n, W, N)

s = f.f(signal)
my, nump = at.compareTime(n, W, N)
print("my fft: ", my, ", numpy fft: ", nump)

fig, (ax1, ax2) = plt.subplots(2, 1)
fig.suptitle('Lab 2.2')

ax1.plot(signal, linewidth=0.8)
ax1.set_title('Generated signal')
ax1.set(xlabel='time', ylabel='generated signal')

ax2.plot(s, color='r', linewidth=0.8)
ax2.set_title('Fast Fourier transform')
ax2.set(xlabel='p', ylabel='F(p)')

fig.savefig("lab2.2.png")

plt.show()