Try deleting the line where you initially assign to subset – it isn't necessary and causes that variable to change type over the course of your loop.
On Tue, Jan 6, 2015 at 6:50 PM, Tomas Mikoviny <[email protected]> wrote: > Hi Stefan, > > you are right. But the moment I try to do this for any subset along the > array it gets inefficient. > Here is the simplest code for running median of one dimensional array. > Time consuming... > > function runmed(input::Array, w::Int) > L = length(input) > output = zeros(input) > subset = zeros(w+1) > for i in 1:L-w > subset = sub(input, i:i+w) > output[i] = median!(subset) > end > return output > end > > a = zeros(300000); > > runmed(a, 200); > > @time runmed(a, 200); > elapsed time: 1.460171594 seconds (43174976 bytes allocated) > > > On Tuesday, January 6, 2015 10:10:39 PM UTC+1, Stefan Karpinski wrote: >> >> You may not need online methods at all. Sorting the rows of a 200 x >> 300000 matrix doesn't take very long on my laptop: >> >> julia> X = randn(200,300000); >> >> julia> @time X = sortrows(X); >> elapsed time: 0.297998739 seconds (480053384 bytes allocated) >> >> >> >> >> On Tue, Jan 6, 2015 at 2:33 PM, Tomas Mikoviny <[email protected]> >> wrote: >> >>> Hi Kevin, >>> >>> generally I'm trying to do baseline correction on mass spectra with >>> ~300000 bins. I've tried several algorithms to evaluate baseline but the >>> ones working the best implement running median and mean. I've just got mean >>> sorted out via cumsum trick in coincidence with Tim's suggestion (found >>> some MATLAB discussion on that). Although I'll check Tamas' suggestion too. >>> >>> I've got stacked with running median that would have reasonable >>> performance since computer has to crunch runmed of array of 200 x 300000 >>> within couple of seconds (max) to manage online analysis. >>> >>> On Tuesday, January 6, 2015 6:18:02 PM UTC+1, Kevin Squire wrote: >>>> >>>> Hi Tomas, >>>> I'm bit aware of any (though they might exist). It might help if you >>>> gave a little more context--what kind of data are you working with? >>>> >>>> Cheers, >>>> Kevin >>>> >>>> On Tuesday, January 6, 2015, Tomas Mikoviny <[email protected]> >>>> wrote: >>>> >>>>> Hi, >>>>> I was just wondering if anyone knows if there is a package that >>>>> implements *fast* running median/mean algorithms? >>>>> >>>>> Thanks a lot... >>>>> >>>>> >>>> >>
