sliding-window

SQL Server: Lead/Lag analytic function across groups (and not within groups)

会有一股神秘感。 提交于 2019-12-22 04:32:42
问题 Sorry for the long post, but I have provided copy & paste sample data and a possible solution approach below. The relevant part of the question is in the upper part of the post (above the horizontal rule). I have the following table Dt customer_id buy_time money_spent ------------------------------------------------- 2000-01-04 100 11:00:00.00 2 2000-01-05 100 16:00:00.00 1 2000-01-10 100 13:00:00.00 4 2000-01-10 100 14:00:00.00 3 2000-01-04 200 09:00:00.00 10 2000-01-06 200 10:00:00.00 11

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

烈酒焚心 提交于 2019-12-21 04:42:07
问题 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], axis=1) return Rtn M = np.array([[0., 0., 0., 0., 0., 1., 1., 0., 1., 1., 1., 0., 0.], [0., 0., 1., 0., 1., 0., 0., 0., 0., 0., 0., 1., 1.], [1., 1., 0., 1., 0., 0., 0., 1., 0., 0., 0., 0., 0.]]) window_size = 4 print func1(M, window_size) [[ 0. 0. 1. 2. 2. 3. 3. 3. 3.

Sliding window algorithm in C#

随声附和 提交于 2019-12-19 11:28:07
问题 I'm trying to implement simple sliding window alogirithm on two-dimensional array in C# 3.0, I found this as very useful but it involves only single-dimensioal array. The post also includes the code for the algo, I'm totaly failed to use it for my senario... can any one suggest me how do I proceed? Scenario: (source: googlepages.com) The above image is 10X10 matrix and need get 3X3 matrix out it, using any algorithm (Sliding window would be greate). Red rectangle is a first set and green one

sql sliding window - finding max value over interval

空扰寡人 提交于 2019-12-19 03:56:50
问题 i have a sliding window problem. specifically, i do not know where my window should start and where it should end. i do know the size of my interval/window. i need to find the start/end of the window that delivers the best (or worst, depending on how you look at it) case scenario. here is an example dataset: value | tstamp 100 | 2013-02-20 00:01:00 200 | 2013-02-20 00:02:00 300 | 2013-02-20 00:03:00 400 | 2013-02-20 00:04:00 500 | 2013-02-20 00:05:00 600 | 2013-02-20 00:06:00 500 | 2013-02-20

Removing comments with a sliding window without nested while loops

北慕城南 提交于 2019-12-19 03:40:25
问题 I'm trying to remove comments and strings from a c file with c code. I'll just stick to comments for the examples. I have a sliding window so I only have character n and n-1 at any given moment. I'm trying to figure out an algorithm that does not use nested whiles if possible, but I will need one while to getchar through the input. My first thought was to while through find when n=* and (n-1)=/ then while through until n=/ and (n-1)=* , but considering this has nested whiles I feel it is

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

ⅰ亾dé卋堺 提交于 2019-12-18 12:28:38
问题 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 the observations in a window of duration X (e.g. 5 seconds), slide the window over Y seconds (e.g. 2.5 seconds), repeat... The number of observations in the window is based on the time column, thus both the number of observations per window and the

sliding window technique for multiple people detection

帅比萌擦擦* 提交于 2019-12-18 09:26:30
问题 I am working on video surveillance application for detecting people. Currently I am implementing HOG descriptor as the detector. However, I have a problem regarding the sliding window technique. My code is only able to detect single person. I am using also Group Rectangles from MexOpen CV to creat multiple bounding boxes. Anybody has idea how to write sliding window technique to detect multiple object? Thank you. % Reading the image im = strcat ('C:\Users\Documents\MATLAB\HOG\HOG\images\16

simple sliding window filter in Matlab

夙愿已清 提交于 2019-12-17 20:56:34
问题 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 k=3 and fun = @(x) min(x); I would get A = [13 14 2 14 10 3 5 9 15 8]; filter(A,k,fun) = [2 2 2 3 3 3 5 8]; Here I only want to look at indices 1,2,3 then 2,3,4 then ... then 8,9,10, so the final sequence is length 7. I can do this easy with a

Does reactive extensions support rolling buffers?

雨燕双飞 提交于 2019-12-17 07:23:27
问题 I'm using reactive extensions to collate data into buffers of 100ms: this.subscription = this.dataService .Where(x => !string.Equals("FOO", x.Key.Source)) .Buffer(TimeSpan.FromMilliseconds(100)) .ObserveOn(this.dispatcherService) .Where(x => x.Count != 0) .Subscribe(this.OnBufferReceived); This works fine. However, I want slightly different behavior than that provided by the Buffer operation. Essentially, I want to reset the timer if another data item is received. Only when no data has been

Does reactive extensions support rolling buffers?

百般思念 提交于 2019-12-17 07:23:08
问题 I'm using reactive extensions to collate data into buffers of 100ms: this.subscription = this.dataService .Where(x => !string.Equals("FOO", x.Key.Source)) .Buffer(TimeSpan.FromMilliseconds(100)) .ObserveOn(this.dispatcherService) .Where(x => x.Count != 0) .Subscribe(this.OnBufferReceived); This works fine. However, I want slightly different behavior than that provided by the Buffer operation. Essentially, I want to reset the timer if another data item is received. Only when no data has been