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
2
votes
2 answers

MATLAB function to process vector with sliding window function, return matrix of vector responses

Assuming vector v of size 1 x n and function fun that takes in a vector of length L and returns a vector of size p x 1. Is there a MATLAB function that would take in vector v, process each sliding window of length L with function fun, and return a…
Marek Miettinen
  • 399
  • 1
  • 7
  • 18
2
votes
1 answer

how to calculate correlation with a sliding window?

I have a zoo object called aux with yearly data from 1961 to 2009: x$nao x[, 2] 1961 -0.03 63.3 1962 0.20 155.9 1963 -2.98 211.0 I want to calculate the correlation between the two columns using a 20 years sliding window. I am trying to…
sbg
  • 1,772
  • 8
  • 27
  • 45
2
votes
1 answer

Leetcode 424. Longest Repeating Character Replacement: Right Pointer Incrementation

I'm trying to solve Leetcode 424. Longest Repeating Character Replacement. Why is this code not working, I cannot get my head around it. class Solution: def characterReplacement(self, s: str, k: int) -> int: l, r = 0, 0 res = 0 …
user123
  • 307
  • 7
2
votes
1 answer

How can reproduce animation for rolling window over time?

I'm experimenting with 1D time-series data and trying to reproduce the following approach via animation over my own data in GoogleColab notebook. It's about reproducing the animation of STS transformation (implemented by series_to_supervised()…
Mario
  • 1,631
  • 2
  • 21
  • 51
2
votes
0 answers

How to Construct a Timebucket key for 2 hour window in REDIS

I am writing a throttling logic where i need to throttle requests of a user if the total number of requests for that USERID reaches a threshold of 200 within a 2 hour time window(sliding window). I need to insert a key with 2 hour timestamp in REDIS…
Yathish Manjunath
  • 1,919
  • 1
  • 13
  • 23
2
votes
2 answers

Pyspark create sliding windows from rows with padding

I'm trying to collect groups of rows into sliding windows represented as vectors. Given the example input: +---+-----+-----+ | id|Label|group| +---+-----+-----+ | A| T| 1| | B| T| 1| | C| F| 2| | D| F| 2| | E| F| …
2
votes
1 answer

PySpark Split Dataframe into Sliding Windows with intervals

I have the following dataframe as input +----+-------------------+ | id | date| +----+-------------------+ | A|2016-03-11 09:00:00| | B|2016-03-11 09:00:07| | C|2016-03-11 09:00:18| | D|2016-03-11 09:00:21| | E|2016-03-11…
2
votes
1 answer

Find the maximum profit when selling theatre seats

In a theatre show there are N seats [1,2,3,...N] each set at a different price such that the ith ticket costs A[i]. People come in group and want to sit together. The indexes of the array B indicate the respective group sizes. With an optimal…
Kartik Thakur
  • 57
  • 1
  • 7
2
votes
2 answers

Sliding window- cannot find error in my code (very basic algo)

I was doing a question online. The question was: Given an integer array A of size N. You have to pick exactly B elements from either left or right end of the array A to get maximum sum. Find and return this maximum possible sum. NOTE: Suppose B = 4…
2
votes
3 answers

How to get matrix position of the max element in sliding window view of an array?

I have successfully found the maximum of the array in each sliding window view using amax and sliding_window_view functions from NumPy as follows: import numpy as np a = np.random.randint(0, 100, (5, 6)) # 2D array array([[51, 92, 14, 71, 60,…
Vishnudev Krishnadas
  • 10,679
  • 2
  • 23
  • 55
2
votes
2 answers

Generating sliding window to subset data for prediction task

I want to write a sliding window function in order to use the model trained from t, t+1, and t+2 year to make prediction on the outcome of the t+3 year. This means that for a 10-year's data, the desired sliding window function should create 7…
Chris T.
  • 1,699
  • 7
  • 23
  • 45
2
votes
0 answers

Implementation of two Sliding Windows over a multivariate sequence of data in python

I am trying to construct two sliding windows over a multivariate sequence of data (m*n). The first window should be fixed and the second one is rolling over the data samples. Both windows have the same size. I followed this postdistance…
2
votes
1 answer

python implementation of numpy.lib.stride_tricks.as_strided

I'm trying to translate the as_strided function of NumPy to a function in Python when I translate ahead the number of strides to the number of variables according to the type of the variable (for float32 I divide the stride by 4, etc). The code I…
2
votes
2 answers

Big O time complexity of LeetCode 567

Below is my solution of LeetCode 567. https://leetcode.com/problems/permutation-in-string/ What would the Big o time complexity of code below be? Should it not be O(n*m) because of if (pattern_map == str_map): in code? Edit: n = pattern_map, m =…
Sxc-Dev
  • 123
  • 1
  • 7
2
votes
1 answer

Count Nice Subarrays - Understanding sliding window technique and not prefix sum

I am new to Two Pointer patters and in particular the Sliding Window technique. I encountered this problem on leetcode - Count Nice Subarrays. I have seen many solutions that change the array to 0's and 1's and then it becomes an entirely different…