Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linear Regression Python
# Author: Ice Script # Date: 10/4/20 # Description: # The python version of https://rextester.com/OBJTUO16392 # Tried using "^2" for some of the equations but it caused # Problems, (Probably should try converting some number into an int) data = [ # Age and BG number [25, 75], [27, 70], [30, 78], [33, 90], [40, 100], [50, 120], [52, 110], [54, 106], [60, 120] ] n = len(data) xSum = 0 ySum = 0 xxSum = 0 yySum = 0 xySum = 0 for i in range(n): xSum += data[i][0] ySum += data[i][1] xxSum += data[i][0]*data[i][0] yySum += data[i][1]*data[i][1] xySum += data[i][0]*data[i][1] div = (n*xxSum) - (xSum*xSum) a = ( (ySum*xxSum)-(xSum*xySum) )/div b = ( (n*xySum)-(xSum*ySum) )/div print(a, b, div) print() for i in range(20, 100): solution = (int)( (a + b*i)*100 )/100 print("Age: " + str(i), "BG: " + str( solution ) )
run
|
edit
|
history
|
help
0
Add missing person
Simple calculator
shuru12
Python3: Class I : Person (Simple)
RCM Distributor info.
calcultion
PyMenuClass
HW Descending order Insertion Sort
PyISP
reduce lambda