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

learn more… | top users | synonyms (3)

1
vote
3answers
64 views
0
votes
3answers
80 views

string to complex number

Consider the following list MyList= {-0.0000396, -0.0000187167, "0.10259130990561813-0.0677132394802944i"} Head /@ MyList (* -> {Real, Real, String} *) In ...
2
votes
1answer
156 views

What is an elegant way to aggregate two cash flows

When modeling a swap contract a common operation is to sum up two cash flows producing a resulting cashflow with netted amounts in the highest granularity of the two initial cash flows. What is a ...
5
votes
3answers
261 views

Question about Map and Total

Suppose I have a list and I want to generate a new list, such that $$ NewList[index] = \sum_{index \neq j}^{NumOfElts} \frac {1}{ \lvert OldList[index]-OldList[j] \rvert ^2 } $$ Can I do it using ...
0
votes
1answer
58 views

Produce a 1-dimensional list of all unique matrix elements

We have some symbolic matrix m, e.g. m={{1, x, 4 x + y},{0, x y + 4x, 4x},{7 x, x, 4x + x y}} and we want to produce as output a list of all the unique elements ...
0
votes
2answers
95 views

Result of NIntegrate ploting to list

I've been working on a project where I need to make two Plots. Those plots are of the form: ...
1
vote
1answer
165 views

Partitioning time series data in sublists by their duration

I would like to do calculations on irregularly sampled time series data at intervals - for example on an hourly basis - rather than over the whole time series. The entire dataset is split up by time ...
15
votes
7answers
1k views

How do I check if any element in a list is positive?

As a simple example of what I would like to do, suppose I have a list a of all real numbers. I would like to perform a simple check to see if some element of ...
2
votes
2answers
144 views

Replacing values above a threshold with 1 [duplicate]

I have a list with some values and I want to replace a value which is greater than 1 with 1 otherwise keep the value. In this case 10562: ...
5
votes
5answers
490 views

Replace values which obey certain criteria

I'd like to replace all values in a list which obey one or more criteria with another value. Example: Replace all values>30 by 30. data={{3,35},{2,7}} ...
7
votes
5answers
309 views

LengthWhile until first duplication

I have the need to trim each of a large number of potentially very long lists (10^6+ elements) to the length where the last occurrence of any distinct element happens, or said another way, where the ...
0
votes
2answers
88 views

Handling output that was returned unevaluated from a function

When evaluating functions, including those described in this post, how do Mathematica users handle values returned from a function that are unevaluated? For example (based on 1): ...
1
vote
2answers
158 views

Mapping functions over multiple lists

I am not sure if this is a duplicate. Spent some time looking over list-manip questions. I’d like to know the Quickest Way to achieve the following Mapping of a function over multiple lists. ...
1
vote
1answer
77 views

Experiment with TagSetDelayed involving Part

Reading Associating Definitions With Different Symbols, I was intrigued by this: You can think of upvalues as a way to implement certain aspects of object-oriented programming. A symbol like ...
5
votes
6answers
836 views

How to select all elements above the main diagonal of matrix?

How to select all elements above the main diagonal of matrix? I need to create a list of them.
9
votes
4answers
1k views

Semi prime numbers

The high school textbook I am using has the example of semi-prime numbers. They wanted students to find (by "perspiration") all the semi-prime numbers less than $50$ (for a question on set theory). ...
2
votes
2answers
98 views

Elegant way to rearrange year/date table into time series/values

I often have data in the form of YEAR JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC 1950 -1.022 -1.146 -1.289 -1.058 -1.419 -1.36 -1.334 -1.05 -0.578 -0.395 -1.151 -1.248 1951 ...
2
votes
2answers
138 views

How can I thread lists of different sizes?

What I need is the equivalent of Maple's zip(+, A, B, 0). Sure I can get it with: ...
6
votes
5answers
246 views

Find positions of duplicates that are neighbours

Assuming the following list {1,2,3,3,5,6,3} I would like to get the position of values that are next to each other and are duplicates. That is, the output should be {3,4}. Thank you for any help. ...
1
vote
3answers
181 views

Generating a list of cubefree numbers

I am trying to generate a list of cubefree numbers (i.e. numbers when prime factorized contain no tripled factors) within a given range. Of DivisorSigma, ...
1
vote
1answer
102 views

Selecting every last element of a nested list

I couldn't find a similar question so I decided to ask this one. I have a nested list with many sublists of equal length. To make things easier let's say it's like that: ...
2
votes
1answer
49 views

Intersection does not take list of lists

The function Intersection takes a number of lists (sets) and finds their intersection. However, the precise input is ...
3
votes
7answers
255 views

How to replace plus sign by comma

I want to replace plus by comma and the order of numbers in the list should be in increasing order. Example: a1 + a10 + a11 + a13 + a2 + a27 + a28 In this ...
1
vote
2answers
105 views

Sorting lists element by element [duplicate]

I have a problem regarding list sorting. Let's say I have a list of lists obtained using Subsets[], of the form ...
5
votes
3answers
306 views

Fast method for combining two lists

I have two lists, v1 and v2. Each element of the lists may be positive or negative. I want to create a list ...
0
votes
2answers
71 views

Specifying an array that may have an unknown number of entries [duplicate]

Say I'm running some process of unknown duration, and during the process, I need to periodically record the state of some variable. If we knew exactly how long the process took, we could simply ...
1
vote
1answer
42 views

Evaluating the tensor product many times for a given list

I need to evaluate the tensor product 10 times in a given list( {g,e,r}) Here I have evaluated for 3 times... ...
0
votes
1answer
251 views

Table - find index of the maximum element [duplicate]

Let's suppose that I have table t = {1.23, 3.4, 10, 34, 1.78, 0.98, 12.56}. To take the biggest element I can use Max[t] ...
1
vote
1answer
124 views

ListPlot doesn't shows all points [closed]

I have a table: p1 = Table[(Binomial[2000, k]*StirlingS2[1386, k]*k!)/(2000^1386), {k, 1, 1386, 1}]; I used ListPlot[p1] ...
2
votes
3answers
120 views

Counting instances where the two identical characters are at the same positions in two strings

Let $s_a$ and $s_b$ be two strings over a $q$-ary alphabet. For each character $(c_1,...c_q)$ in the alphabet, I'd like to return a pair of values $(r,k)$ where $r$ represents the count for the ...
7
votes
6answers
223 views

Faster list duplicate 'limiter'

Given some list, e.g., {5, 3, 2, 3, 1, 0, 1, 3, 5, 5, 4, 5, 1, 2, 5, 2, 2, 0, 1, 4}, I need to limit the duplicates, if any, to an arbitrarily chosen number. The ...
0
votes
1answer
30 views

Error about limit MaxExtraPrecision

After my evaluations I have an error: N::meprec: Internal precision limit $MaxExtraPrecision=50. reached while evaluating ... ...
1
vote
2answers
49 views

Choosing a position in an array with uniform random probability conditioned on it having a specific element

I have an array exArray with two types of integer elements: 1 and 2. I'd like to choose a ...
2
votes
2answers
38 views

Specifying an array with a specific number of copies of two elements

To specify an array of length L in Mathematica, where each entry is someElement, I'm accustomed to writing: ...
0
votes
0answers
15 views

logarithmic distribution of a range in fixed number of elements [duplicate]

I want to distribute a range between 4 to 93 in 50 numbers which are logarithmically distributed. How I can do this in mathematica?
7
votes
3answers
245 views

When does a list contain only ones?

I am starting with a list of length n that contains all -1's. For instance, when n = 6 the list is {-1, -1, -1, -1, -1, -1}. I ...
12
votes
4answers
1k views

Moving maximum function?

How can I construct a moving maximum function? For example, if I have a list of 12 values: { 5, 6, 9, 3, 2, 6, 7, 8, 1, 1, 4, 7 } and I want to maximize over 3 ...
1
vote
3answers
114 views

Distinguishing slots in a function mapping Position across a list

Suppose that I have a list myList that has more than one level. Here is an example of such a "data structure": ...
0
votes
1answer
130 views

Monitor the list for changes

I wrote a function to monitor the list of variable. What it does is if the variable in list change, the changed variable will be separated from others. check the function and output ...
2
votes
3answers
110 views

Quickly plotting (number of events) vs. (time) for a very large number of events encoded as pairs of real numbers representing start and end times

I have an array that looks like the following: exampleArray = {{t1,r1},{t2,r2},{t3,r3},{t4,r4},{t5,r5},...}; Where each pair of real numbers $(t_k,r_k)$ ...
21
votes
5answers
429 views

More efficient way of generating list of occurrence counts?

Given a list, e.g., target = {a, b, c, b, c, d, c, d, e, f, a, h, g}, I want to generate a list containing the occurrence count of the corresponding element of the ...
0
votes
1answer
61 views

how to filter out numbers of specific type in a table

I am working with a way to generate a table of some numbers, but the one functions could return the complex numbers which I don't want. I am going to filter out the complex numbers. The only way I can ...
4
votes
4answers
790 views

Select a repeated element in a list

I want to select all elements that repeat 4 times in the list. I propose this code ...
1
vote
2answers
94 views

How to create automatically some matrices for symbolic manipulation?

I want to create in an automatic way some matrices to do symbolic calculations with them. They look like these: $$ \left( \begin{array}{cccc} a & 0 & b & 0 \\ 0 & 1 & 0 & 0 ...
1
vote
4answers
189 views

List manipulation: position & max value combination

Starting with {{0, 0, 0}, {1, 1, 2}, {2, 3, 3}, {3, 4, 5}} I would like to get {{0, 2, 3, 5}, {1, 3, 2, 3}} where the ...
0
votes
1answer
100 views

Using DeleteCases with multiple AstronomicalData properties

I am attempting to use AstronomicalData and DeleteCases together to remove invalid cases of two properties while listing the ...
1
vote
2answers
107 views

Computing lists using AstronomicalData

Edit: Initially in my question I asked how I could search the database of AstronomicalData["Exoplanets"] and return 2 filtered values that only contained valued ...
5
votes
1answer
165 views

What is the fastest way to maintain a large set of expressions?

In my algorithm I need to maintain a set (an unordered list of distinct elements) of expressions supporting two operations: Test an expression for membership in the set Adding a new expression to ...
4
votes
1answer
304 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 ...
1
vote
1answer
96 views

MapThread multiple functions onto multiple lists

I'm trying to learn the functional style which seems to prevail in Mathematica. I'm having trouble accomplishing the following: Let's say I have multiple lists of arbitrary data (using two lists ...