Нужно переделать под паскаль x=[]
y=[]
nmax=50
with open ('5.txt') as f:
for line in f:
data=list(map(float, line.split()))
x.append(data[0])
y.append(data[1])
x_sr=0
y_sr=0
sigma=0
for i in range(nmax-1):
sigma+=abs(y[i]-y[i+1])
sigma/=nmax
for i in range(nmax):
x_sr=x_sr+x[i]
y_sr=y_sr+y[i]
x_sr=x_sr/nmax
y_sr/=nmax
sum1=sum2=0
for i in range(nmax):
sum1=sum1+(x[i]-x_sr)*(y[i]-y_sr)
sum2=sum2+(x[i]-x_sr)*(x[i]-x_sr)
k=0
k=sum1/sum2
b=0
b=y_sr-k*x_sr
print('y =',k,'x +',b)
k=0
for i in range(nmax-2):
if (abs(y[i]-y[i+1])>3*sigma)and(abs(y[i+1]-y[i+2])>3*sigma):
print('x =',x[i+1],' y =',y[i+1])
x[i+1]=0
y[i+1]=0
k+=1

x_sr=0
y_sr=0
for i in range(nmax):
x_sr=x_sr+x[i]
y_sr+=y[i]
nmax-=k
x_sr/=nmax
y_sr/=nmax
sum1=sum2=0
for i in range(nmax):
sum1=sum1+(x[i]-x_sr)*(y[i]-y_sr)
sum2=sum2+(x[i]-x_sr)*(x[i]-x_sr)
k=0
k=sum1/sum2
b=0
b=y_sr-k*x_sr
print('y =',k,'x +',b)

analekss analekss    2   04.06.2020 16:06    1

Другие вопросы по теме Информатика