sliding-window

Matrix with sliding window elements

早过忘川 提交于 2019-11-28 04:53:24
问题 I have time series, and I applying some user defined function to every W elements in time series. Right now I am just using for loop, slide window of size W an apply my function to elements in a window at every iteration. I am using Matlab and it is very inefficient with a "for loops" so I would love to vectorize this operation. As a solution I see transforming signal with length N to a matrix with size (N - 1, W) where each row is time series in different windows and applying function to

Android Sliding Up View

泄露秘密 提交于 2019-11-28 01:30:45
问题 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 like the AndroidSlidingUpPanel from "umano" which you can find here: The problem is that I want the first child (The content of my View - an image for example) to fill all the screen and also I want the second child(the actual bottom bar) to be

Sliding window in R

江枫思渺然 提交于 2019-11-28 01:29:49
问题 I have a dataframe DF, with two columns A and B shown below: A B 1 0 3 0 4 0 2 1 6 0 4 1 7 1 8 1 1 0 A sliding window approach is performed as shown below. The mean is calulated for column B in a sliding window of size 3 sliding by 1 using: rollapply(DF$B, width=3,by=1). The mean values for each window are shown on the left side. A: 1 3 4 2 6 4 7 8 1 B: 0 0 0 1 0 1 1 1 0 [0 0 0] 0 [0 0 1] 0.33 [0 1 0] 0.33 [1 0 1] 0.66 [0 1 1] 0.66 [1 1 1] 1 [1 1 0] 0.66 output: 0 0.33 0.33 0.66 0.66 1 1 1 0

Bigquery SQL for sliding window aggregate

你。 提交于 2019-11-27 16:40:23
问题 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 - (sliding window aggregates with window-size of 30 days for every week) I am using google bigquery EDIT: Gordon - re your comment about "Customer", Actually what I need is slightly more complicated thats why I included customer in the table above. I am looking to get the number of customers

Implementing an efficient sliding-window algorithm in Haskell

梦想与她 提交于 2019-11-27 16:36:58
问题 I needed an efficient sliding window function in Haskell, so I wrote the following: windows n xz@(x:xs) | length v < n = [] | otherwise = v : windows n xs where v = take n xz My problem with this is that I think the complexity is O(n*m) where m is the length of the list and n is the window size. You count down the list once for take , another time for length , and you do it down the list of essentially m-n times. It seems like it can be more efficient than this, but I'm at a loss for how to

BigQuery SQL for 28-day sliding window aggregate (without writing 28 lines of SQL)

☆樱花仙子☆ 提交于 2019-11-27 12:56:57
I'm trying to compute a 28 day moving sum in BigQuery using the LAG function. The top answer to this question Bigquery SQL for sliding window aggregate from Felipe Hoffa indicates that that you can use the LAG function. An example of this would be: SELECT spend + spend_lagged_1day + spend_lagged_2day + spend_lagged_3day + ... + spend_lagged_27day as spend_28_day_sum, user, date FROM ( SELECT spend, LAG(spend, 1) OVER (PARTITION BY user ORDER BY date) spend_lagged_1day, LAG(spend, 2) OVER (PARTITION BY user ORDER BY date) spend_lagged_2day, LAG(spend, 3) OVER (PARTITION BY user ORDER BY date)

Does reactive extensions support rolling buffers?

梦想的初衷 提交于 2019-11-27 12:45: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 received for the entire 100ms do I want to handle it. This opens up the possibility of never handling

R data.table sliding window

☆樱花仙子☆ 提交于 2019-11-27 11:39:27
What is the best (fastest) way to implement a sliding window function with the data.table package? I'm trying to calculate a rolling median but have multiple rows per date (due to 2 additional factors), which I think means that the zoo rollapply function wouldn't work. Here is an example using a naive for loop: library(data.table) df <- data.frame( id=30000, date=rep(as.IDate(as.IDate("2012-01-01")+0:29, origin="1970-01-01"), each=1000), factor1=rep(1:5, each=200), factor2=1:5, value=rnorm(30, 100, 10) ) dt = data.table(df) setkeyv(dt, c("date", "factor1", "factor2")) get_window <- function

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

落爺英雄遲暮 提交于 2019-11-27 09:19:23
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 input is not given within 2 seconds then Time-out: 2 seconds Timer again set to 0 Please enter the input: //if input is not given within 2 seconds then Time-out: 2 seconds Timer again set to 0 Please enter the input:22 Data accepted Terminate the program` Code: #include<iostream> #include<time.h> using namespace std; int main() { clock_t endwait; endwait = 2000 ;

sliding window of M-by-N shpae numpy.ndarray

不问归期 提交于 2019-11-27 00:52:31
I have a numpy array of shape (6,2) [[00,01], [10,11], [20,21], [30,31], [40,41], [50,51]] I need a sliding window with step size 1 and window size 3 likes this: [[00,01,10,11,20,21], [10,11,20,21,30,31], [20,21,30,31,40,41], [30,31,40,41,50,51]] I'm looking for a numpy solution. If your solution could parametrize the the shape of the original array as well as the window size and step size, that'd great. I found this related answer Using strides for an efficient moving average filter but I don't see how to specify the stepsize there and how to collapse the window from the 3d to a continuous 2d