Viewers: in countries Watching now:
Many successful programmers know more than just a computer language. They also know how to think about solving problems. They use "computational thinking": breaking a problem down into segments that lend themselves to technical solutions. Code Clinic is a series of six courses where lynda.com authors solve the same problems using different programming languages. Here, David Powers works with PHP.
David introduces challenges and provides an overview of his solutions in PHP. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, Java, Python, and Ruby.
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 you're 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 Moor 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 Moor 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
Find answers to the most frequently asked questions about Code Clinic: PHP .
Here are the FAQs that matched your search "" :
A: The Lake Pend Orielle site is not accessible in some geographical areas. We have contacted the owner of the server to try to resolve this issue.
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
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.