Tag Info

Hot answers tagged

6

This one takes less than one third of the time in my machine. The main idea is NOT converting to ImageData[] to speed up image ops. imgs = Import /@ fNames; fun[img_, idx_] := ImageApply[UnitStep[# - .18]/number idx &, img]; imgs1 = MapIndexed[fun[#1, #2[[1]]] &, imgs]; fold = Fold[ ImageAdd[ImageSubtract[#1, ImageMultiply[#1, Binarize[#2, 0]]], ...


5

This seems quicker. Importing the images is the slowest bit, there's probably not much you can do about that. fNames = FileNames["*.png"]; n = Length @ fNames; bins = Table[ Clip[Import[fNames[[i]], "GrayLevels"], {0.18, 0.18}, {0, i/n}] , {i, n}]; Colorize[ Image[Map[Max, Transpose[bins, {3, 1, 2}], {2}]], ColorFunction -> "TemperatureMap"]


5

Since we can not see the source code of Mathematica, we don't know the detailed algorithm Mathematica use to do string pattern searching. But in most other languages, they use KMP algorithm to do explicit string matching. KMP is in fact a very compact design of the DFA pattern matching algorithm. You can find a comparison here. You can see that the ...


4

bug fixed in 10.0.2. WIndows 7, 64 bit Commonest[{1, 2, 3, 1, 2, 3}, 1] (*should return {1}*)


3

Consider also 'Sort' and 'First' > (your expression here...) // Sort // First Max also suffers poor performance on DateObjects that can remedied in similar form: > (your expression here...) //Sort // Last To comment on the OP situation: at this time (MMA 10.0.2) short lists also suffer unacceptable delays. For example, applying Min or Max to a ...


3

As mentioned by blochwave, your code can't benefit from compilation. To speed up your code, take Rolf Mertig's advise may be the best. Making use of the Listable attribute of those arithmetical function will also help a little: (* Tested under n = 1000, dual-core laptop *) pk1 = Table[ Sum[Binomial[a, i]*StirlingS2[i, r]*(n - c)^(-i), {i, r, a}], {r, 1, ...


2

Update As noted by @user565739, my earlier solution does not work when i or j are unity (because the internal representation of z^1 does not involve Power). A simple generalization is as follows. f = x^3 y^4 + x^7 y^2; f /. {z1_^i_ z2_^j_ -> formular1[i, j], z1_ z2_^j_ -> formular1[1, j], z1_^i_ z2_ -> formular1[i, 1], z1_ z2_ -> ...


2

This seems to be somewhat faster. I use N[] or equivalent thereof in some places. Also removed a Floor since the argument had to be integral anyway. Clear[f, fr] f[n_, 0, s_, a_] := 1 fr[n_, s_] := fr[n, s] = Sum[m^-s, {m, 1., n}] f[n_, 1, s_, a_] := f[n, 1, s, a] = fr[n, s] - fr[a, s] f[n_, k_, s_, a_] := f[n, k, s, a] = N[Sum[Binomial[k, j] ...


1

I didn't go deep to the possible repetitive calculation of f[x] and its derivative (actually I doubt if they are the bottleneck of speed, due to my… intuition), but your code got a 1.25X speed up in my computer with the Together in your integrand[t] being taken away: gauMix[means_, vars_] := Total[Apply[(1/(Sqrt[2*Pi*#2]*Length[vars]))* E^-(((x - ...


1

l = ConstantArray[{"26.11.2014 13:56:17", "26.11.2014 13:56:18" , "26.11.2014 13:56:20"}, {10000}] // Flatten; I can get 20x speed up by converting it to DateList form: AbsoluteTime[ ToExpression@StringSplit[#, " " | "." | ":"][[{3, 2, 1, 4, 5, 6}]] ]& /@ l; // Timing {1.684811, Null}



Only top voted, non community-wiki answers of a minimum length are eligible