17 Jan 12:07
import math
import numpy as np
import matplotlib.pyplot as plt
tau_0 = 0.01
numbers = []
time = []
results = []
file1 = open("pomiary2.txt", "r")
lines = file1.readlines()
temp = 0
for line in lines:
temp+=1
line = line.strip()
line = float(line)
line = line - 50000
numbers.append(line*0.00000001)
file1.close()
for i in range(1, len(numbers)):
if numbers[i-1] > 0:
numbers[i] += 1
if numbers[i-1] < 0:
if numbers[i] > 0:
numbers[i] -= 1
#n =3
N = len(numbers)
end = N/4
file2 = open("wyniki.txt", "a")
for n in range(3, round(end), 10):
sum = 0
temp = 0
for i in range(0, N-2*n):
sum+=pow(numbers[i+2*n]- 2*numbers[i+n]+numbers[i], 2)
temp = sum/(2* pow(n, 2) * pow(tau_0, 2) * (N - 2 * n))
temp = math.sqrt(temp)
results.append(temp)
time.append(n*tau_0)
file2.close()
numbers = np.loadtxt("wyniki.txt", usecols=0, dtype=float)
plt.loglog(time, results)
plt.xlabel('log(\u03C4)')
plt.ylabel("log(ADEV)")
plt.grid()
plt.show()