Questions tagged [moving-average]

A calculation of the average value of the most recent (within some window) values in a time series, rather than the average of the entire series.

Moving average is a calculation of the average value of the most recent (within some window) values in a time series, rather than the average of the entire series.

1034 questions
-2
votes
2 answers

moving average in python

I've tried to create a generator function which can find simple moving average of the list, but it doesn't work at all. I think the root of the problem might be in finding sum def gen(lst, n): s = 0 for i, _ in enumerate(lst): if…
JF_01
  • 21
  • 4
-2
votes
1 answer

compute absolute distance/weighted moving average. Stata or R

I want to capture in a variable (called “absolutedistance”) the absolute value of the distance of a numeric variable (called “v1”) between a given subject (identified with var “id”; total 50 subjects) in a given year (identified with var “duration”;…
vic_tor
  • 1
  • 3
-2
votes
1 answer

How to calculate this variable in R

I have the following data: mydf[77:84,] id game_week points code web_name first_name second_name position team_name date fixture team1 team2 home_away team_scored team_conceded minutes goals assists cleansheet goals_conceded own_goals 77 3…
Manasvi Bali
  • 25
  • 1
  • 3
-2
votes
1 answer

Time series data frame in R

Currently, I have a data frame (A) with row.names as dates and two column values (Xval and Yval) Xval,Yval "2015-01-01",5,6 "2015-01-02",7,4 "2015-01-05",-1,10 "2015-01-06",-4,3 I have two main questions: (Question 1) I want to compute a new data…
qwer
  • 223
  • 4
  • 13
-2
votes
5 answers

C++ Gas Mileage Averaging

I'm supposed to be making a simple console program which can allow a user to input their miles driven and gallons used during multiple trips. It uses a while loop structure and calculates two fuel economies, one for the trip, and the overall fuel…
-2
votes
1 answer

Taking average value every 2 seconds

i have a problem with arrays or something missed in these text.. my program works every 500ms and i want to read first 4 double values and take average of these values and then get next 4 double values and so on... i write something about this and…
cemaran85
  • 3
  • 1
-3
votes
1 answer

Running Total and Moving Average

What is the genre-wise running total and moving average of the average movie duration? -- (Note: You need to show the output table in the question.) /* Output format:…
-3
votes
1 answer

Compute moving average in pandas with a twist

This seems very simple to achieve in excel. Not sure how to do this with pandas. My data set looks as follows [Row,Flag,Value 1,FALSE,3 2,FALSE,1 3,FALSE,2 4,FALSE,3 5,FALSE,5 6,TRUE,nan 7,TRUE,nan 8,TRUE,nan 9,TRUE,nan] I wan an output that looks…
-3
votes
2 answers

How do you compute for the moving average of a given dataset in C#?

So I use a randomly generated dataset and I need to find the moving average of the sample size the user inputted. For example, the dataset is a list with {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and the sample size the user inputted is 2. The program must…
Hope D
  • 1
-3
votes
1 answer

How to handle missing values for moving averages features in a time series problem?

I'm trying to create some moving averages on data that has missing values. The way i see it i have two options: 1) I can fill these points in with the last known value. The problem is, i think this will mess with the integrity of the moving average…
-3
votes
2 answers

Rolling Average for last 3 years for same week number Python Pandas

I am finding average of the same weeks whenever there is data available for example 201932, using the average of the data from 201632, 201732 and 201832. Example : 2019 is year and 32 is week number
vij
  • 21
  • 1
  • 1
  • 4
-3
votes
2 answers

Stata - Generating rolling average variable

I'd like to generate a rolling average variable from a basketball dataset. So if the first observation is 25 points on January 1, the generated variable will show 25. If the second observation is 30 points on January 2, the variable generated will…
user3654703
  • 1
  • 1
  • 3
-3
votes
1 answer

uninitialized variable in moving average computation

What I am trying to achieve in the following code is to find moving average; int slots = int ((sr+e)/mst); // finding number of slots int temp2; int temp1; if (temp1 == null) { temp2 = 0; } temp2=temp1; // previously found number of…
-7
votes
1 answer

How to print arrays index/subscript

Few Java questions: How to prompt user for input? How to save input from user in an array? How to average numbers in an array? How to compare numbers? How to print information back to the user? The scenario is as follows: let the user to input 10…
1 2 3
68
69