Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

learn more… | top users | synonyms (4)

5
votes
2answers
267 views

Ranking a vector containing ties

How can I rank a vector such that the ties are replaced by their middle ranks. For example, {1, 2, 2, 3}. I want to rank this vector but the ties must be replaced ...
0
votes
1answer
109 views

Problem with List Dimension Outer Map [duplicate]

I am currently handling a big list which has the following dimension: {6, 3, 4, 2, 2, 1, 8} where the last number 8 represent a ...
9
votes
1answer
404 views

How can I define a Listable function only apply to a vector?

Consider the function f which should behave as f[{{1, 2}, {3, 4}, {5, 6, 7}}] ...
4
votes
3answers
215 views

Variable partitioning of the data in the form of “list of lists”

I am looking for a way for variable partitioning of the data in the form of a "list of lists" for interpolating the imported data from excel. The data looks like: ...
3
votes
1answer
189 views

Levels and slots

I am struggling with levels and #, if I understand this I think I will be able to grasp the entire concept. ...
8
votes
1answer
174 views

Quickly selecting for points in a set that are within a critical distance of points in another set

Imagine two lists of two-dimensional coordinates: listA = RandomReal[{0,100},{202,2}]; listB = RandomReal[{0,100},{97,2}]; I'm attempting to quickly generate a ...
7
votes
1answer
106 views

Why does Rescale performance vary significantly based on the real number values in a list?

I have a list of the form: testList = Table[{Flatten[RandomReal[{-200, 200}, {1, 2}], 1], RandomReal[{-200, 200}, {69, 2}]}, {i, 1, 100}]; And I would like to ...
4
votes
2answers
773 views
2
votes
1answer
119 views

Can Map operations be compiled or otherwise sped up for large lists?

I'm performing a series of Map operations in the following script: ...
4
votes
2answers
163 views

Speeding up Position for finding the indices of a small number of integer elements in a large matrix

I have a large $100 \times 4000$ element matrix composed of integer elements, testMatrix, and I was to use Position to find the ...
0
votes
1answer
153 views

Generating an array using list values at indices corresponding to entries in a separate list satisfying some criterion

Imagine one has an array of integer value sets that looks like this: ...
0
votes
1answer
163 views

johansen test error in code

Cross-posted at the Wolfram community forum I have found this code on a forum, apparently it worked in a previous version of mathematica. Now when I run it, it keeps running for ages. I am not able ...
4
votes
0answers
104 views

Gather dependency on list order?

I get intrigued about Gather behavior on this post. I thought that Gather was invariant under list order? Here is the result I ...
12
votes
5answers
723 views

What's the cleanest functional-programming style way to perform this list operation?

I am looking for the correct method for accomplishing the unknown piece in the following code snippet: rolls = Tuples[Range[1, 4], {2}] ...
0
votes
2answers
524 views

Finding max value of each column of 4x4 Array

I have the following array in both MatrixForm and List form ...
1
vote
2answers
201 views

Taking a percentage of data from a list or a table

I have a list of data and for the calculation I only need the a of portion of the data. I know that Take[data, {1,100}], for example, is taking line 1 to 100 of the ...
7
votes
5answers
198 views

Selecting terms from a matrix

There are similar questions to this on the forum but none fit the purpose here: I would like to extract certain elements of a matrix depending on whether a factor is present or not, and create ...
1
vote
1answer
575 views

List plot joined with stair steps instead of diagonal lines

What's a simple way to plot a list of points so that they're joined with stair steps instead of straight lines between the points? I'd imagine something like... ...
3
votes
2answers
163 views

Using list elements in TrackedSymbols for Dynamic

During the execution of the following code a column of three lists and two sliders are displaying in output. The first list updates if either a or b changes. The second list updates only if the value ...
0
votes
2answers
283 views
1
vote
4answers
263 views

Calculating the median difference between elements with a (particular pair) of consecutive integer indices residing in the same sublist

NOTE: I formally made a serious mistake in the first example provided. pointLists[[1]] had an extra element, and we should have a guarantee that ...
4
votes
4answers
616 views

Replace For-loop with functional code

I am very new to Mathematica. I have code written using for loops. I want to rewrite it using Map/Thread but I am not sure how ...
3
votes
6answers
164 views

Change sublist based on position

Supposed that: list = {2, 3, 5, 7, 9}; sublist = {{3, 3, 5}, {2, 2, 2, 7, 9}}; I want to change each sublist in sublist as following: Find the positions of ...
6
votes
1answer
875 views

All possible topological orderings of a graph

TopologicalSort[] returns one of many unique orderings. From wikipedia: if a topological sort does not form a Hamiltonian path, the DAG will have two or ...
0
votes
2answers
253 views

Animate a sequence of bitmap-like data Mathematica 9.0.0

I am new to Mathematica, but already find it a very nice tool. Right now I am trying to create an animation of numeric data, where each frame corresponds to a distinct text file with a table-like ...
6
votes
7answers
358 views

Sum of two functions, list processing

I am creating some simple graphs of functions defined by ordered pairs. Students are learning about "operations on functions", in this case, adding functions. If I have two functions defined by ...
7
votes
5answers
244 views

Better way to make a certain list with palindromic sublists

Here is my code, which works, but seems a little too long, I think might be a more refined version. ...
4
votes
3answers
162 views

Appending to sublists using “anchor” values

Say I have a set of lists that look like this: ...
1
vote
3answers
138 views

Accessing sublists conditional on their length

Say I have a list that looks like this: ...
3
votes
0answers
68 views

Listing all combinations produced by picking one element from each of several sets [duplicate]

I have a problem like this, I am given the following sets {a,b,c}, {d,e,f}, {h,i,j}. I want to pick one element from each set, and output a list of all the ...
0
votes
2answers
103 views

How to extend “List-of-numbers-with-number” arithmetic to “List-of-X-with-X” arithmetic? [duplicate]

I'll start with a couple of examples (since this is all one can get from the documentation anyway). First, adding lists of numbers equal length is done term-by-term. E.g. ...
10
votes
4answers
291 views

Searching linked lists that contain lists?

Following the advice I've read here and other sites, I've been trying to use the Mathematica equivalent of a linked lists... ...
7
votes
6answers
212 views

How to join held Lists?

Let's say I have a = Hold@{2+2} b = Hold@{4+4} How can I get Hold@{2+2,4+4} ie join the two held lists ? More ...
1
vote
1answer
137 views

Assumptions about list elements

I am trying to simplify some expressions using assumptions and got an inconsistent behavior of Mathematica 9 when working with indexed variables. Consider ...
6
votes
6answers
319 views

Sort a list of coordinates by frequency from first component of each coordinate

The situation is that I have a List like this: ...
1
vote
2answers
391 views

How to pick a solution from a list of solutions using a test?

I have a list of solutions that depends on a parameter b3 and I'd like to get the solution for which the x value is minimal when ...
4
votes
4answers
233 views

How to construct tuples with a given order?

How do I create a list of tuples with an ordering imposed on them, where each element is from a generating set? Specifically, I'm trying to create a listing of tuples $(x_1, x_2, ..., x_n)$ such that ...
14
votes
6answers
729 views

How to find the distance of two lists?

I have two lists as the followings: ab = {1, -1, -1, -1, 1, 1}; ac = {1, -1, -1, 1, 1, 1}; How I can find the difference (more precisely, the edit distance) ...
13
votes
5answers
294 views

Can ReplacePart be sped up?

Test case: ...
10
votes
5answers
534 views

How to find first list element that differs from average of N previous elements by more than a given amount?

Given a list of real numbers, I need to write a function that returns the value of the first element in the list that differs from the mean of the previous $N$ elements by greater than $P$ standard ...
5
votes
1answer
246 views

Selecting a list from a list of lists

In working through Programming Paradigms Via Mathematica (A First Course) I have come across this two part question: A permutation of length "n" is a list of the first n positive integers in ...
11
votes
5answers
1k views

How can I simulate this animation of checking for prime numbers?

I can only implement a very simple one, I want to make my code look like that. Any better ideas? ...
2
votes
2answers
208 views

Deleting parts of groups that do not have equal dates

Find the intersection of dates within the pair and remove the other dates & corresponding prices. Also keep the list in same format as it currently is in. Let me explain: Each stock has closing ...
2
votes
3answers
478 views

Select sublists with second element nearest to zero

I've got some big lists from which i need some data (one of the big lists). To be specific, I need to divide this biglists in sublists of the same length (10000), and form a new list with the mean of ...
15
votes
3answers
632 views

How to partition a list to make each subset's size equal and mean as close as possible

Suppose we have 3 lists each with 18 numbers like this: ...
8
votes
10answers
355 views
1
vote
1answer
132 views

Extracting lists from list based on length

I have a list looking like this; ...
0
votes
1answer
128 views

Using sublists returned from a function as elements of a list argument to an other function

This is a contrived example, but it gets the point across. I am looking to use the following as inputs: ...
17
votes
12answers
2k views

Pick elements of largest absolute value

For example, given list = {{1, -3, -5}, {2, 1, 6}, {0, 2, 4}, {-9, 2, 6}} should return: {-5, 6, 4, -9} Updated I found ...
4
votes
0answers
168 views

Replacing and combining elements in a list [duplicate]

I am trying to increase the level of nesting in the following list while adding a 'tag' to each leaf: ...