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

learn more… | top users | synonyms (4)

3
votes
2answers
161 views

Looping through 3 million elements of a list to 'Set' values is slow [on hold]

I am looping through the 3 million elements of a time-series (v1, o1) and corresponding values (v2, o2). v1 contains a uniformly increasing timestamp (e.g. 1 to 3,000,000 in increments of 1) o1 ...
4
votes
1answer
97 views

Why is Reap result nested?

A minimal (toy) example for my question: i= 1; Reap[Do[Sow[i = (i + 1)^2], {4}]] (* {Null, {{4, 25, 676, 458329}}} *) I presume the entire result is a ...
-2
votes
0answers
76 views
1
vote
0answers
82 views

Entropy of lists and sublists

If we examine the following Entropy outputs below, it can be seen that the Entropy of ...
12
votes
4answers
388 views
2
votes
0answers
110 views

Brownian Bridge - Multiple Paths [on hold]

I am attempting to simulate multiple Brownian Bridges on the interval [0, 1]. I have the following snippet: ...
-3
votes
1answer
50 views

How to sort my list? Help [on hold]

I have a list={1,2,3,4,5,-6,9,3,12,0,-3}. I want to sort its, as way {even,odd,even,odd,....}. Moreover in crescent way for even and odd numbers. So the result ...
3
votes
2answers
139 views

Modifying the content of a list

If I have a long list of form {{1,2,3,4},{5,6,7,8}, ... {97,98,99,100}} how do I edit/convert it by adding the text as shown below ...
2
votes
4answers
86 views

Removing an ordered pair from a list of ordered pairs according to a certain criterion

I have a list of ordered pairs produced by evaluating {IsotopeData["Thorium226", "ExcitedStateEnergies"], IsotopeData["Thorium226", "ExcitedStateSpins"]} I'm ...
12
votes
2answers
460 views

What is the fastest way to get the nth distinct permutation of a list?

What is the fastest way to write a function nthPermutation[xs_List, n_Integer] which is equivalent to Permutations[xs][[n]] but ...
5
votes
1answer
46 views

Generating repeated elements in a list [on hold]

Is there a function in mathematica that allows you to generate repeated elements inline within a list. For example, let's say you provided this as input text: {1, 2, 3, 4, Repeat[5,3], 6, 7} ...
3
votes
4answers
141 views

Calculating expected value from paired values and weights

I'm very new to Mathematica. I just need a quick solution on how to multiply x with y when a data set is given as ...
19
votes
2answers
370 views

Is there a built-in equivalent to Python's enumerate?

Python's built-in function enumerate takes an iterable over $(a_0, a_1, \dots )$ as argument and returns an iterable over the sequence of pairs $((0, a_0), (1, ...
0
votes
1answer
48 views

Avoiding misconversion of data with ToExpression function [on hold]

I've got a list of data with the following structure which can be easily converted To expresion by some manipulation such as ...
14
votes
3answers
459 views

How to zero (or replace) the diagonal of a square matrix?

Zeroing the diagonal of a square matrix is an operation I need frequently, but somehow I still haven't managed to find an elegant solution that satisfies all these requirements: works with both ...
14
votes
8answers
383 views

Splitting a list into increasing sublists

I have a list of numbers (say, for example, {1,2,3,4,3,2,1,2,3,4,3,2}), and I want to split it into sublists so that each sublist is the (smallest) sublist whose ...
5
votes
3answers
178 views

Simple exercise using the function Cases

I'm having some trouble in the following exercise: Find which elements of the list are prime numbers or divisible by 3. list = Table[i^2 - 6 i - 1, {i, 0, 15}] ...
2
votes
2answers
119 views
9
votes
1answer
86 views

How to partition a 2-D array properly?

Given that I have the following array lst = Array[Subscript[P, #1, #2] &, {5, 5}, {0, 0}] $ \left( \begin{array}{ccccc} P_{0,0} & P_{0,1} & P_{0,2} ...
0
votes
3answers
103 views

Complement[] changes order of elements?

Consider this example: Complement[{a, y, c, d, e}, {a, c}, {d}] (*{e, y}*) However, I was expecting the result to be: ...
1
vote
1answer
140 views

Appending elements to a list in parallel table

Is there any way to store values in a list that is being computed in parallel? For example, if ParallelTable is computing some ...
0
votes
0answers
62 views

Plotting 3D data as a surface [closed]

I am having a problem plotting some data in a 3dimensional surface. These data are distributed like a surface. And I would like to plot them joining them all as a surface. The data are in the form ...
10
votes
4answers
3k views

Removing empty sets from lists

If I had a list, say, names= {"Andy", "Bob", "Carly", "Sandy", "Jeff", "Tim", "Tom", "Zach"} and I decide to pick a characteristic only a certain of them have, ...
6
votes
2answers
241 views

Modifying the elements of a list according to a given probability

Let list be a list of lists, the elements of which are random integers in the interval $[1,c]$. Each element $i$ has a probability ...
6
votes
5answers
162 views

Nested list from a flat folder list

I have a list of folders and files in my current working directory as a result of a built-in function FileNames: FileNames["*", "", Infinity]]. It looks like this: ...
0
votes
0answers
47 views

Large lists to manipulate later in chunks [closed]

If I try to evaluate either one of the following expressions: Table[n, {10^8, 10^9] Range[10^8, 10^9] I get ...
0
votes
0answers
54 views

Piecewise NDSolveValue: Nested Variable Iteration

I am attempting to make the variable Rc a piecewise-function of [z] and have it update as NDsolve iterates through the range of 'z' such as {z,0,Le), but to no avail. The following code is an attempt ...
2
votes
2answers
72 views

Perform calculation on several sublists using Map

I am trying to perform a calculation on a list containing sublists. More exact: The x-axis values are time data, progressing from zero, the y-axis data are data points, which I want to normalize. I ...
8
votes
3answers
164 views

How can I generate a $2n$-point moving maximum of a list as efficiently as MaxFilter?

This is based on the prior question, Moving maximum function?, where @rasher provided two winning solutions (i.e. clearly the most efficient): MaxFilter[list, 1] ...
0
votes
0answers
74 views

Fitting Data using GeometricBrownianMotionProcess

I am trying to fit Data (see below) using a GeometricBrownianMotionProcess, and have attached two figures. One figure is that of the Data, and the other of the GeometricBrownianMotion for given ...
2
votes
3answers
160 views

Reassigning values in Map

I have a list of lists. Minimal example: lists = {{a,b,c},{d,e,f}} I want to set the values on position 2 (b and e) to the value of their right neighbour (c and ...
1
vote
2answers
40 views

Converting data set from one form to another

I wish to convert Data to Data2. Both sets are provided below. Note that the second set has an arbitrary parameter "t". How can this be done. ...
11
votes
5answers
313 views

Partition a list into sublists of different lengths

I have the list {a, b, c, d, e, f, g, h, i} and I want to make a sub-list of the form {{{a, b}, c}, {{d, e}, f}, {{g, h}, i}} ...
0
votes
3answers
54 views

How to generate a list of outputs for function f(x,y) for a set of known (x,y) values [closed]

Say I want a list of outputs the function f(x,y)=x+y will give for x,y values of (1,5),(5,3),(0,2),(1,1),(2,6). How do I do that? I know this must be pretty straight forward. I just can't figure it ...
0
votes
1answer
29 views

Using Select function to select elements based on last element of nested list [closed]

Good morning, I have a list with each element containing a tuple and a single. It is of this form: ...
17
votes
2answers
375 views

Count number of sublists with a total not greater than a given max

Suppose I have a list of positive integers: data={1, 1, 2, 3, 3, 3, 5, 5, 5, 7, 7, 8, 8, 9, 10, 10, 12, 16, 23} I want to count the number of subsets up to ...
11
votes
2answers
190 views

why MeanFilter is nearly 100 times slower than MovingAverage for 1D array?

I used to average over my data with MeanFilter before I learn about MovingAverage and thought that these two functions are similar except that MeanFilter is more powerful for its ability to deal with ...
2
votes
1answer
113 views

Need Help Writing code to find Capparelli Partitions

I am trying to add multiple criterion to IntegerPartitions[n] so that it sorts only partitions that fit the criterion. It creates a list of list of numbers in ...
1
vote
5answers
191 views

Finding roots of transcendental equation and collecting into a list

I am working on a physics reserach project for school and I have run into some troubles working Mathematica. I am a fairly inexperienced mathematica user so any help would very much be appreciated. I ...
3
votes
3answers
190 views

Delete rows based on specific periods

I have data (.xlsx format): two columns - data in first column imported as DateObject (dates with specific time), data in second column are numbers (113388.28, 865165.98 etc.). I want to delete the ...
-2
votes
0answers
25 views

“Extract” certain elements of a list of “rules”? [duplicate]

I have the following list: {u1[0] -> 3773.62, u2[0] -> 3773.62, u3[0] -> 48.7871} I need to extract the elements on the right hand side of each rule ...
1
vote
1answer
30 views

Histogram and Random Lists [closed]

Suppose I have the following list listrand of random numbers from RandomReal[-30,30] (where the size of the list is 40). Is ...
1
vote
2answers
92 views

How to find the palindromic number I'm looking for?

I'm looking for a number which is the same when you read it reverse like 101 or 878. I have to get all numbers from 10 to 1000. There are 99 numbers. ...
2
votes
1answer
66 views

How to find the local minimum points in the multi-dimensional numerical data?

I am trying to get some local minima of an n-dimensional function (which only has numerical form). For two-dimensional function data, we can find the local minimum points from the contour plot easily. ...
1
vote
4answers
117 views

Do not expand matrices in Mathematica calculation

Here is an example of a problem I'm having. Consider that I have defined: omega={{p[t]},{q[t]},{r[t]}} x={{a},{b},{c}} R={{1,2,3},{4,5,6},{7,8,d}} What I would ...
1
vote
3answers
113 views

Scatter plot with smooth lines [closed]

I have two lists of data between which there may be some functional dependence. I want to plot one against the other (hence scattered plot) where the points are connected by smooth lines. In ...
1
vote
1answer
59 views

Assign List of Vectors to List

I want to assign a list of vectors (though each only contains one) to a list. For example, create list called "eVectors" and do ...
11
votes
2answers
190 views

Fastest way to sum the upper triangle

I feel like this is an recurring question: if there's a symmetric matrix whose diagonal is not all 0, how could I get the sum of the part of it that's above the diagonal as fast as possible? Small ...
5
votes
2answers
73 views

Nested permutations

I would like to compute all "nested permutations" (not sure if it's the right term) of a list consisting of simple elements (numbers, strings) and simple sublists (level 1 lists of simple elements). ...
0
votes
3answers
74 views

Identify a scalar, a list

I have a symbolic scalar m2 and a symbolic list (representing a 3x3 matrix) A. I want a function which does something like: ...