Questions tagged [sliding-window]

In data analysis, sliding windows are advancing sub-lists inside lists which allow, e.g., computation of a record's change from the previous record or next record. In networking, a sliding window may refer to a flow control technique that maintains windows of sequential frames sent or received without a corresponding acknowledgement.

In data analysis, sliding windows are advancing sub-lists inside lists which allow, e.g., computation of a record's change from the previous record or next record. In SQL in particular, the analytic functions LEAD(), LAG(), and computations OVER() a changing subset of query results involve sliding windows.

In networking, a sliding window may refer to a flow control technique that maintains windows of sequential frames sent or received without a corresponding acknowledgement.

583 questions
9
votes
5 answers

R: Rolling window function with adjustable window and step-size for irregularly spaced observations

Say there is a 2-column data frame with a time or distance column which sequentially increases and an observation column which may have NAs here and there. How can I efficiently use a sliding window function to get some statistic, say a mean, for…
Jota
  • 17,281
  • 7
  • 63
  • 93
9
votes
1 answer

Sliding Window over Time - Data Structure and Garbage Collection

I am trying to implement something along the lines of a Moving Average. In this system, there are no guarantees of a quantity of Integers per time period. I do need to calculate the Average for each period. Therefore, I cannot simply slide over the…
Kurtis
  • 1,599
  • 1
  • 16
  • 30
9
votes
2 answers

R: fast sliding window with given coordinates

I have a data table with nrow being around a million or two and ncol of about 200. Each entry in a row has a coordinate associated with it. Tiny portion of the data: [1,] -2.80331471 -0.8874522 -2.34401863 -3.811584 -2.1292443 [2,] 0.03177716 …
Karolis Koncevičius
  • 9,417
  • 9
  • 56
  • 89
8
votes
6 answers

Generate a list of strings with a sliding window using itertools, yield, and iter() in Python 2.7.1?

I'm trying to generate a sliding window function in Python. I figured out how to do it but not all inside the function. itertools, yield, and iter() are entirely new to me. i want to input a='abcdefg' b=window(a,3) print…
O.rka
  • 29,847
  • 68
  • 194
  • 309
8
votes
1 answer

How do I create a sliding window with a 50% overlap with a numpy array?

Say I have an array like so: array([1, 2, 3, 4, 5, 5, 7, 8, 9, 10]) I want to change it to array([1, 2, 3, 4]), array([3, 4, 5, 6]), array([5, 6, 7, 8]), array([7, 8, 9, 10]) Here the window size would be 4, and step size would be 2. How can I…
user2398046
8
votes
2 answers

Numpy Vectorization of sliding-window operation

I have the following numpy arrays: arr_1 = [[1,2],[3,4],[5,6]] # 3 X 2 arr_2 = [[0.5,0.6],[0.7,0.8],[0.9,1.0],[1.1,1.2],[1.3,1.4]] # 5 X 2 arr_1 is clearly a 3 X 2 array, whereas arr_2 is a 5 X 2 array. Now without looping, I want to…
Nikhil
  • 545
  • 1
  • 7
  • 18
8
votes
5 answers

How to use a timer in C++ to force input within a given time?

I want to implement a time out feature in C++. If the user does not input the value within 2 seconds then the program must display the time-out statement and ask the input again EX(OUTPUT SCREEN): Timer=0; Please enter the input: //if…
Ankita Rane
  • 171
  • 1
  • 1
  • 12
7
votes
4 answers

Generalized sliding-window computation on the GPU

Here's some Python code that implements a sliding-window computation on two 3D matrices, X and Y. import numpy def sliding_dot( X,Y ) : assert X.ndim == Y.ndim == 3 iw,ih,id = X.shape fw,fh,fd = Y.shape assert id == fd assert…
BrianTheLion
  • 2,618
  • 2
  • 29
  • 46
7
votes
1 answer

Computing the difference between first and last values in a rolling window

I am using the Pandas rolling window tool on a one-column dataframe whose index is in datetime form. I would like to compute, for each window, the difference between the first value and the last value of said window. How do I refer to the relative…
Pandora
  • 203
  • 1
  • 3
  • 7
7
votes
1 answer

Fast rolling-sum for list of data vectors (2d matrix)

I am looking for a fast way to compute a rolling-sum, possibly using Numpy. Here is my first approach: def func1(M, w): Rtn = np.zeros((M.shape[0], M.shape[1]-w+1)) for i in range(M.shape[1]-w+1): Rtn[:,i] = np.sum(M[:, i:w+i],…
user3329302
  • 627
  • 2
  • 8
  • 12
7
votes
2 answers

Finding k-mers in a sliding window

I am trying to work through this bioinformatics problem: https://stepic.org/lesson/An-Explosion-of-Hidden-Messages-4/step/1?course=Bioinformatics-Algorithms-2&unit=8 The specific question is in the 5th window of the link above, and the question is: …
epicode
  • 73
  • 1
  • 3
7
votes
2 answers

Bigquery SQL for sliding window aggregate

Hi I have a table that looks like this Date Customer Pageviews 2014/03/01 abc 5 2014/03/02 xyz 8 2014/03/03 abc 6 I want to get page view aggregates grouped by week but showing aggregates for past 30 days…
7
votes
1 answer

contrast enhancement of an image using neighbourhoood

Hi I want to enhance the contrast of an image using the neighbourhood pixel values. Let the image be considered as u0. Then I want to enhance the image by using the formula Here, M1 is the minima and M2 is the maxima of u0 among the neighbourhood…
roni
  • 1,443
  • 3
  • 28
  • 49
7
votes
2 answers

Sliding window minimum/maximum in 2D

Suppose we are given an integer matrix of pixels of size NxN and an integer k - window size. We need to find all local maximums (or minimums) in the matrix using the sliding window. It means that if a pixel has a minimum (maximum) value compared to…
Andrei Baskakov
  • 161
  • 2
  • 3
6
votes
4 answers

Calculate max on a sliding window for TimeSeries

Input: public class MyObject { public double Value { get; set; } public DateTime Date { get; set; } } Method to generate test objects: public static MyObject[] GetTestObjects() { var rnd = new Random(); var date…
Nick Farsi
  • 366
  • 4
  • 19
1
2
3
38 39