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
4
votes
1 answer

How to output a struct array when I use the nlfilter function?

I have the following function which calculates statistic parameters. I would like to pass this function to nlfilter to do the calculation for a whole image. But the output of nlfilter must be a scalar. How can I convert this to a function handle…
H.L.
  • 41
  • 2
4
votes
2 answers

Sliding window pattern match in perl or matlab regular expressions

I am trying to use either Perl or MATLAB to parse a few numbers out of a single line of text. My text line is: t10_t20_t30_t40_ now in matlab, i used the following script str = 't10_t20_t30_t40_'; a = regexp(str,'t(\d+)_t(\d+)','match') and it…
4
votes
2 answers

Running variance when time window is not constant

I am trying to calculate a moving variance with a window of, let's say 4 years, for each one of the names A, B and C. The data is weekly: > head(data1, 17) date name value 1 1985-01-01 A -0.44008233 2 1985-01-01 B NA…
Per
  • 577
  • 4
  • 7
4
votes
5 answers

Efficiently accumulate Sliding Window Percentage Changes of large dataset

I have a few million datapoints, each with a time and a value. I'm interested in knowing all of the sliding windows, (ie, chunks of 4000 datapoints) where the range from high to low of the window exceeds a constant threshold. For example:, assume a…
Scott Klarenbach
  • 37,171
  • 15
  • 62
  • 91
4
votes
4 answers

Android Sliding Up View

I need to do a Sliding Up View wich should slide up from the bottom of the screen when I click a button. It has to show on the bottom of the screen and I need to slide/drag it to the center of the screen. The images below explain it better. almost…
4
votes
3 answers

Python - Element-wise means of multiple matrices with Numpy

I am implementing a sliding-window model, where I want to initialize a matrix @t as the element-wise means of the previous N matrices, where N is the window size. This is my initial attempt, which displays the last N matrices: list_of_arrays =…
Zhubarb
  • 11,432
  • 18
  • 75
  • 114
4
votes
1 answer

non-maximum suppression on detection windows

In object detection literature it is common to use a classifier and a sliding window approach to detect the presence of objects in an image, this method returns a set of detection windows and detection overlaps are resolved using non-maximum…
Jono Brogan
  • 341
  • 7
  • 19
4
votes
4 answers

Find start and end dates when one field changes

I have this data in a table FIELD_A FIELD_B FIELD_D 249052903 10/15/2011 N 249052903 11/15/2011 P ------------- VALUE CHANGED 249052903 12/15/2011 P 249052903 1/15/2012 N ------------- VALUE CHANGED 249052903 2/15/2012 …
cooperjv
  • 43
  • 2
  • 5
3
votes
2 answers

What's the most efficient way to compute the mode in a sliding window over a 2D array in Python?

I have an RGBA image that I need to upscale while keeping it smooth. The catch is that I need to keep the colors exactly the way they are (background: I'm resizing a map where provinces are color-coded), and so I cannot just perform a resize with…
3
votes
2 answers

simple sliding window filter in Matlab

I don't have the package for nlfilter and I didn't quite follow this example. I have a really simple function fun and I want to apply it to a moving window of an array. The array is Nx1, and I want to look at length k intervals, say. So for N=10 and…
WisaF
  • 314
  • 1
  • 3
  • 11
3
votes
5 answers

Sliding window method for pattern recognition in SWI-Prolog

I would like to find the most eloquent and efficient method, algorithmically speaking, to count occurrences of some patterns in SWI-Prolog. For now, my solution uses DCG and looks like this: count_occurrences(Pattern, List, Count) :- …
3
votes
0 answers

Returning maximum sum of k elements provided left or right subarray of selected element should be discarded

My friend got asked a question in an interview: Given an array, say: [4, 6, -10, -1, 10, -20] and a value k, say: 4, you have to return the maximum sum of k elements from the array such that every time you select an element, you need to discard…
Someone
  • 611
  • 4
  • 13
3
votes
1 answer

Is the complexity of kdb's moving max function mmax O(n)?

I used function mmax to calculate moving max of a 10-million-length integer vector. I ran it 10 times to calculate the total execution time. The running time for window size 132 (15,025 milliseconds) is 6 times longer than for window size 22 (2,425…
3
votes
1 answer

How does this algorithm implement a sliding window?

I'm currently prepping for a technical interview and practicing some data structures and algorithms questions with Python. There is a common question that asks you to find the longest substring in a string, such that that substring contains no…
MetaMario
  • 33
  • 3
3
votes
1 answer

Intuition behind calculating values for 'atmost K' and 'atmost K-1' to get the answer for 'equals K'

I am trying to solve an algorithm problem: Given an array nums of positive integers, call a (contiguous, not necessarily distinct) subarray of nums "good" if the number of different integers in that subarray is exactly k. For example, [1,2,3,1,2]…
J. Doe
  • 1,291
  • 2
  • 10
  • 19