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

learn more… | top users | synonyms (3)

2
votes
0answers
48 views

pattern matching and applying a function, not working as expected

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] ...
19
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
50 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
112 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
284 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
119 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 ...
0
votes
0answers
46 views

NonLinearModelFit - fit parameters in form of a list [closed]

I want to fit a sum of multiple normal distributions with an exponential background to multiple data sets. My model is: ...
1
vote
3answers
63 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
89 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
35 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
104 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
24 views

Strange behavior with Permutations [closed]

I've noticed the following thing: when I address a specific part of a hand-made list like {{{a, b}, {e, f}}, {{aa, bb}, {ee, ff}}}[[1, 1]] it produces ...
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
141 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
71 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
281 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
78 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
46 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
40 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
36 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
57 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
40 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
70 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
48 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
85 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
119 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 ...
3
votes
3answers
171 views

Trouble with Position[]

I am in trouble with Position, Although my example works as expected it throws a warning. Position[{{a,b},{a,c},{a,b}}, _?(#[[2]]==b&), {1}] During ...
0
votes
1answer
47 views

Position of elements in a list satisfying some criteria - Understanding the syntax [closed]

From this post: if one wants to know the position of the elements of a list that satisfy some criteria, (s)he can do something like that: ...
1
vote
1answer
45 views

List Manipulation and Removing Cases

I've imported a large data set, manually removing headers in the .rtf file where it originates. However, when I import this data, I receive this output: ...
0
votes
1answer
57 views

How to use Hold on a variable defined as a graph

I'm working on doing operations on different graphs and getting their probability node degree distributions using a simple algorithm. If I have many defined graphs, for example: ...
15
votes
7answers
542 views

Enumerating tuples from a larger space such that all pairs of values are present at least once

I am trying to write a function that will accept a list of N lists and returns a list of N-tuples that represent all pairs of values from the original N lists at least once. To illustrate with an ...
5
votes
5answers
487 views

Efficient Indexed Sort

Suppose I have a preference for animals given by: orderOfAnimals = {"dogs", "cats", "fish", "elephants", "giraffe", "hamsters", "poodles"}; I'm given many data ...
1
vote
1answer
104 views

Find maxima and minima of data like {time,value}

I have a list of time and values of the charge and discharge of a capacitor, and i want to separate in two list of {time,value of charge} , {time, value of discharge} I know there is a lot of the ...
1
vote
1answer
48 views

How to make a table of successive values

I want a list, where each entry is of the form {x,y}. I want x to go from $-\pi / 2$ all the way up to $\pi/2$. I also want ...