An organization surveyed the price of petrol at petrol stations in Mumbai and Bangalore. The data, in rs per liter, are given below.
Mumbai 73.96 73.76 74.00 73.91 73.69 73.72
Bangalore 73.97 73.81 73.52 74.08 73.88 73.68
Which city has the more consistently priced petrol? Give reasons for your answer.
This is a very basic form of data science question. we will try to solve this problem using Python and come up with an appropriate reason for this question.
Note : For now, you will think that we can calculate this manually. But , you will be dealing with thousands of records. At that time, this basic tutorial also proves beneficial.
Steps to solve a problem :
- Understand the problem
- Design an approach
- Solve using Python
- Quote your answer with a reason.
For more information on Python please visit m previous blog.
1. Understand the problem.
We have been asked that which city has consistently priced petrol. After reading the problem we should be able to think what exactly we should find to ans this question. The price should not vary a great deal if we want a consistent result. So, by calculating the standard deviation we will be able to answer the question. So, we have to find standard deviation for both the cities and compare the values.
2. Design an approach.
- Find mean for both the cities.
- Find Standard Deviation.
- Compare both the values.
3. Solve using Python.
Lets solve this problem using Python.
Define functions for mean and standard deviation.
Create a main function to add the values to list , calculate the std deviation on that values and compare the std dev.
Note : (If data is large, then we will store it in excel sheet and then import that excel sheet.This will be shown in one of the upcoming tutorial)
After executing this program the answer that we get is :
4. Quote your answer with reason :
When we calculate consistency, standard deviation plays an important role. Lower the standard deviation, consistent are the values. So, for our problem, the std dev is low for the petrol prices in Mumbai than for Bangalore. So the prices in Mumbai are consistent as compared to Bangalore.
No comments:
Post a Comment