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

learn more… | top users | synonyms (3)

0
votes
1answer
24 views

How to select states with equal times

Can anyone show me how to select the states that have equal times-dates. For example, i have two time series. First that have 10 observations, say from 2014/10/1 to 2014/10/10, and second that have 7 ...
0
votes
1answer
31 views

Replace list of symbols in an expression

I have an expression: exp = a+b+c and a list containing all the symbols of my expression: syms = {a,b,c} and I would like ...
0
votes
4answers
33 views

Conditional combining of nested lists

I have two nested lists like those {{a,A},{b,B},{c,C}...{z,Z}} {{a,1},{c,2}...{t,12}}. I want to combine them to get a new list that looks like this ...
7
votes
5answers
686 views

Check if two lists are equal in any order

Suppose I have two lists, how can I efficiently check if the two lists are identical up to permutations of the elements? For example I would like the function to output: ...
8
votes
1answer
134 views

Strange behavior of BinCounts

Bug introduced in 8.0 and fixed in 10.0.0 Just try this example: ...
1
vote
1answer
141 views
0
votes
1answer
61 views

Rotate points by 60° in 2D

I wrote this code, to rotate a list of points 60° about the first point in the list in 2D, but Mathemtica says: "Recursion depth of 1024 exceeded."
2
votes
2answers
105 views

Matching a case when one element in a pair is Null

I've got a dataset of laitutdes and longitudes. Unfortunately, some of the dataset was from when a time when lat/longs weren't constantly recorded. So I need to remove the invalid data before working ...
6
votes
2answers
72 views

Mathematical operation on two lists by a “key” [duplicate]

I'm a complete newb here. Just looking for direction. I've got two lists like this... ...
4
votes
5answers
210 views

Summarize a list of pairs / (Using GatherBy and Tally?)

Given a list of (frencuently repeated and unsorted) pairs {Mode, SubMode} I want to form the list ...
2
votes
3answers
68 views

How to get an element of a list , which is computed out of substituted variables?

What is the best way to get the element of a list, which is computed out of substituded variables? For example one wants to get the first element of the first row of ...
1
vote
1answer
52 views

Summing subsets of array

I have an array farr, size Nx*Nx. I have a function frk that maps index {n,m} to an integer (approximately ...
0
votes
1answer
43 views

Loops for Unit Root Test

I want to compute some unit root tests on a data generating process. I already split the sample in 100 single samples, but how can I do a unit root test on all of them and store the results in another ...
2
votes
3answers
123 views

Concisely returning a position in an array with an index variable [on hold]

We have an array and an index in the array: exampleArray = Table[{a, b, "q"}, {a, 1, 10}, {b, 1, 10}]; arrayIndex = {5, 4}; Very simply, we can return the value ...
2
votes
2answers
32 views

replace an interval of values [duplicate]

I want to replace values in an interval [a,b] by 0 in a list of values. Example: {{.5,.2,.49,1,1},{.49,.5,.495,1}} I want to get: ...
2
votes
1answer
62 views

DateListPlot with multiple data sets and incongruous timelines?

I am using Mathematica to analyze some sales data for my company. (A copy of the available data is here.) We are trying to analyze the sales trends for each month by item. DateListPlot works well ...
15
votes
6answers
441 views

How can I remove B -> A from a list if A -> B is in the list?

I have a list of transformations like this: list = {"A" -> "B", "B" -> "A", "C" -> "D"} As this is used to plot an undirected graph with ...
9
votes
3answers
214 views

What is the best way to flatten a linked list with lists as values?

By following the advice on this site I have ended up with a linked list like the following: acc = {{1, 2}, {{2, 3}, {{3, 4}, {{4, 5}, {{5, 6}, {}}}}}}; This was ...
3
votes
4answers
96 views

How to Remove Undirected Edges that are the Same [duplicate]

Given: theData = {1 <-> 2, 2 <-> 3, 2 <-> 1} I would like to remove any duplicates where I define a duplicate to be: ...
4
votes
3answers
101 views

Changing the x-axis for ListLinePlot with more Lists

I'm fighting with a seemingly very simple problem: I have two lists of data, and want to plot them with ListLinePlot. The two lists are only data-points, therefore ...
4
votes
5answers
244 views

Can I generate a “piecewise” list from a list in a fast and elegant way?

Suppose we have a number list a: n = 1000000; a = RandomReal[{0, 1}, {n}]; We want to generate a list ...
1
vote
1answer
58 views

Transforming a nested list for textual output

Hello I have a data structure based on lists, with items, subitems and subsubitems, and I want to display a textual output with a description. ...
4
votes
5answers
208 views

Extracting Coefficients from a List of Sines

I want to extract the coefficients from the following list: list={16.2219 Sin[16.2219 t], 6.60924 Sin[6.60924 t], 13.927 Sin[ 13.927 t], 2.91309 Sin[2.91309 t]} ...
0
votes
2answers
34 views

How do I generate a list of delayed rules? [duplicate]

I want a list like this: {x :> Print[1], x :> Print[2], x :> Print[3], x :> Print[4], x :> Print[5]} I tried: ...
6
votes
2answers
226 views

List of tuples without forbidden pair

How do you get a list of tuples in Mathematica that do not include certain pairs of elements? For example, I'm trying to list sequences of matrices of a certain length, and I do not want two adjacent ...
2
votes
2answers
79 views

Joining two lists with diverse properties [closed]

I want to make a list from two independent ones. ...
5
votes
2answers
137 views

Conditional string replacement

I have a list of text and need to replace an element based on the text that appears in the element before it. Example of my list: ...
2
votes
1answer
102 views

Sort eigenvectors of a list of matrices

I have a list of matrices and want to obtain a list of eigenvectors and eigenvalues for each matrix, both sorted by the size of the eigenvalue. If I write ...
1
vote
1answer
62 views

Manipulate filters in arrayplot with graphical user interface

I have a set of images which need to be filtered by different filters. So I have made an interface in which the user can choose his or her filter. However I now want to manipulate the degree of the ...
4
votes
4answers
158 views

Using Cases to get elements in a list

I have the following list: ...
4
votes
4answers
114 views

Finding the position of a single array in a list of arrays that contains wildcard variables

Consider two lists: superList = {{wc,wc,1,wc,wc}, {wc, wc,2, wc, wc}, {wc, wc, 3, wc, wc}, {wc, wc, 4, wc, wc}}; littleList = {a,b,3,c,25}; In ...
1
vote
1answer
65 views
5
votes
4answers
170 views

Signed power set of a list

Given {a, b, c, ...} with $n$ elements generate a list with $2^n$ elements. For example, if the list were {a, b, c}, then the ...
4
votes
6answers
234 views
0
votes
0answers
68 views

Solution of a set of quadratic congruences (Chinese remainder)

Edit: Please remove this question. I think there are mathematics error in what I am asking. You are welcome to edit the question if you can state the problem correctly. I have a set of quadratic ...
4
votes
2answers
318 views

Rearranging a matrix

I would like to convert a matrix which has a structure like this: {{"A", 10, "D", 1},{"B", 3, "A", 2},{"C", 7, "B", 3},{"D", 6, "C", 4}}//MatrixForm//Print; ...
3
votes
2answers
147 views

How to define even permutations correctly?

I define even permutations as following, but there may be some error. I use it in two different way and get different output. ...
0
votes
1answer
90 views

Matrix Operation

I have a $3\times3$ matrix A, and a function sTrans that outputs two $3\times3$ matrices in a list when given a $3\times3$ ...
9
votes
5answers
357 views
4
votes
5answers
139 views

Counting the number of instances where items at the same position in two matrices are equal?

Given two matrices having the same dimensions: m1 = {{1, a, 2}, {4, 5, 0}, {g, a, d}} m2 = {{1, b, 2}, {7, 2, 0}, {a, a, a}} Is there a built-in function that ...
3
votes
1answer
129 views

Manipulating list of matrices

I have a list of around 100 matrices, that looks like this ...
3
votes
1answer
103 views

Recursion when randomizing elements in a list

I want to randomize certain elements of a list; Since the code list = {a, b, c, d, e, f, g}; list[[{1, 3, 5}]] = RandomSample@list[[{1, 3, 5}]]; list works fine, ...
2
votes
2answers
168 views

Constraining a random function

This question is a follow-up from here. I have a function that generates a list of correlations between some random variables: ...
4
votes
1answer
184 views

How can I randomize order of elements in a list?

Is there a straightforward way to go from an ordered list like: ord = {a, b, c, d, e, f, g, h} to a disordered list like: ...
4
votes
4answers
131 views

Sublist pattern matching

Is there any way to simplify the following pattern: {p___, {a___, x_, x_, b___}, q___} :> {p, {a, x, b}, q} Ie. where I remove duplicated elements within ...
3
votes
2answers
72 views

The conflated two uses of SameTest within Intersection

Intersection works as expected in this case... a = Range[1,5];b=Range[3,7]; Intersection[a,b] giving... {3,4,5} However if ...
6
votes
6answers
252 views

Total by a criteria

I am developing a weighted KNN algorithm. In a step, I need to do the sum of weights of each class. For example: ...
6
votes
1answer
1k views

Mutual Information involving two matrix states

I basically retrieved the following technique of evaluating the mutual information involving two matrices from this site at http://bmia.bmt.tue.nl/People/BRomeny/Courses/8C080/default.htm The ...
4
votes
2answers
138 views

Looping through a list partition

I got the following list and I would like to loop and partition this list in the following way. ...
5
votes
4answers
224 views

Pattern matching - comparing two lists

I would like to compare two different lists to see if the shorter one is a member of the larger e.g. is the list {2,3}, with that sequence of elements, a member of {1,2,3,4,5}? I have tried using ...