Math Problem Statement
- The following table represents the volume of sale (in millions of rupees) of a certain company for the 2004-2022.
Year
Sales
Year
Sales
2004
55
2014
94
2005
77
90
2015
87
2006
2016
76
2007
94
2017
80
2008
91
2018
78
2009
72
2019
77
2010
67
2020
75
91
2011
63
2021
2012
77
2022
74
2013
84
2022
69
a) Plot the data on a chart.
b) Fit a 3-year moving average to the data and plot the results on your chart.
c) Also fit a 7-year moving average to the data and plot the results on the same chart. What differences do you find by smoothing the data 3-year and 7-year average method?
Solution
To analyze and address the given problem, we will perform the following steps:
Step-by-Step Process
- Organize Data: Structure the given sales data into a usable format, filling in any missing values if necessary.
- Plot Raw Data: Create a chart displaying the sales values over the years.
- 3-Year Moving Average: Compute and plot the 3-year moving average on the same chart.
- 7-Year Moving Average: Compute and plot the 7-year moving average on the same chart.
- Comparison: Analyze and describe the differences between the smoothed curves using the two moving averages.
Let me process this data and create the necessary charts. pandas as pd import matplotlib.pyplot as plt
Data from the table (after interpreting and organizing)
data = { "Year": [2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022], "Sales": [55, 77, 90, 94, 91, 72, 67, 63, 77, 84, 94, 87, 76, 80, 78, 77, 75, 91, 69] }
Create a DataFrame for easy manipulation
df = pd.DataFrame(data)
Calculate moving averages
df['3-Year Moving Average'] = df['Sales'].rolling(window=3).mean() df['7-Year Moving Average'] = df['Sales'].rolling(window=7).mean()
Plot the raw data and the moving averages
plt.figure(figsize=(14, 8))
Plot raw data
plt.plot(df['Year'], df['Sales'], marker='o', label='Raw Sales Data', color='blue')
Plot 3-year moving average
plt.plot(df['Year'], df['3-Year Moving Average'], label='3-Year Moving Average', color='orange', linestyle='--')
Plot 7-year moving average
plt.plot(df['Year'], df['7-Year Moving Average'], label='7-Year Moving Average', color='green', linestyle='--')
Customize the chart
plt.title("Sales Data with Moving Averages (2004-2022)", fontsize=16) plt.xlabel("Year", fontsize=14) plt.ylabel("Sales (in millions)", fontsize=14) plt.legend(fontsize=12) plt.grid(True) plt.tight_layout()
Show the chart
plt.show()### Chart Explanation
- Raw Sales Data: The blue line shows fluctuations in the company's sales over the years, with notable peaks and troughs.
- 3-Year Moving Average: The orange dashed line smooths the data by averaging sales over every 3-year window, reducing short-term fluctuations while preserving general trends.
- 7-Year Moving Average: The green dashed line provides a more pronounced smoothing by considering a 7-year window. This results in a less sensitive curve, highlighting longer-term trends.
Observations
- 3-Year Moving Average: Captures short-term changes effectively, showing more detailed patterns like smaller peaks and dips.
- 7-Year Moving Average: Highlights broader trends while suppressing noise, ideal for identifying long-term trends.
Would you like detailed calculations or further explanations?
Related Questions
- How are moving averages calculated, and why are they useful for trend analysis?
- What happens if we use a larger window (e.g., 10-year moving average)?
- How do moving averages relate to other smoothing techniques, like exponential smoothing?
- Can moving averages be used to forecast future sales data?
- How do short-term fluctuations affect business decision-making compared to long-term trends?
Tip
When analyzing data trends, choose the moving average window size based on your goal: shorter windows for detail, longer windows for a broader perspective.
Ask a new question for Free
By Image
Drop file here or Click Here to upload
Math Problem Analysis
Mathematical Concepts
Statistics
Data Visualization
Moving Averages
Formulas
3-Year Moving Average = (Sales[i-1] + Sales[i] + Sales[i+1]) / 3
7-Year Moving Average = (Sales[i-3] + Sales[i-2] + Sales[i-1] + Sales[i] + Sales[i+1] + Sales[i+2] + Sales[i+3]) / 7
Theorems
Concept of Moving Averages in Time Series Analysis
Suitable Grade Level
Grades 9-12
Related Recommendation
Time Series Analysis: 3-Year and 7-Year Moving Averages for Sales Data (2004–2022)
Calculating Two-Period Moving Average for 2008 Using Yearly Sales Data
Time Series Analysis with Linear Regression and MSE Calculation for Cost Forecasting
Forecasting Sales Demand using Three-Month and Five-Month Moving Averages
Time Series Analysis: Period vs Observed Values with Trend Analysis and Moving Averages