Question
Linear Regression create a set of points like this ( all on one line ) p = [[0,3.8414709848078967],[0.6931471805599453,6.6818861490654635],[1.0986122886681098,7.5355691627323065],[1.3862943611198906,7.788374949171635],[1.6094379124341003,8.478827375073264],[1.791759469228055,9.887622378713294],[1.9459101490553132,11.440627194940042],[2.0794415416798357,12.307124413342725]] where: p[i][0] is an x value and
Linear Regression
create a set of points like this ( all on one line )
p = [[0,3.8414709848078967],[0.6931471805599453,6.6818861490654635],[1.0986122886681098,7.5355691627323065],[1.3862943611198906,7.788374949171635],[1.6094379124341003,8.478827375073264],[1.791759469228055,9.887622378713294],[1.9459101490553132,11.440627194940042],[2.0794415416798357,12.307124413342725]]
where:
p[i][0] is an x value
and p[i][1] is the corresponding y value
Find the least square curve that best matches these points using linear regression.
I need four outputs:
n = number of points
m = slope
b = y intercept
r = coefficient of regression.
formulas that might help:
n = p.length
m = (n* xy - x* y)/(n* xx - x* x)
b = ( y - m* x)/n
r = (n* xy - x* y)/sqrt((n* xx - x* x)*(n* yy- y* y))
PLEASE WRITE THE CODE IN NOTEPAD++ OR TEXTEDIT. WRITE IN JAVASCRIPT. MAKE SURE TO COPY AND PASTE CODE.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started