help with linear regression analysis

This is my last assignment of the year and i absolutely dont know how to start this program. I need to Write a program that uses linear regression to determine the equation of the straight line that best fits the data shown on the back of this page:
Number of data points: a
Mean value of Temperature (deg. F): a.aa
Mean value of Resistance (Ohms): a.aa
The equation of the best fit line is: y = (a.aa)x + a.aa
The R-squared value is: a.aaaa


The resistance characteristics of a thermistor can be found by placing it in an oven where its temperature can be varied while its resistance to electrical current is measured. One such exercise resulted in the following data:

Temperature(F) Resistance(Ohms)
100 13580
121 10430
139 7576
160 5328
182 3446
201 2308
220 1578
240 932
258 726
284 416
299 169


Also the following is required:
1) Write a function to load the arrays. Do not hardcode the number of data points (n) — count them as you load the arrays.
2) Pass the arrays to a second function that will calculate the slope, y-intercept and R-squared value of the best-fit straight line. (This will involve the summations.)
3) Write a third function that will return the average value of any array passed to it. (Call it twice to obtain Tavg, and Ravg.)
4) Write a fourth function to output the results to the console. Be sure to format your results very neatly and very clearly. Make it look professional:


In conclusion Im not looking for anyone to do this for me, i jus desperately need guidance!!
Last edited on
I think I'd start with number 1.
ok how would i do that??
Well about number 1 can you ask the user how many data points are there? because if not can you use vectors?
ok how would i do that??


Utilizing the IDE or editor of your choice, tap keys until you have some semblance of working code. When you do, present it here along with some commentary describing what it should be doing and what happens that makes you think it's not doing what it should be doing. Specific questions are welcome. "I'm not looking for anyone to this for me, but how do I write code?"... not so much.

It's your last assignment of the year. Surely you've been paying enough attention to know how to start.
Topic archived. No new replies allowed.