Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Hello, and welcome to Code Clinic. My name is David Powers. Code Clinic is a monthly course where unique a problem is introduced to a collection of lynda.com authors. In response, each author creates a solution, using the programming language of their choice. In my case, I'll be using PHP. You can learn several things from Code Clinic. Different approaches to solving the problem, the pros and cons of different languages, and some tips and tricks to incorporate into your own coding practices.
This month, we'll work on a problem in statistical analysis and to some extent, handling big data. It's common to use a computer to manipulate and summarize large amounts of information, providing important insights into how to improve or handle a situation. In this problem, we'll use weather data collected by the US Navy from Lake Pend Oreille in northern Idaho. Lake Pend Oreille is the fifth deepest fresh water lake in the United States. So deep in fact, that the US Navy uses it to test submarines.
As part of that testing, the US Navy compiles an exhaustive list of weather statistics, including wind speed, air temperature and barometric pressure. You can browse this data by pointing your browser at http://lpo.dt.navy.mil. You'll find several weather summaries, a web cam, and the raw data they collect every five or six minutes archived as standard text files.
For anyone living or working on Lake Pend Oreille, weather statistics are an important part of every day life. Especially, if your on a small boat in the middle of the lake. There can be a significant difference between average wind speed and median wind speed.In this challenge I'll be using PHP to calculate the mean and median of the wind speed, air temperature and barometric pressure recorded into the deep more station for a given range of dates. The other authors will each use their own favorite language to solve the same problem.
First, let's briefly review mean and median. These are both statistics, to explain how they're calculated, we need a set of numbers. How about 14 readings for Wind Gusts at deep more weather station on January 1, 2014. You can see the data of this website. The first column, is the day the wind gust was recorded. The second column, is the time it was recorded. And the third column, is the wind gust in miles per hour. The mean, is also known as the average.
So calculate the mean of a range of numbers, simply add the values in the set and then divide by the number of values. In this example, we add all of these numbers together and then divide the sum by 14 the amount of numbers in the set. In this case, the mean is equal to nine. The median is the middle value in a set of data sorted in ascending order. Think of the median as the median strip of the road, it always marks the center.
To calculate the median first, sort the numbers from lowest to highest. If there's an odd number of values, then just take the middle number. If there's an even number of values, then calculate the average of the central two numbers. In this case, there's an even number of values. So we sort, then take the average of the middle two values, eight and eleven, so the median is 9.5. In addition, some offices including myself have chosen to implement a web service to provide access to the new weather statistics created by the author's program.
The JSON data returned looks like this. So that is our first challenge. Pull statistics from a data set available online. Perhaps, you want to pause and create a solution of your own. How would you solve the problem? In the next videos, I'll show you how I solve the challenge
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 96658 Viewers
56 Video lessons · 110372 Viewers
71 Video lessons · 79199 Viewers
131 Video lessons · 37982 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.