Course 3.2Lesson 5 of 5
A project that uses the whole chapter: a table of eight planets and Pluto, with the period of Neptune missing, is read, checked for missing values, cleaned by dropping the incomplete row, extended with a column for the ratio of the period squared to the distance cubed, which is about 1.0 with a spread of 0.016, and analysed with a straight line through the logarithms, whose slope is 1.5. The fitted law predicts the period of Neptune from its distance as 165.0 years, which is close to the true 164.8, and a graph on log-log scales shows all the points on a straight line. A good analysis reads, checks, cleans, derives, summarises, predicts and draws, and reports what it did at every step.
Try the code and the simulations beside the lesson.
After this lesson you can
You have a table of the planets: the distance from the Sun in AU and the period in years. There is also Pluto, a dwarf planet. One value is missing: the table does not say the period of Neptune. The questions are:
This is a small example of what a scientist does with data: read it, check it, clean it, calculate from it, find a law, make a prediction, and draw a picture, and say so clearly.
Predict first. Before you run it, what ratio do you expect for Pluto (39.5 AU, 248 years)? and .
1. Read and check. pd.read_csv(io.StringIO(text)) reads the table. The program prints the number of rows, 9, and the missing values in each column. The result shows exactly one missing value: the period of Neptune.
2. Clean. p.dropna() drops the row of Neptune, so 8 rows are left. We chose to drop it, and not to fill it with a guess, because we want to use Neptune as a test later. (If we had filled it, the prediction would not be a real test.) Note what you did: "one row with a missing period was removed".
3. Derive. p.assign(ratio=...) makes a new table with a new column, the ratio. (assign returns a new table and leaves the old one as it was.) The ratios are 0.971 for Mercury, 1.030 for Venus, 1.000 for Earth, 1.006 for Mars, 1.000 for Jupiter, 1.000 for Saturn, 0.999 for Uranus and 0.998 for Pluto.
4. Summarise. The mean of the ratio is 1.0 and the spread is 0.016. The law holds to about 2 percent. Look at which ones are farthest from 1: Mercury (0.971) and Venus (1.030). The table gives their numbers with only two digits, so a rounding error of a few percent is expected. The big planets, Jupiter to Pluto, agree to about a fifth of a percent.
5. Find the power. np.polyfit on the logarithms of the distances and the periods gives the slope 1.5: the power of the law is 3/2, found from the data alone. The data say , which is the same as .
6. Predict. Use the fitted law, , with the distance of Neptune, 30.07 AU. The prediction is 165.0 years. The real period of Neptune is 164.8 years. The prediction is correct to 0.1 percent. This is a test of the law with a body that was left out of the fit, and the law passes it. That is the main reason why the law is believed.
7. Draw. The picture shows the eight bodies on a log-log graph, with the fitted line. The points lie on the line, from Mercury at the lower left to Pluto at the upper right.
Neptune's real period is about 165 years. A prediction for a body left out of the fit is the honest test of the law.
A good analysis ends with a short report. For this project:
The table has 9 bodies. One period (Neptune) was missing, and the row was removed for the fit. For the other 8, the ratio has the mean 1.00 and the spread 0.016, so Kepler's third law holds to about 2 percent. A line fitted to the logarithms gives the power 1.50. The law predicts 165.0 years for Neptune, and the true value is 164.8 years.
Notice what is in it: the size of the data, what was cleaned, the numbers with their spreads, and the test. A reader can trust a report like this, and can repeat it.
Start with two quick questions. Each New numbers gives you a fresh one, so you can practise as long as you like.
Then the labs and the problems:
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Every lesson is open to read. Enrolling also lets you:
Log in to join the discussion.
Loading…
This lesson is free to read. Enroll free to keep your place and take the tests.