Questions on using or implementing more or less common data structures such as linked lists, structs, trees, tries, heaps etc. in Mathematica.

learn more… | top users | synonyms

2
votes
2answers
78 views

Merge two trees into a rectangular matrix in Mathematica

How can I merge two trees, t and s, so as to form a square matrix below, where both trees starts from top-left (as shown), and ...
10
votes
7answers
243 views

Extract left-upper triangular data from a square matrix-form list

Hopefully, this question is not too basic or obscure. I'd like an idea on how to extract this {{1}, {5, 2}, {9, 6, 3}, {13, 10, 7, 4}} from ...
4
votes
0answers
44 views

How to transform a tree-form list to matrix-form list in Mathematica? [closed]

Excuse my naive question. Is there a quick/efficient way to transform {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}} to a lower-triangular matrix-form ...
0
votes
1answer
103 views

How to fit multiple Gaussian peaks to data [duplicate]

How would I fit this data with Gaussian Peaks? I have tried various codes but none have even worked. Note: If I do Log[data], the peaks are more visible (I have tried the method from here but it got ...
1
vote
1answer
108 views

Fitting multiple peaks

I am using the code found here to fit multiple peaks of a large dataset which I don't know anything about. This was the only code I could find on the internet to do such a thing. So this is my attempt ...
0
votes
0answers
20 views

Remove background from multipeak data [duplicate]

Let's say I have a a very large list of data in the format {{n,f[n]}} so something like {{1,600},{2,700},{3,1100}...} and if this data is plotted, then it will look like a sum of Gaussian functions+a ...
1
vote
0answers
27 views

Repeat code segment from certain cell [closed]

If I have a lot of code and wish to repeat it in a different cell, but with some variables changed, how do I do it? (without copying and pasting) I tried using GoTo and Label but it did not recognize ...
1
vote
1answer
102 views

Resampling Data using Temporal Data

I am having a problem using TemporalData. I am simulating a two state system, and every time the system goes into a new state (which happens randomly), then I put ...
2
votes
0answers
54 views

Arrays with two different types of indices

Is there a way of having arrays which have, so to speak, two different depths $m,n$? From the point of view of memory usage, it would be the same as an array of depth $m+n$, but I would like to ...
0
votes
1answer
88 views

Turning table into association for Classify

I have the following sample data for 20 users. I know their sex, and the response for three yes/no questions. I am trying to building a classifier to guess their response to the third question, based ...
5
votes
3answers
335 views

Selecting numbers from a list

If I wish to select numbers which are greater than 2 or less than 1, I use the following codes respectively: ...
1
vote
2answers
130 views

Short way to query Dataset by the value of several columns

I learned how to query Dataset for rows that contain a certain value, but now I need to query for a long series of And in chain ...
23
votes
2answers
529 views

Dataset vs an association of associations

Associations with a record structure (e.g., a flat table) can be organised in one of two main ways. First as a list of associations, which is also used in the case of Mathematica's data set ...
1
vote
0answers
96 views

Custom Head for Encapsulation

Often when I'm writing a project in Mathematica, the number of arguments I must provide to functions spins out of control. I need a sort of object-oriented encapsulation approach. I've already had a ...
1
vote
0answers
191 views

Integration of graphs with datasets

Mathematica has a rich family of graph algorithms. I would like to leverage some of these for a very large tree structure. Because of the size of the structure, I would like to store it in a Dataset ...
2
votes
0answers
84 views

AVL binary search tree implementation

Is there any text-book implementation of self-balancing binary search trees such as AVL or red-black in Mathematica?
17
votes
1answer
247 views

Why do lookup times in Dataset and Association differ by orders of magnitude?

Consider the following three data structures: a list of rules, an association, and a dataset: ...
0
votes
1answer
100 views

Import and export without changing number format

I have a complex file that is the output of a program. The file contains multiple columns with data in different number formats. For example: ...
3
votes
0answers
106 views

Does Mathematica support an unordered set (e.g. hashset) data structure?

Does Mathematica support any data structure representing an unordered set (without multiplicity) of Mathematica expressions? I would like this data structure to support $O(1)$ insertion, deletion, and ...
2
votes
0answers
52 views

Does Mathematica support out-of-core Associations?

I often find myself collecting data in an Association[] which outgrows my computer's main memory. Does Mathematica support any out-of-core equivalent? Ideally, I ...
3
votes
2answers
188 views

Entropy of the elements of a general data set

I have the following data set, and wish to track the evolution of the entropy of each element within the set. I have evaluated the entropy for some elements, but how does one evaluate the entropy of ...
3
votes
4answers
113 views
2
votes
1answer
138 views

ordered tree data structure

I have a map $f:X\to \mathbb{N}$ and I wish to find $x,x'\in X$ such that $f(x)=f(x')$. Since such elements are rare, I will have to check very many elements and perform many comparisons, so I suspect ...
3
votes
1answer
111 views
4
votes
1answer
130 views

Parsing string with nested information

I am trying to parse a string, but I have no idea how to solve the following problem ...
5
votes
2answers
327 views

How would I programmatically add a row to a Dataset?

I would like to use a Dataset to track the process of a lengthy calculation over a large volume of material. Dataset appeals to me because of the power of the queries and it also looks like it may ...
5
votes
1answer
146 views

Filtering Query Nested Data (Dataset and Association)

I am trying to filter a nested Dataset. I have some data that looks like this (curated for this example): ...
3
votes
2answers
276 views

Mathematica data structures for analysis [closed]

I'm starting to learn Mathematica and one thing that has been bugging me is the apparent lack of a good structure for keeping data and metadata for analysis. Something along R's ...
2
votes
1answer
141 views

Structure of KernelMixtureDistribution and SmoothKernelDistribution

I would like to know more about the structure behind the KernelMixtureDistribution and SmoothKernelDistribution in Mathematica. ...
21
votes
1answer
273 views

Make my data-structure atomic

Lately, and by lately I mean since version 7 or so, the number of atomic expressions in Mathematica constantly grew. In former times only the native types like integers and optimised arrays were ...
0
votes
1answer
97 views

Right data format when EmpiricalDistribution expects “Rectangular Array”

I have the following code to generate random data (these are the eigenvalues of a non-central Wishart matrix, and I am interested in their distribution). ...
15
votes
1answer
242 views

Why won't SparseArray let me store values with the head List?

When you attempt to define a SparseArray with elements that have the head List it complains: ...
3
votes
3answers
198 views

Breaking up combined data into several smaller data sets

I have one combined data with first number as the x-value and the remaining as different y-axis values (y1,y2,y3...). How do I break this combined list, data= (x,y1,y2,y3...) into smaller lists, such ...
14
votes
0answers
407 views

Learning Resources for Data Science in the Wolfram Language

I'm delivering an upcoming course on Data Science with the programming/analysis done predominantly in the Wolfram Language. I created the following table to leverage students' familiarity with Lists ...
15
votes
3answers
785 views

Converting hierarchies of rules to associations

The impossibility of MatchQ-ing inside and Association MatchQ-ing Associations (MMA 10) explains a problem I have. I would like ...
3
votes
1answer
453 views

how to create Dataset after importing txt file

I would like to translate a imported txt file to Dataset. ...
0
votes
4answers
147 views

Using levels in MapIndexed

I am trying to use MapIndexed to manipulate a matrix of data but I am having trouble getting the levels parameter to work the way I would like. Suppose that my data ...
26
votes
3answers
1k views

Error changing Dataset using Part

Update It was a bug in the documentation of V10.0, this functionality was not implemented yet, and V10.1 changed the documentation, removing it. It's a pity, because it's a very useful operations, ...
104
votes
3answers
5k views

How to make use of Associations?

I have been curious about it for long. Now that Mathematica 10 arrives, I think it's time to ask the question: How the new Association data structure would be used ...
1
vote
0answers
143 views

What's a non-trivial Mathematica program involving conscious choice of stack vs. queue data structure?

In a typical computer science algorithms course, much attention is given to the discussion of queues vs. stacks as a data structure programmers need to consciously choose from to achieve algorithmic ...
39
votes
2answers
3k views

How can I add a column into a existing Dataset?

I'm very excited about the brand new Dataset function. I have played with it in Wolfram Cloud, and haven't figured out how can I add a new column into an existing ...
1
vote
0answers
80 views

Data structures sought for storing particular list information

I have a set of lists. These lists contain two dimensional coordinates of natural numbers. So a list can be ...
1
vote
1answer
71 views

DownValues Type Access and Timing

I definitely use so much DownValues structure for some many applications like to replace some common structures in a some way. It seems that DownValues is so fast for access, and set. My question is ...
2
votes
2answers
117 views

Extracting “records” from a matrix

From a rank 3 matrix like ...
4
votes
2answers
857 views

What is the Mathematica way of joining two tables?

Is there a special Mathematica way of joining tables of data together, so that I would get similar functionality as if I was running a database with sql? For example, I have one particular table ...
2
votes
2answers
987 views

Get positions of all non zero matrix elements

I want to find all non zero elements of a table and I want to create a list that contains the name of the table the element was removed from, the position of the element, and the value of the element. ...
0
votes
1answer
103 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$ ...
2
votes
1answer
941 views

Interpolation: Unstructured grid error

If I try to make a table SimpleTable and to interpolate a function of two variables, I encounter a problem. For example: ...
2
votes
3answers
370 views

Re-arranging / selecting of a data table very slow in For loop [duplicate]

My task is quite simple; I have a table of data like M = {{1,2}, {1,3}, {3,4}, {5,1}, {6,9}, {6,8}, {6,1}}; so the table is sorted with respect to the first ...
3
votes
1answer
169 views

Reading many single files and creating numbered (? or indexed) variable

I tried many different approaches, but I could not solve the following problems, I appreciate your help: What is the best way to read many data files? I mean we have ...