daily pastebin goal
12%
SHARE
TWEET

ajusteretas

a guest Aug 16th, 2018 180 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def reta(dados_x, dados_y):    
  2.     a = dados_y.cov(dados_x) / dados_x.var()
  3.     b = dados_y.mean() - a*dados_x.mean()
  4.  
  5.     print('Ajuste linear entre X3 e X4:')
  6.     print('Coeficiente linear:', b)
  7.     print('Coeficiente angular:', a)
  8.  
  9.     fig = plt.figure(figsize=(8, 6))
  10.     plt.scatter(dados_x, dados_y, c='red', alpha=0.8)
  11.     plt.title('x versus y')
  12.     plt.xlabel('eixo x')
  13.     plt.ylabel('eixo y')
  14.  
  15.     plt.plot((dados_x.min(), dados_x.max()), (a*dados_x.min()+b, a*dados_x.max()+b), color='blue')
  16.  
  17.     plt.tight_layout()
  18.     plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top