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"]


4

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


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, ...


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 ...


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] ...


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_ -> ...


1

You could always use brute force: max = 10^12; ( sq2 = Range[Floor[Sqrt[max/2]]]^2; sq2 = sq2[[2 ;;]] + sq2[[ ;; -2]]; sq3 = Range[Floor[Sqrt[max/3]]]^2; sq3 = sq3[[3 ;;]] + sq3[[2 ;; -2]] + sq3[[;; -3]]; Intersection[sq2, sq3] ) // Timing {0.046800, {365, 35645, 3492725, 342251285, 33537133085}} Not as elegant as the others, but quite ...


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