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

learn more… | top users | synonyms (3)

9
votes
4answers
590 views

How to rebuild original data from a histogram?

I have data in the following form. I have a list of values and a list of frequencies that indicate how often each value has occurred. Example list of values: ...
17
votes
7answers
1k views

Find continuous sequences inside a list

I have a list which is something like this: {3,4,5,6,7,10,11,12,15,16,17,19,20,21,22,23,24,42,43,44,45,46} What I'd like to to is get the intervals which are in ...
2
votes
3answers
92 views

List Manipulation Via Conditionals

I'm trying to convert one list to another by applying a condition on the list's elements. But I can't figure out how to do this in mathematica's language. Python example below ...
8
votes
3answers
166 views

Truncating a list once all members of a set have appeared?

Consider if you would the case where we have some list of elements: list0 = {54, 4, 7, 9, 3, 54, 4, 20, 2, 456, 2, 3}; And we have some target list: ...
0
votes
0answers
47 views

Fourier Transformation of a List

As we know the FourierTransform goes a function of t ,for example, f[t] to ...
1
vote
1answer
28 views

Nested list element at position specified by a list

I'm trying to avoid constructions like Y[[X[[1]], X[[2]], X[[3]]]]. That is we have a nested list (Y) of depth $n$ and another ...
0
votes
1answer
123 views

How do I plot results of complicated calculations in Mathematica?

I am new to Mathematica and am struggling with making plots of how features of solutions vary with parameters. For example, I can find the eigenvalues and zeroes of a Sturm Liouville problem (showing ...
1
vote
1answer
57 views

Shifting Columns in an Array Efficiently

I am trying to find a more efficient way to shift the columns of the partitions of an array according to a defined slope and fill in the shifted regions with zeros I have done it below but, I know it ...
16
votes
2answers
1k views

Sorting a list with secondary criterion

Is there an easy way to sort a list on multiple levels of criteria? By this I mean, first the list should be sorted according by criteria A (the same as using the usual sort function, ...
2
votes
0answers
54 views

pattern matching and applying a function, not working as expected [duplicate]

Consider the following code G[x, y] /. a_[b__] -> Total[a @@@ Permutations[List[b]]] I expect it to give G[x, y]+G[y,x] ...
20
votes
4answers
3k views

K-means clustering

In MATLAB, there is a command kmeans() that divides an array into $k$ clusters and calculates the centroid of each cluster. Is there any command in Mathematica to ...
0
votes
1answer
55 views

ListPicker delayed output

I'm trying to make a wrapper for ListPicker that delays updating the list unless Ctrl or Shift is released. The aim is to allow nested ...
1
vote
2answers
115 views

GPA calculation from a set of randomly generated marks obtained

So, this is a homework question posed by my teacher: "A student has 10 courses. Find the ceiling value of the obtained marks and corresponding grade according to the following data Print the result ...
1
vote
2answers
65 views

how to get continuation of square matrices with periodic diagonal band automatically?

I want write a function that can automatically analyze any square matrices with periodic band diagonals and give continuations of them. But I can't figure out an elegant way to do this. Suppose we ...
3
votes
1answer
134 views

Function that returns the second argument of Reap

I'm trying to create a function that returns only the second argument of Reap. Here's my naive guess of how it would go : Reap2[x_]:= Flatten[Reap[x][[2]],1] ...
6
votes
3answers
313 views

Better answer to Santa's riddle about sum of a number's divisors?

I was hoping to find an elegant solution to this riddle, using only a line or two of Mathematica: Santa Claus was telling one of his elves: "If I multiply the age of three of my reindeer, I get ...
3
votes
3answers
122 views

Finding largest Range in a list

In a list of positive integers, I would like to find the largest n such that Range[n] is a subset of the list. So for example ...
1
vote
3answers
66 views

GatherBy based on condition imposed on index variable

Excuse me. This might be user specific question but I need your help. I have an indexed data, where positive integers are used for indexing data. I am trying to group data putting condition on index ...
2
votes
2answers
90 views

Why is Nearest not giving me expected result

I have the following list: numbers={0.,0.6,0.8,1.,1.2,1.4,1.8} Then I calculate the midpoints: ...
1
vote
0answers
38 views

Problem with ParallelTable in using externaly defined iterator [closed]

In order to reduce my computation time, I'm making some tests with parallel computation, especially with ParallelTable. Here is a simple code : ...
5
votes
2answers
107 views

TemporalData, RandomFunction, Loops: Extracting data from TemporalData sets?

I'm doing a finance project for my differential equations class to explore stochastic processes. I'm exploring IRA retirement funds. From the project write-up: Standing assumption: at time of ...
0
votes
0answers
40 views

Regarding Cycles and Lists of Functions

So, I'm trying to determine the Normal Matrix of a Least Squares Aproximation; I have a basis constituted by 8 functions f1,f2...f8; I have 9 points which constitute Datax = {x1,x2...x9} Now, I ...
4
votes
4answers
142 views

Partition list into a given number of sub-lists

I'm having quite a hard time with the following. I would like to partition a list into a list of sub-lists, in such a way that the number n of sub-lists is fixed. ...
0
votes
1answer
72 views

for loop and list

I'm new to Mathematica. I want to built a function like that; ...
2
votes
1answer
99 views

Request for Explanation in case of Replacement not working

The 2 code snippets work on a matrix ABg with 22 rows and two columns containing Strings. Some entries in column 2 are List { } to be recognized by the first Character "{". In the list some items must ...
3
votes
3answers
252 views

How can the lowest non-zero value in a nested list be found and its position in the sublist returned?

In the example code below we have a list of triples that produce one or more sublists with at least one zero value. How can the positions of the lowest non zero value in each sublist be returned ...
3
votes
4answers
282 views

How to change a value within a list of lists?

I essentially have two questions, both are related. 1) How do I change a value within a list of lists (I provided a example problem)? 2) Why does my code not work? I have a list which was created ...
0
votes
4answers
79 views

how can one select elements from a list that are satisfied a criteria which need to compare with other elements in the list?

For example: I want to select elements from a list {1,4,3,2,5} that are bigger than its previous element. {4,5} satisfies the criteria: 4 is greater than 1 and 5 is greater than 2(Ignore the first ...
1
vote
3answers
47 views

While subpartitioning the elements in list using GatherBy, can I corresponding subpartition the elements of an unrelated list?

If we have a list like the following: list1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; And we use GatherBy to subpartition is according to a test function ...
1
vote
0answers
41 views

Creating a List with Lists as entries [closed]

I'm trying to create a list A which contains 8 same elements. Each of the elements look like {0, 0, 0, 0}. I was able to do it ...
1
vote
2answers
38 views

Subpartitioning elements of a list based on some h[ri] == h[rj] test

If we have a list of elements: list = {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12}; I'd like to further partition the elements into sets where, for some ...
0
votes
1answer
58 views

How to add an extra column to a current matrix (list)? [duplicate]

a = {{-800, 1712}, {-801, 1713}, {-806, 1832}} TableForm[a] b = a[[All, 2]] - Min[a[[All, 2]]] How do I make a new matrix (list) whic looks like this ...
1
vote
2answers
42 views

Creating a list of triangle-square numbers up to n_

I have to, for a class, create a function that gives you the triangular-square numbers up to n. That said, here's the code I have: ...
2
votes
4answers
112 views

Use a categorical argument to add one layer of list structure

Consider the following nested list x = {{1,2,a}, {3,4,a}, {8,11,b}, {12,3,a}, {4,3,b}, {3,2,c}} I want to use the categorical variable ...
2
votes
2answers
86 views

Insert at specific resulting positions in multidimensional list?

I have an initial "multidimensional" list (that is, a list that is not a vector): list0 = {{1},{2,3,4},{3,4},{5}}; and I want to insert elements ...
1
vote
2answers
71 views

Insert at specific resulting positions?

I have an initial list: list0 = {1,2,3,4,5}; and I want to insert {a,x} at specific positions ...
0
votes
1answer
49 views

Plotting data from specific column

I have data like this: 1406998993.147 73 TCP_MISS/200 22284, 1406998993.158 109 TCP_MISS/200 83827, 1406998993.197 111 TCP_MISS/200 57020, If I want to plot the column 1 and ...
1
vote
1answer
86 views

Constructing new lists using Table

I tried to modify an old notebook to show a spreadsheet style output in a table. I am not getting any errors when it runs, so I think the data I am gathering and the new variables I added, ...
2
votes
1answer
60 views

How can I use parts of lists with Dynamic?

I'm a newbie - what am I doing wrong? I want to use parts of lists (vectors) in calculations but Mathematica will not evaluate anything that involves parts of lists that update dynamically. Is there a ...
2
votes
4answers
149 views

How to remove hours, minutes, seconds from list

How to remove 0 that represent hours, minutes, and seconds from a date list say a ...
0
votes
1answer
44 views

Deleting list elements at a certain level

I have a large list of 3 by 3 matrices such that the dimensions of the list for an example 100 matrices would be: {100,3,3} I have written a function that locates all the matrices I do not want and ...
0
votes
1answer
43 views

Simple arithmetic operations on elements of a list [duplicate]

How can I shift the first element of a list by 148.38 and the second element by -38.45? The data ...
2
votes
1answer
57 views

second part of a list with something like BinLists

I have a list that looks like this testList = Transpose@Table[{RandomInteger[{0, 100}], RandomReal[]}, {100}]; i.e. basically two lists in one. Using BinLists ...
1
vote
1answer
91 views

Why doesn't Thread work in this case?

The following function is supposed to pick the element of the list with highest weight, i.e., with Thread [f[{{a,1},{b,2}}]] it should make the variables ...
3
votes
3answers
124 views

How to pick the maximum of a list? Improving efficiency

I need to find the element of a list, with the highest weight. Example: ...
4
votes
5answers
133 views

New nested list from three lists

I have three lists. x = {a,b,c,d} y = {A,B,C} z = {{1,2,3},{4,5,6},{7,8,9},{10,11,12}} and I wish to construct the following list out of these three lists ...
2
votes
1answer
33 views

In each sublist, replace the value in the right part by the value in the left part

Consider the following nested list {{a,1/x},{b,2x},{c,Sqrt[x]},{d,1-1/x}} I'd like to come up with the same list where the variable $x$ is systematically ...