sliding-window

Removing comments with a sliding window without nested while loops

主宰稳场 提交于 2019-11-30 22:31:48
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 inefficient. I can do it this way if I have to, but I was wondering if anyone had a better solution. The

R: Efficiently subsetting dataframe based on time of day

邮差的信 提交于 2019-11-30 22:31:24
I have a large (150,000x7) dataframe that I intend to use for back-testing and real-time analysis of a financial market. The data represents the condition of an investment vehicle at 5 minute intervals ( although holes do exist ). It looks like this (but much longer): pTime Time Price M1 M2 M3 M4 1 1212108300 20:45:00 1.5518 12.21849 -0.37125 4.50549 -31.00559 2 1212108900 20:55:00 1.5516 11.75350 -0.81792 -1.53846 -32.12291 3 1212109200 21:00:00 1.5512 10.75070 -1.47438 -8.24176 -34.35754 4 1212109500 21:05:00 1.5514 10.23529 -1.06044 -8.46154 -33.24022 5 1212109800 21:10:00 1.5514 9.74790 -1

R: Efficiently subsetting dataframe based on time of day

随声附和 提交于 2019-11-30 18:04:05
问题 I have a large (150,000x7) dataframe that I intend to use for back-testing and real-time analysis of a financial market. The data represents the condition of an investment vehicle at 5 minute intervals ( although holes do exist ). It looks like this (but much longer): pTime Time Price M1 M2 M3 M4 1 1212108300 20:45:00 1.5518 12.21849 -0.37125 4.50549 -31.00559 2 1212108900 20:55:00 1.5516 11.75350 -0.81792 -1.53846 -32.12291 3 1212109200 21:00:00 1.5512 10.75070 -1.47438 -8.24176 -34.35754 4

Sliding window algorithm for activity recognition

£可爱£侵袭症+ 提交于 2019-11-30 09:02:39
问题 I want to write a sliding window algorithm for use in activity recognition. The training data is <1xN> so I'm thinking I just need to take (say window_size=3 ) the window_size of data and train that. I also later want to use this algorithm on a matrix . I'm new to matlab so i need any advice/directions on how to implement this correctly. 回答1: The short answer: %# nx = length(x) %# nwind = window_size idx = bsxfun(@plus, (1:nwind)', 1+(0:(fix(nx/nwind)-1))*nwind)-1; idx will be a matrix of

sliding window technique for multiple people detection

◇◆丶佛笑我妖孽 提交于 2019-11-29 17:25:10
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.bmp'); im = imread (im); win_size= [64, 128]; [lastRightCol lastRightRow d] = size(im); counter = 1; %%

Matrix with sliding window elements

杀马特。学长 韩版系。学妹 提交于 2019-11-29 11:08:42
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 this matrix. So, my questions are: How to transform my initial time series to such a matrix? Let's say I

Android Sliding Up View

不问归期 提交于 2019-11-29 07:54:42
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 showed when I click a button. The images below explain it better. If there is not possible to do this by

Sliding window in R

老子叫甜甜 提交于 2019-11-29 07:44:27
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.66 Now, for each row/coordinate in column A, all windows containing the coordinate are considered and

Bigquery SQL for sliding window aggregate

旧街凉风 提交于 2019-11-29 02:20:15
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 who had >n pageviews in a 30day window every week. something like this Date Customers>10 pageviews in

Implementing an efficient sliding-window algorithm in Haskell

泪湿孤枕 提交于 2019-11-29 02:01:51
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 make it more linear. Any takers? You can use Seq from Data.Sequence , which has O(1) enqueue and dequeue