Python Forum

Full Version: Mechatronics Homework help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I was wondering if I could get some instruction on where to begin with this homework question I'm having difficulty understanding. I'll post a picture of the question but there are a few things I'm having trouble even getting started with so if I could get a walkthrough on where to at least get started with the code and a few helpful pointers I'll be very appreciative.
To begin, the HW08data.txt file. How can I get the file loaded into the program so I can assign the data to variables? Once I have the variables, which I believe is actually 16 points of (x,y) values. I know I need to run a while loop to calculate m for all 16 points and then use m to calculate r, this r value should be between 0 and 1. Once that value is calculated, I need to remove a point from the loop and recalculate r to see if it moves closer to 1, if it does I continue the loop up until it stops increasing closer to 1. So thats where I'm at and if I could at least get a framework on where to begin i think I can get an understanding of what to do. Thank you!
Here are the 2 pictures of the question
https://drive.google.com/file/d/1HsOZVlg...sp=sharing

https://drive.google.com/file/d/1l6EfDYY...sp=sharing

Here is the link for the HW08data.txt file.
https://drive.google.com/file/d/1nvSuJpZ...sp=sharing
Quote:How can I get the file loaded into the program so I can assign the data to variables
https://www.pythonforbeginners.com/files...-in-python
For the linear regression and other math, you can use numpy and matplotlib:
numpy: http://www.numpy.org/
matplotlib: https://matplotlib.org/

If you are required to do the math from scratch, here's a couple of sites:
linear regression: https://www.geeksforgeeks.org/linear-reg...mentation/
https://mubaris.com/posts/linear-regression/

getting the data loaded, just cut and paste into (between brackets, separated by comma's:
datapoints = []
Don't forget, google can find most anything!