Advertisement
Korotkodul

Laba_1.1.4

Apr 2nd, 2025 (edited)
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.48 KB | None | 0 0
  1. matrix20 = [
  2. [39, 41, 41, 21, 40, 26, 32, 31, 35, 43],
  3. [31, 37, 36, 39, 47, 27, 50, 49, 28, 45],
  4. [31, 37, 41, 40, 34, 37, 42, 22, 36, 34],
  5. [36, 45, 31, 41, 26, 37, 41, 33, 37, 31],
  6. [38, 27, 29, 39, 35, 42, 45, 32, 46, 31],
  7. [21, 26, 37, 47, 32, 38, 45, 32, 36, 24],
  8. [37, 37, 30, 33, 29, 42, 29, 34, 35, 38],
  9. [26, 51, 27, 29, 37, 26, 45, 33, 20, 34],
  10. [44, 45, 28, 33, 37, 31, 41, 43, 41, 33],
  11. [39, 41, 42, 30, 30, 46, 35, 30, 45, 39],
  12. [37, 40, 39, 41, 39, 41, 31, 35, 42, 39],
  13. [33, 37, 42, 40, 36, 29, 42, 32, 32, 29],
  14. [35, 30, 52, 49, 39, 40, 36, 30, 34, 41],
  15. [34, 47, 33, 45, 34, 44, 22, 29, 36, 33],
  16. [32, 30, 17, 38, 34, 32, 35, 38, 31, 35],
  17. [22, 39, 29, 28, 34, 36, 35, 36, 38, 44],
  18. [37, 35, 41, 35, 30, 31, 28, 46, 30, 37],
  19. [48, 40, 44, 41, 40, 33, 36, 32, 38, 22],
  20. [32, 43, 34, 45, 34, 46, 38, 38, 28, 39],
  21. [58, 26, 29, 41, 38, 38, 32, 39, 28, 35],
  22.     ]
  23. array = []
  24. for a in matrix20:
  25.   b = []
  26.   for i in range(5):
  27.     b.append(a[2 * i] + a[2 * i + 1])
  28.   array.append(b)
  29.  
  30. matrix40 = []
  31. for i in range(10):
  32.   a = []
  33.   for j in range(5):
  34.     a.append(cmp40[2 * i][j])
  35.   for j in range(5):
  36.     a.append(cmp40[2 * i + 1][j])
  37.   matrix40.append(a)
  38.  
  39. for a in matrix40:
  40.   print(a)
  41.  
  42.  
  43. from collections import Counter
  44.  
  45. t10 = []
  46. for a in matrix10:
  47.   for el in a:
  48.     t10.append(el)
  49.  
  50. t40 = []
  51. for a in matrix40:
  52.   for el in a:
  53.     t40.append(el)
  54. #print(t40)
  55.  
  56. table40 = sorted(Counter(t40).items(), key = lambda x: x[0])
  57.  
  58. data40 = []
  59. #print("TABLE 40")
  60. for p in table40:
  61.   #print(p[0], p[1], p[1] / len(t40))
  62.   data40.append(tuple( (p[0], p[1] / len(t40)) ))
  63. #print()
  64.  
  65.  
  66. """cnt = 0
  67. cases = []
  68. for i in range(24):
  69.  a, b = map(int, input().split())
  70.  cases.append(tuple( (a, b) ))
  71.  cnt += b
  72. print(cases)
  73. for p in cases:
  74.  print(p[0], p[1])
  75. print("cnt:", cnt)"""
  76.  
  77. cases = [(6, 2), (8, 4), (9, 8), (10, 9), (11, 20), (12, 12), (13, 19), (14, 26), (15, 27), (16, 28), (17, 37), (18, 37), (19, 28), (20, 26), (21, 23), (22, 22), (23, 11), (24, 19), (25, 10), (26, 13), (27, 7), (28, 6), (29, 2), (30, 2)]
  78. cnt = 400
  79.  
  80. data10 = []
  81. for p in cases:
  82.   data10.append(tuple( (p[0], p[1] / cnt) ) )
  83.  
  84. """
  85. print("DATA, t = 10")
  86. for p in data10:
  87.  print(p[0], p[1])
  88.  """
  89.  
  90. """
  91. print("DATA, t = 40")
  92. for p in data40:
  93.  print(p[0], p[1]) """
  94.  
  95. s10 = 0
  96. for p in data10:
  97.   s10 += p[0] * p[1] * 400
  98. n10 = s10 / 400
  99. #print("s10:", s10)
  100. #print("n10:", n10)
  101.  
  102. s40 = 0
  103. for p in data40:
  104.   s40 += p[0] * p[1] * 100
  105. n40 = s40 / 100
  106. #print("s40:", s40)
  107. #print("n40:", n40)
  108.  
  109. sigma10 = 0
  110. for p in data10:
  111.   sigma10 += p[1] * 400 * (p[0] - n10)**2
  112. sigma10 /= 400
  113. sigma10 = sigma10**0.5
  114. #print("sigma10:", sigma10)
  115.  
  116. sigma40 = 0
  117. for p in data40:
  118.   sigma40 += p[1] * 100 * (p[0] -  n40)**2
  119. sigma40 /= 100
  120. sigma40 = sigma40**0.5
  121. #print("sigma40:", sigma40)
  122.  
  123. sigma10_relative = sigma10 / 20
  124. sigma40_relative = sigma40 / 10
  125. #print("sigma10_relative:", sigma10_relative)
  126. #print("sigma40_relative:", sigma40_relative)
  127.  
  128. #print("n10**0.5:", n10**0.5)
  129. #print("n40**0.5:", n40**0.5)
  130.  
  131. diff10_relative = abs(sigma10 - n10**0.5) / sigma10
  132. diff40_relative = abs(sigma40 - n40**0.5) / sigma40
  133. #print("diff10_relative:", diff10_relative)
  134. #print("diff40_relative:", diff40_relative)
  135.  
  136. """
  137. cnt_in_sigma10 = 0
  138. cnt_in_2_sigma10 = 0
  139. for p in data10:
  140.  if abs(p[0] - n10) <= sigma10:
  141.    cnt_in_sigma10 += p[1] * 400
  142.  if abs(p[0] - n10) <= 2 * sigma10:
  143.    cnt_in_2_sigma10 += p[1] * 400
  144. cnt_in_sigma10_proportion = cnt_in_sigma10 / 400
  145. cnt_in_2_sigma10_proportion = cnt_in_2_sigma10 / 400
  146. print("cnt_in_sigma10:", cnt_in_sigma10)
  147. print("cnt_in_sigma10_proportion:",  cnt_in_sigma10_proportion)
  148. print("cnt_in_2_sigma10:", cnt_in_2_sigma10)
  149. print("cnt_in_2_sigma10_proportion:", cnt_in_2_sigma10_proportion)
  150. """
  151.  
  152. """
  153. cnt_in_sigma40 = 0
  154. cnt_in_2_sigma40 = 0
  155. for p in data40:
  156.  if abs(p[0] - n40) <= sigma40:
  157.    cnt_in_sigma40 += p[1] * 100
  158.  if abs(p[0] - n40) <= 2 * sigma40:
  159.    cnt_in_2_sigma40 += p[1] * 100
  160. cnt_in_sigma40_proportion = cnt_in_sigma40 / 100
  161. cnt_in_2_sigma40_proportion = cnt_in_2_sigma40 / 100
  162. print("cnt_in_sigma40:", cnt_in_sigma40)
  163. print("cnt_in_sigma40_proportion:",  cnt_in_sigma40_proportion)
  164. print("cnt_in_2_sigma40:", cnt_in_2_sigma40)
  165. print("cnt_in_2_sigma40_proportion:", cnt_in_2_sigma40_proportion)
  166. """
  167.  
  168. """
  169. e10_eq1 = sigma10_relative / n10
  170. print("e10_eq1:", e10_eq1)
  171. e10_eq2 = 1 / (n10 * 400)**0.5
  172. print("e10_eq2:", e10_eq2)
  173. """
  174. e40_eq1 = sigma40_relative / n40
  175. print("e40_eq1:", e40_eq1)
  176. e40_eq2 = 1 / (n40 * 100)**0.5
  177. print("e40_eq2:", e40_eq2)
  178.  
  179.  
  180.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement