penguin77
  • Member for 6 years, 10 months
  • Last seen more than 1 year ago
How to change line lengths in LineLegend
Accepted answer
9 votes

First question answered, here we go with LegendMarkerSize: legend = LineLegend[styles, {"f", "g"}, LegendMarkerSize -> 5]; Second question answered: Customize a Grid for the legend using the ...

View answer
What are the cool kids talking about when they use ##&[]?
8 votes

I believe it is important to get a fundamental understanding of what Pure Functions are that goes beyond the understanding using of a syntax. Hereafter an non-exhaustif summary of a few key ...

View answer
Comparing memory consumption of two pieces of code
8 votes

A possible alternative for getting insight on how memory efficient two approaches are, could be by using Monitor and StepMonitor functions along with MemoryInUse. For convenience a rule for ...

View answer
Indexed Map Thread
7 votes

You may consider this MapIndexed[Times, #] & /@ {{a, b, c}, {e, f, g}} // Plus @@ # & (* {{a + e}, {2 b + 2 f}, {3 c + 3 g}} *) MapIndexed applies a function (in your example Times to ...

View answer
Limit the number of processors used by ParallelTable?
7 votes

To demonstrate evaluation in parallel computing on different number of kernels 1)Default list of kernels run for parallel computing `$ConfiguredKernels` (*("<<`1` local kernels>>", ...

View answer
Why does cropping an image improve TextRecognize so much?
Accepted answer
5 votes

For this example, it seems that setting the Alpha Channel to .1 yields correct result across all languages without needing to crop. TextRecognize[img ~SetAlphaChannel~ .1, Language -> #] & ...

View answer
Customizing X-axis label for groups of 7 (weeks)
4 votes

Creating a data set dset with date values for the period of 5 months starting on a Sunday associated with random integers ( DayName @ {2015, 04, 12} (* Sunday*)). dset = DateRange[{2015, 04, 12}, ...

View answer
Folding 3-variate function with 2 iterator
Accepted answer
4 votes

Here we go using FoldList list = Array[{Subscript[a, #], Subscript[b, #]} &, {3, 1}] // Flatten /@ # & (* or Flatten[#,1]& doing the same, but faster *) FoldList[f[#, Sequence @@ #...

View answer
Grid versus GraphicsGrid use cases?
4 votes

uuhahh, there is an important big difference. Grid returns a Grid object whereas GraphicsGrid returns an Image. Therefore you will be able to apply all Image functions to GraphicsGrid as a whole, ...

View answer
how to download using weather data function many proporties exactly.
4 votes

Here the answer to your question posted in your comment in following steps: 1) Retrieve Weather data and assign to dset dset = WeatherData[ "WMO44292", #, {{1956, 8, 2, 12, 0, 0}, {1957, 8, 2, ...

View answer
Using Map sequentially
4 votes

Uuuh, that's like a breeze.... ace= {1, 14, 27, 40}; uno = Partition[RandomSample[Range[52], 52], 13]; Intersection[#, ace] & /@ uno This returns the Aces returned in each hand let's go ...

View answer
Turning a set of random walk data 45 degrees
4 votes

No need folding 1D graph to get a 2D Random walk in Mathematica. and the CCW easy in Mathematica. Here we go: Generate data set for the random sequence with 2000 steps. Alternatively, you may use ...

View answer
Make a program that does union of two lists
3 votes

Instead of using a for loop, you may consider Union straight away: Union[RandomInteger[10, 3], RandomInteger[10, 3]] (*{0, 4, 6, 9, 10} Obviously result will different for each run *)

View answer
Do TakeWhile and LengthWhile work with Greater?
Accepted answer
3 votes

I trust, you have figured out the response to your "why" question by reading the comments. For your convenience here some very common ways for selecting elements from a list. Cases[{1, 2, 3, 4, 5}, ...

View answer
Define a matrix depending on variable in Mathematica
Accepted answer
3 votes

Do you mean this ? n = 5; getA[kappa_] := Table[2*Cos[(2*π/n)*(Abs @(i - j))*kappa], {i, 0, n-1}, {j, 0, n-1}] getA[3] //MatrixForm You may post the expected result from your Python code in ...

View answer
How to stop a Dynamic[] in one notebook from hurting performance in another?
3 votes

You may consider moving the variables used for the dynamic clock into a dedicated context Dynamic[{clock`d, clock`h, clock`m, clock`s} = List @@ DateDifference[Now, DateObject[{2015, 5, 18}],...

View answer
mathematica use too much memory to Import large dat file
Accepted answer
3 votes

M9 under Windows 7, Intel Core i7 970. 24 GB RAM, Import without any problem. Alternatively you can read the file as a stream. str = OpenRead["z:\\temp\\omni_m_all_years.dat"] ReadList[str, Record]...

View answer
How to delete Missing["NotAvailable"] from list of rules?
3 votes

Less elegant than DeleteCases, however an alternative: exp = {First -> {a -> "aaaa", b -> "bbbb"}, Second -> {c -> "cccc", d -> "dddd", e -> Missing["NotAvailable"], f -&...

View answer
Apply an accumulative function to each column of a dataset
3 votes

Illustrating Rasher's suggestions for your convenience with some data set. Just create anything for the sake to demonstrate counting: dset = ElementData[#, "SoundSpeed"] & /@ ElementData[] // ...

View answer
ContourPlot: format numbers in contour labels and legend
3 votes

Replace PlotLegends-> Automatic with Barlegend combined with option LegendFunction PlotLegends -> BarLegend[Automatic, LegendFunction -> (ScientificForm[# // N] &)]]

View answer
interactively replace pixel value
Accepted answer
3 votes

One way of getting this to work is by using the Locator as a Control of Manipulate. For the convenience of easier spotting the replaced pixel I have cropped and magnified the image. image = ...

View answer
How to make legends in Graphics?
3 votes

Easy as this... Legended[grp, Grid[{Range @ 6, {"this", "asd", "asdf", "blabla", "af", "asd"}} // Transpose]] grp is your Graphics, obviously. You may fiddle around with Grid at your will for ...

View answer
Collect distributed sums
Accepted answer
2 votes

You may consider this, rl= (a_. Sum[b_. Subscript[x_, i_], {i_, i0_: 1, n_}]) :> Sum[(a b) Subscript[x, i], {i, i0, n}]; exp = Sum[2/9 Subscript[x, i], {i, 1, n}] + 2 Sum[1/9 Subscript[x,...

View answer
Strange behaviour of Append
Accepted answer
2 votes

Append has no side effect You may try AppendTo a = {x^2 + y^2 == 1}; AppendTo[a, x + y == 0] Solve[a, {x, y}] resulting in (* {{x -> -(1/Sqrt[2]), y -> 1/Sqrt[2]}, {x -> 1/Sqrt[2], ...

View answer
How to simplify and shorten pattern code?
Accepted answer
2 votes

You may consider this to produce same result as your code: n = 15; s = 11; m = 3; ip = IntegerPartitions[n, {m}]; Select[ip, Max @@ # < s && DuplicateFreeQ@# &]

View answer
How to create a recursive TreeGraph
Accepted answer
2 votes

If your are looking for a Binary tree than this may work for you: fnBTree[n_] := CompleteKaryTree[Sequence @@ # , VertexLabels -> "Name"] & /@ Join[{{1, 1}, {2, 1}}, Table[{i + 1, 2}, ...

View answer
What is the meaning of two square brackets in function definition?
2 votes

Example 3 is very different from example 1 and 2. Example 2 is a function with 4 arguments whereas example 3 has two arguments, first argument is a list with three elements{a_,b_,c_} and 2nd ...

View answer
How to import a file for processing but not for displaying?
Accepted answer
2 votes

Easy fix: Export the result in the form ExpressionML Here is the code. N[ Sum[2/10^((n*(Floor[9/n] + 1) - 9)4), {n, 1, Floor[Sqrt[ 9]]}] + Sum[ 2/(10^((n(Floor[9/n] + 1) - 9)4) (10^(n*4) - ...

View answer
Floating point arithmetic bug caused by Table[]
Accepted answer
2 votes

Set Accuracy before processing blorp, this makes you trouble free for matching numbers. SetAccuracy [#, Accuracy @ # // Min // IntegerPart] & /@ blorp or simply SetAccuracy [#, 12] & /@...

View answer
Parallel evaluation hangs before doing anything
2 votes

Did you try DistributeDefinitions[evolve] before running ParallelTable ?

View answer