Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8545173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:43:59+00:00 2026-06-11T12:43:59+00:00

I want to calculate Centered Moving average of a set of Data . Example

  • 0

I want to calculate Centered Moving average of a set of Data .

Example Input format :

quarter | sales      
Q1'11   | 9            
Q2'11   | 8
Q3'11   | 9
Q4'11   | 12
Q1'12   | 9
Q2'12   | 12
Q3'12   | 9
Q4'12   | 10

Mathematical Representation of data and calculation of Moving average and then centered moving average

Period   Value   MA  Centered
1          9
1.5
2          8
2.5              9.5
3          9            9.5
3.5              9.5
4          12           10.0
4.5              10.5
5          9            10.750
5.5              11.0
6          12
6.5
7          9  

I am stuck with the implementation of RecordReader which will provide mapper sales value of a year i.e. of four quarter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:44:00+00:00Added an answer on June 11, 2026 at 12:44 pm

    This is actually totally doable in the MapReduce paradigm; it does not have to be though of as a ‘sliding window’. Instead think of the fact that each data point is relevant to a max of four MA calculations, and remember that each call to the map function can emit more than one key-value pair. Here is pseudo-code:

    First MR job:
    
    map(quarter, sales)
        emit(quarter - 1.5, sales)
        emit(quarter - 0.5, sales)
        emit(quarter + 0.5, sales)
        emit(quarter + 1.5, sales)
    
    reduce(quarter, list_of_sales)
        if (list_of_sales.length == 4):
            emit(quarter, average(list_of_sales))
        endif
    
    
    Second MR job:
    
    map(quarter, MA)
        emit(quarter - 0.5, MA)
        emit(quarter + 0.5, MA)
    
    reduce(quarter, list_of_MA)
        if (list_of_MA.length == 2):
            emit(quarter, average(list_of_sales))
        endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to calculate the average of a set of circular data. For example,
I want to calculate the average of a set of angles, which represents source
I want to calculate a moving average of the last, say 20, numbers of
I want to calculate the smallest integer with exactly k bits set, that is
I want to calculate a bonus based on the two consecutive months where sales
I want to calculate price based on the customer selected options. For example,there are
I want to calculate average speed of the distance traveled using gps signals. Is
I want to calculate number of days from a date. For example, we have
I want to calculate distance in my custom repository class. The problem is that
We want to calculate the value of an integral in linear plot. For a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.