Симченко Сергей Александрович N2

Материал из Wiki
Перейти к: навигация, поиск

import numpy as np import math f = open("order.txt", "r") X = [] Y = [] for line in f:

   q, x1, x2, x3, x4, x5, x6, y = map(float, line.split())
   x = []
   x.append(x1)
   x.append(x2)
   x.append(x3)
   x.append(x4)
   x.append(x5)
   x.append(x6)
   x.append(x1 * x1)
   x.append(x1 * x2)
   x.append(x1 * x3)
   x.append(x1 * x4)
   x.append(x1 * x5)
   x.append(x1 * x6)
   x.append(x2 * x2)
   x.append(x2 * x3)
   x.append(x2 * x4)
   x.append(x2 * x5)
   x.append(x2 * x6)
   x.append(x3 * x3)
   x.append(x3 * x4)
   x.append(x3 * x5)
   x.append(x3 * x6)
   x.append(x4 * x4)
   x.append(x4 * x5)
   x.append(x4 * x6)
   x.append(x5 * x5)
   x.append(x5 * x6)
   x.append(x6 * x6)
   X.append(x)
   Y.append(y)

f.close() Mx = [] for j in range(27):

   Mx1 = np.sum(X[j]) / len(X)
   Mx.append(Mx1)

My = np.sum(Y)/len(Y) print(Mx) print("Mx =", Mx) Dx = [] Dx11 = 0 Dy = 0 for i in range(len(X)):

   Dy += (Y[i] - My) ** 2

for i in range(27):

   Dxs = 0.0
   for j in range(len(X)):
       Dxs += (X[j][i] - Mx[i]) ** 2
   Dx.append(Dxs/len(X))

print("Dx =", Dx) kx = [] for i in range(27):

   kxs = 0.0
   for j in range(len(X)):
       kxs += ((X[j][i] - Mx[i]) * (Y[j] - My))
   kx.append(kxs)

print("kx=", kx) r = [] rABS = [] for i in range(len(kx)):

   r1 = (kx[i] / (len(X)-1)) / (math.sqrt(Dx[i]) * math.sqrt(Dy))
   r.append(r1)
   rABS.append(math.fabs(r1))

print("r= ", r, len(r)) print(np.max(rABS)) print("Первый иднекс = ", rABS.index(np.max(rABS)) + 1) phi = rABS.index(np.max(rABS)) kxxp = [] rp1 = [] for i in range(27):

   if i != phi:
       kxsp = 0.0
       for j in range(len(X)):
           kxsp += ((X[j][i] - Mx[i]) * (X[j][phi] - Mx[phi]))
       kxxp.append(kxsp)

print("KxP1 = ", kxxp, len(kxxp)) for i in range(len(kxxp)):

       r11 = (kxxp[i] / (len(X)-1)) / (math.sqrt(Dx[i]) * math.sqrt(Dx[phi]))
       rp1.append(r11)

print("rP1 = ", rp1, len(rp1)) poo = [] pABS = []

for i in range(len(kxxp)):

       po = (r[i]-r[phi] * rp1[i])/(math.sqrt((1 - (r[phi] ** 2)) * (1 - (rp1[i] ** 2))))
       poo.append(po)
       pABS.append(math.fabs(po))

print(poo, len(poo)) print("Ro1 = ", pABS) print(np.max(pABS)) print("Второй иднекс = ", pABS.index(np.max(pABS))) hi = pABS.index(np.max(pABS)) print(hi) kxxpp = [] rp2 = [] for i in range(26):

   if i != hi:
       kxsp = 0.0
       for j in range(len(X)):
           kxsp += ((X[j][i] - Mx[i]) * (X[j][hi] - Mx[hi]))
       kxxpp.append(kxsp)

print("KxP2 = ", kxxpp, len(kxxpp))

for i in range(len(kxxpp)):

       r12 = (kxxpp[i] / (len(X)-1)) / (math.sqrt(Dx[i]) * math.sqrt(Dx[hi]))
       rp2.append(r12)

print("rP2 = ", rp2, len(rp2)) poo2 = [] pABS2 = []

for i in range(len(kxxpp)):

   po2 = (poo[i]-poo[hi] * rp2[i])/(math.sqrt((1 - (poo[hi] ** 2)) * (1 - (rp2[i] ** 2))))
   poo2.append(po2)
   pABS2.append(math.fabs(po2))

print("Ro2 = ", poo2) print(np.max(pABS2)) print("Третий иднекс = ", pABS2.index(np.max(pABS2)))


pci = pABS2.index(np.max(pABS2)) NX =[]

for i in range(len(X)):

   nx = []
   nx.append(1)
   nx.append(X[i][phi])
   nx.append(X[i][hi+1])
   nx.append(X[i][11])
   NX.append(nx)

print(NX) mx = np.matrix(NX) B1 = np.matmul(np.transpose(mx), mx) B2 = np.matmul(np.linalg.inv(B1), np.transpose(mx)) B = np.matmul(B2, Y) print(B)


[1334.18, 918.92, 668.16, 2043.48, 717.22, 842.16, 548.82, 1680.96, 2531.5, 1410.28, 1285.9, 753.14, 300.08, 857.4, 1008.1, 622.32, 587.74, 2295.62, 865.58, 797.32, 1728.48, 599.98, 1901.18, 1006.02, 1755.24, 877.06, 1086.5]

Mx = [1334.18, 918.92, 668.16, 2043.48, 717.22, 842.16, 548.82, 1680.96, 2531.5, 1410.28, 1285.9, 753.14, 300.08, 857.4, 1008.1, 622.32, 587.74, 2295.62, 865.58, 797.32, 1728.48, 599.98, 1901.18, 1006.02, 1755.24, 877.06, 1086.5]

Dx = [1659258.1155999997, 754443.9304, 379602.43519999995, 3961540.3232000005, 449808.15560000023, 635512.8047999997, 14138395.549199998, 6166171.7336, 5880905.65, 5249955.5592, 5365614.194000002, 5789465.8035999965, 21136843.943200003, 10309052.828, 9864509.986, 8430312.786400001, 8533613.187600002, 10426114.358800001, 10471508.498000002, 9124746.9816, 5074529.4368, 17810661.261200003, 3852981.4899999993, 8255880.387600002, 8374177.3664, 4688800.792399999, 10117382.17]

kx= [-2776631.077800071, -11323.659000057727, -2735901.143200034, 3105383.4707999006, -11160997.33720005, 2315010.113599949, -273350159.7777998, -58983768.219, -301590411.4512, 39447842.285800055, -683243134.0051999, 348329.1580000855, -32212932.626199804, -201659940.13939995, 155491144.33280015, -594381813.9689999, 109825695.22500008, -326175185.54639995, 20186866.695600104, -743100160.9481997, 28495753.510400046, 336702932.01880014, -420651751.0204, 267864778.1958001, -1068006106.8863999, -409266213.3656, 222422589.25959998]

r= [-0.0007446489161933638, -4.503639866226383e-06, -0.0015340031899526577, 0.0005389811210388624, -0.0057488330751216616, 0.0010031851544639405, -0.025113637718238133, -0.008205689190284362, -0.042962127592449856, 0.005947518428501872, -0.10189571280879187, 5.001047047484491e-05, -0.0024204747166797435, -0.021697045918858165, 0.017102447191693397, -0.07071866043526835, 0.01298756820434501, -0.03489635230329191, 0.002155036583942118, -0.08498206828597968, 0.004369911222963678, 0.027561143546511683, -0.07403116717027007, 0.032205071833952055, -0.1274949594679776, -0.06529280992029947, 0.02415656458240398] 27 0.1274949594679776

Первый индекс = 25

KxP1 = [-79506220.36, -53805610.000000015, -37358587.239999995, -124156252.63999999, -37995638.63999999, -49823076.88000001, 179866345.23999998, 50995362.60000001, 55411610.76000001, 26068662.360000007, 235466232.96, 68726020.2, 217763610.96000004, 167514617.12, 72384806.56, 293511694.00000006, 92516579.60000001, 174868426.52000004, 124359416.32000002, 343064884.16, 39385415.28000001, 97668676.96000001, 165511347.12000003, 38069917.96000001, 212948213.28, 59381811.91999998]

rP1 = [-0.4352882811706083, -0.4368646633446207, -0.4276207708101426, -0.4399156355268059, -0.3995332502453671, -0.440759045674489, 0.3373515335626213, 0.14482906220819677, 0.16114302474751857, 0.08023683254673793, 0.7168887369838249, 0.20143493434795184, 0.3340396972170328, 0.3679392924712604, 0.16253335576842676, 0.7129127915795442, 0.22334998829844832, 0.3819293226001716, 0.2710234645738416, 0.8009376207227143, 0.1233020744806429, 0.1632105112455183, 0.5946510014165292, 0.09344005539753297, 0.5189622470991122, 0.19339952213264006] 26 [-0.06298458549173727, -0.06243375392962137, -0.06251915017475687, -0.06236375455268047, -0.06234598188909586, -0.061991871562410504, 0.019167882791482262, 0.010453917781259191, -0.022900942265358486, 0.016363173573288228, -0.015178659078068582, 0.026486594817603203, 0.042966436339393094, 0.027338622401860684, 0.03864977324493508, 0.029005404534484927, 0.042888152127402344, 0.01505233196077994, 0.03845029157529726, 0.02885090171432413, 0.020411361114511997, 0.04943044272969443, 0.0022370041739808912, 0.04467667393055186, -0.07233822191417215, -0.04175807928693842]

Ro1 = [0.06298458549173727, 0.06243375392962137, 0.06251915017475687, 0.06236375455268047, 0.06234598188909586, 0.061991871562410504, 0.019167882791482262, 0.010453917781259191, 0.022900942265358486, 0.016363173573288228, 0.015178659078068582, 0.026486594817603203, 0.042966436339393094, 0.027338622401860684, 0.03864977324493508, 0.029005404534484927, 0.042888152127402344, 0.01505233196077994, 0.03845029157529726, 0.02885090171432413, 0.020411361114511997, 0.04943044272969443, 0.0022370041739808912, 0.04467667393055186, 0.07233822191417215, 0.04175807928693842] 0.07233822191417215

Второй индекс = 24

KxP2 = [-79506220.36, -53805610.000000015, -37358587.239999995, -124156252.63999999, -37995638.63999999, -49823076.88000001, 179866345.23999998, 50995362.60000001, 55411610.76000001, 26068662.360000007, 235466232.96, 68726020.2, 217763610.96000004, 167514617.12, 72384806.56, 293511694.00000006, 92516579.60000001, 174868426.52000004, 124359416.32000002, 343064884.16, 39385415.28000001, 97668676.96000001, 165511347.12000003, 38069917.96000001, 212948213.28]

rP2 = [-0.4352882811706083, -0.4368646633446207, -0.4276207708101426, -0.4399156355268059, -0.3995332502453671, -0.440759045674489, 0.3373515335626213, 0.14482906220819677, 0.16114302474751857, 0.08023683254673793, 0.7168887369838249, 0.20143493434795184, 0.3340396972170328, 0.3679392924712604, 0.16253335576842676, 0.7129127915795442, 0.22334998829844832, 0.3819293226001716, 0.2710234645738416, 0.8009376207227143, 0.1233020744806429, 0.1632105112455183, 0.5946510014165292, 0.09344005539753297, 0.5189622470991122]

Ro2 = [-0.10521121025550913, -0.1048136931971474, -0.10365296460104942, -0.10515563369714033, -0.09979854050045422, -0.10485685480684008, 0.04640612802018981, 0.021209188522782474, -0.011422963601053113, 0.022297481808092927, 0.05274928229613816, 0.04202736920015787, 0.07140837467741024, 0.05817758930648912, 0.051220630978477226, 0.11520511723259053, 0.0607342368582472, 0.046302663546079516, 0.06047142278180437, 0.14533210230123292, 0.029633989355312956, 0.06223210667100266, 0.05643379763974496, 0.051797689084524874, -0.0408153190905274]


Третий индекс = 19

[[1, 3481.0, 1770.0, 1680.0], [1, 256.0, 1200.0, 1125.0], [1, 36.0, 282.0, 799.0], [1, 4761.0, 6417.0, 7626.0], [1, 400.0, 740.0, 1776.0], [1, 2601.0, 1479.0, 1276.0], [1, 6724.0, 1312.0, 48.0], [1, 1.0, 12.0, 948.0], [1, 5476.0, 7252.0, 3332.0], [1, 4225.0, 520.0, 768.0], [1, 49.0, 602.0, 4558.0], [1, 5476.0, 2146.0, 116.0], [1, 1296.0, 684.0, 570.0], [1, 5329.0, 2628.0, 1044.0], [1, 6241.0, 5372.0, 5712.0], [1, 484.0, 1100.0, 2900.0], [1, 81.0, 144.0, 112.0], [1, 5929.0, 3542.0, 3312.0], [1, 324.0, 540.0, 1050.0], [1, 2809.0, 212.0, 288.0], [1, 3600.0, 3540.0, 5782.0], [1, 6241.0, 2133.0, 648.0], [1, 361.0, 1634.0, 8514.0], [1, 729.0, 2079.0, 462.0], [1, 49.0, 609.0, 6612.0], [1, 2704.0, 4628.0, 178.0], [1, 2209.0, 752.0, 800.0], [1, 529.0, 690.0, 1890.0], [1, 1521.0, 2652.0, 5712.0], [1, 3844.0, 4526.0, 511.0], [1, 1024.0, 64.0, 56.0], [1, 4225.0, 130.0, 194.0], [1, 1444.0, 380.0, 600.0], [1, 121.0, 572.0, 3016.0], [1, 7744.0, 1144.0, 1027.0], [1, 7396.0, 4816.0, 3976.0], [1, 4761.0, 4692.0, 612.0], [1, 5625.0, 2475.0, 1353.0], [1, 1225.0, 1645.0, 3149.0], [1, 4.0, 154.0, 1155.0], [1, 3969.0, 4536.0, 1224.0], [1, 9025.0, 4180.0, 2376.0], [1, 1296.0, 1944.0, 2592.0], [1, 625.0, 1300.0, 260.0], [1, 1.0, 55.0, 1705.0], [1, 5041.0, 0.0, 0.0], [1, 2116.0, 1196.0, 1664.0], [1, 6889.0, 4316.0, 2496.0], [1, 7744.0, 3344.0, 1102.0], [1, 1681.0, 3198.0, 1404.0]]

[-140.81971322 -3.335835 0.49445777 -0.29292457]

Персональные инструменты
Пространства имён

Варианты
Действия
Навигация
Инструменты