Advertisement
Savelyev_Vyacheslav

Math1

Mar 14th, 2022
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.92 KB | None | 0 0
  1.  
  2.  
  3.  
  4. import math
  5. def c(b, a):
  6.     a1 = math.factorial(a)
  7.     b1 = math.factorial(b)
  8.     c1 = math.factorial(a-b)
  9.     c = a1 / b1 / c1
  10.     return c
  11. def M(arX, ksi):
  12.     M = []
  13.     for i in range(0, len(arX)):
  14.         M.append(arX[i]*ksi[i])
  15.     return M
  16. def Msum(arX, ksi):
  17.     M = []
  18.     for i in range(0, len(arX)):
  19.         M.append(arX[i]*ksi[i])
  20.     return sum(M)
  21. def D(M_, arX, ksi):
  22.     D = []
  23.     for i in range(0, len(arX)):
  24.         out = ((ksi[i])-M_)**2 * arX[i]
  25.         D.append(out)
  26.     return D
  27. def Dsum(M_, arX, ksi):
  28.     D = []
  29.     for i in range(0, len(arX)):
  30.         out = ((ksi[i])-M_)**2 * arX[i]
  31.         D.append(out)
  32.     return sum(D)
  33. def sigma(Dx):
  34.     return Dx**0.5
  35. def MuXY(arX_,ksi_,ksiy, Dx, Dy):
  36.     ar = []
  37.     for item in ksiy:
  38.         for i in range(len(arX_)):
  39.             ar.append(arX_[i]*ksi_[i]*item)
  40.             i +=1
  41.     ar.append(-Dx*Dy)
  42.     return sum(ar)
  43. def rxy(MuXY,Sigx, Sigy):
  44.     rx = MuXY/Sigx/Sigy
  45.     return rx
  46.  
  47. # 1
  48. # Дано
  49.  
  50. arX_ = [0.35,0.27,0.33,0.05] # Дано
  51. ksi_ = [0,1,2,3]   # Дано
  52.  
  53. arY = [0.58,0.42] # Дано
  54. ksiy = [22,18]   # Дано
  55. pervoe = 1 # первое число равно ?
  56.  
  57.  
  58. MuXY = MuXY(arX_,ksi_,ksiy, 0.8736, 3.897)
  59. print("MuXY - ", MuXY)
  60.  
  61. # Формулы функции
  62. M_ = Msum(arX_, ksi_)
  63. print("Матожидан =", M_)
  64. D_= Dsum(M_,arX_,ksi_) # массив
  65. print("Дисперсия = ",D_)
  66. Sig = sigma(D_)
  67. print("Сигма = ",Sig)
  68. rxy = rxy(MuXY,0.934, 1.97)
  69. print("rx = ", rxy)
  70.  
  71.  
  72.  
  73.  
  74. # 2
  75. # импортируем модули
  76. import numpy as np
  77. import math
  78. import matplotlib.pyplot as plt
  79. from numpy import arange, exp
  80. ##a=0
  81. ##b=2
  82. ##def fx(x):
  83. ##    y = 1 - (b-x)**2/(b-a)**2
  84. ##    return y
  85. ##print(fx(0))
  86. ##print(fx(2))
  87. ##def fx2(x):
  88. ##    y = +1/2*x**2 - 1/12*x**3
  89. ##    return y
  90. ##print(fx2(0))
  91. ##print(fx2(2))
  92. ##x = np.linspace(0, 2,10)
  93. #plt.plot(x, fx2(x))
  94. #plt.show()
  95.  
  96.  
  97. ##
  98. ##
  99. ##def x025(x):
  100. ##    return 0.25*x**2
  101. ##x025(1.5) - x025(-0.5)
  102. ##
  103. ##
  104. ##
  105. ##
  106. ##
  107. ##def x025_(x):
  108. ##    return (1/6)*x**3
  109. ##x025_(1.5) - x025_(-0.5) -0.5**2
  110. def graf(x,y):
  111.     plt.plot(x, y)
  112. a=6.4
  113. k = -0.3125/6.4
  114. b = 0.3125
  115. def fx_(x):
  116.     return k*x+b
  117. def fxInt(x):
  118.     return (k*x**2)/2+b*x
  119. def fxMx(x):
  120.     return (k*x**3)/3+b*x**2/2
  121. def fxDx(x):
  122.     return (k*x**4)/4 + b*x**3/3 - 2.13**2
  123. def expP(x):
  124.     return 1-exp(-x*3)
  125. def expInt(x):
  126.     return x+exp(-3*x)/3-1/3
  127.  
  128. x = np.linspace(-1, 100,1)
  129. x_= arange(0,2.3333,0.01)
  130. fx_(x)
  131. graf(x_,expInt(x_))
  132. graf(x_,expP(x_))
  133.  
  134. #S = fxInt(0) - fxInt(a)
  135. #S = fxMx(0) - fxMx(a)
  136. #S = fxDx(0) - fxDx(a)
  137. S = expInt(0.81)
  138.  
  139. print(S)
  140. #graf(x,fx_(x))
  141. #graf(x,fxInt(x))
  142. #graf(x,fxMx(x))
  143. #graf(x,fxDx(x))
  144. #plt.show()
  145. #######################################4-5
  146.  
  147.  
  148.  
  149. def laplasX(Dsig, predel): ##потом по табличному значению https://math.semestr.ru/corel/table-laplas.php
  150.     return predel / Dsig
  151.    
  152.  
  153.  
  154. plt.show()
  155.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement