TransWikia.com

Handling lists indexed with integer partitions

Mathematica Asked on April 17, 2021

I am trying to do some exploration around the multi-dimensional version of [truncated moment problem], where I work with various distributions (uni- or multi-variate), and use some truncated moment sequences of them. I frequently use three different types of sequences:

  • when the distribution is a fully independent joint, the truncated sequence is represented as a $Ktimes tau$ matrix,
    where $K$ is the valence of the distribution and $tau$ is the truncation to the order of moments;
    from this matrix desired joint moments can be readily computed.

  • when the distribution is correlated:

    • independent truncations $tau_k$ for each variate $x_k$: the truncated sequence is represented as a $tau_1timestau_2timescdotstimestau_K$-dimensional array
    • one overall truncation $tau$: sometimes I need all the joint moments whose order is $leqslanttau$; if I use the previous scheme, I would have to save a $tau^K$-dimensional array, where the majority of entries are not used.

Therefore, I am trying to find out which construct I should use to represent the third kind of truncated sequence. The options that I currently know of are:

  1. a ragged array (a nested List in which each sublist is of different length)
  2. an association (hash map) where I use multi-indices (Lists with integer entries) as keys.

Which has the better performance? Is there better ways to handle such arrays?


Update I find a similar question at MMA SE; the accepted answer suggests using a dispatch table, but as associations are introduced, won’t (speaking for this case only) replacing dispatch tables with associations avoid invoking the pattern-matching mechanism and make things faster?

Theoretically, with some optimised byte alignment, float-valued integer-partition (from now on I’ll call them intpart for short) indexed arrays can be represented compactly in the memory; these however may be slow to access, and will definitely be hard to mutate. A hash map is a more flexible alternative. The real problem is which Wolfram built-in hashes the way best suited for this case (for the lack of better phrasing). Compared to Dispatch and Association, is using compiled ragged lists a good idea?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP