Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
0
votes
One to Many Lists Merge
(* combine[expr_, l_] :=
With[{matches = Select[l, First[#] == First[expr] &]},
If[Length[matches] == 0, {Append[expr, Missing[]]},
Map[Join[expr, Rest[#]] &, match …
1
vote
Find maxima and minima of data like {time,value}
To find minima, run the same command with your data negated. To find the times and values, do
Transpose[{data[[PeakDetect[data]], 1]], FindPeaks[data[[All, 2]]]}]
2
votes
Short way to combine the elements of a list with an operation
For the particular question:
If[Or @@ (# > 1& /@ a), 1, 0]
but there is a problem you should be aware of: Or returns immediately after a True clause, so if your list is $10^{10}$ long, the version …
4
votes
Accepted
Swapping of elements
Assuming I understand the question correctly,
Permute[xp, Cycles[{{1, 21}}]
will do the needful. Notice that this works to effect an arbitrary permutation of the elements.
1
vote
Issue with very large lists in Mathematica
This looks like a bug, but presumably a workaround is to use a hash table. That is, in @Szabolcs's code, change the first line to:
Table[arr[i] = RandomInteger[10, 5].x^Range[5], {i, 1, 1000000}];
…
4
votes
Sublists of Random Permutations
mrandomperms[n_, m_]:= Table[PermutationList[RandomPermutation[n]], {m}]
Was my initial answer, but, as pointed out by Mr. Wizard, PermutationList should be given $n$ as a second argument, since othe …
0
votes
Working with calculations that depend on the previous value in a list
I am not sure what it is you are trying to do, but presumably
list = foo /@ RotateRight[list]
is something like what you want?!
The most general solution involves the function ListConvolve[] whic …
0
votes
Why does Arrays interpret lists as Cycles?
I don't understand the question: Mathematica likes to represent permutations as products of cycles (do a help on "Permutations"), so it seems natural that it would represent the symmetry group of the …
0
votes
Easy way to covert a Range or set of vales to an Interval object
Well, here is the simplest I can think of:
foo[l_, x_] := Module[{ll = l[[-1, -1]]},
If[ll + 1 == x, Append[l[[;; -2]], Append[l[[-1]], x]],
Append[l, {x}]]]
z[l_] := Fold[foo, {{l[[1]]}}, Rest …
5
votes
Better way than using multiple flattens?
This will certainly be less efficient, but is slightly shorter:
ReactionPower = Tr[RF1.Transpose[RF1vel] + RF2.Transpose[RF2vel]];
1
vote
2
answers
179
views
quantilization (if that is a word)
Suppose I have a list of data, and a list of quantiles ({0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9} is a perennial favorite), and I want to assign to each element the quantile it is in (so for Range …
4
votes
To overcome iteration limit and trying to speed up
To answer the specific question, I think that instead of Apply[Dot, l],
Fold[Dot, l] will not run into any problems. Of course, all the other comments are valid.
9
votes
3
answers
4k
views
Generating random symmetric matrix
Suppose first that I want to generate a matrix whose elements are independent and identically distributed (i.i.d.) with distribution dist. This is easy:
randMat[dist_, n_, m_] := RandomVariate[dist, …
3
votes
Accepted
Replace $z$ with interpolated function and plotting
I am not sure what you are trying to do exactly, but this works fine:
ContourPlot[w[x, y, z] /. z -> int[x, y], {x, 0, 8}, {y, 0, 8}]