# Manipulating Linear Tables with Multiple External Intervals and Quantities

**URL:** <https://community.wolfram.com/t/manipulating-linear-tables-with-multiple-external-intervals-and-quantities/14047>\
**Category:** Ideas\
**Tags:** discrete-mathematics, graphics-and-visualization\
**Created:** [May 5, 2019, 6:43pm UTC](https://community.wolfram.com/t/manipulating-linear-tables-with-multiple-external-intervals-and-quantities/14047 "2019-05-05T18:43:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quimicalobo](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/quimicalobo/32/8777_2.png) [@quimicalobo](https://community.wolfram.com/u/quimicalobo)\
**Post date:** [May 5, 2019, 6:43pm UTC](https://community.wolfram.com/t/manipulating-linear-tables-with-multiple-external-intervals-and-quantities/14047/1 "2019-05-05T18:43:39Z")

</div>

This topic is just about some examples of table manipulation. There are several types of operations that can be done. If anyone wants to add some types is very welcome to post here. This is a simple example of a linear table with internal range and made with a certain amount of repetitions:

```
Flatten[Table[Table[n1, {n1, 11, 19}], 3]]

```

![6618i1.png](https://global.discourse-cdn.com/wolfram/original/2X/0/072ac41a43bf0ef23a45106045ae56573ccb6a4c.png)

Below is an example of a table with only one interval and quantity control, both external to the command, as well as some manipulations such as: organization, order, quantity numbers of each type, random permutation, and random choice.

- Table manipulation with external interval and quantity controlled.

 ![7629i2.png](https://global.discourse-cdn.com/wolfram/original/3X/d/5/d5aa43678de69505e5570d6089e68e644b19d260.png)

Now a similar type of table but with multiple ranges outside the command and only one quantity control:

- Table manipulation with multiple external intervals and quantity controlled.

 ![6431i3.png](https://global.discourse-cdn.com/wolfram/original/3X/9/c/9ce8531b719d34591ef0bb8ad15924231d443762.png)

```
ListPlot[r1] (* before random permutation *)
ListPlot[r2] (* after random permutation *)

```

 ![7939i4.png](https://global.discourse-cdn.com/wolfram/original/2X/0/07071e20080a091a6b7284ac2177a360d8f6ee56.png)

Below is another type of table, but with multiple external intervals and quantities of each interval controlled separately as well as some other variations of manipulations:

- Table manipulation with multiple external intervals and multiple quantities controlled.

 ![1824i5.png](https://global.discourse-cdn.com/wolfram/original/3X/4/a/4ab7ea89576df1b2e558a29b71f4ba33d333cdfb.png)

```
ListPlot[r21] (* before random permutation *)
ListPlot[r22] (* after random permutation *)

```

 ![1983i6.png](https://global.discourse-cdn.com/wolfram/original/3X/f/6/f65840eec7ee09b1a0147dab0d48d628e0a5fad1.png)

These are just a few examples, the ones I know, and if there are other ways or types of manipulation I’d love to know. That topic is about that.

Thanks.

---

<div class="post-metadata">

**Author:** ![quimicalobo](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/quimicalobo/32/8777_2.png) [@quimicalobo](https://community.wolfram.com/u/quimicalobo)\
**Post date:** [May 6, 2019, 1:27pm UTC](https://community.wolfram.com/t/manipulating-linear-tables-with-multiple-external-intervals-and-quantities/14047/2 "2019-05-06T13:27:48Z")

</div>

Thinking of ways to do more or less complex interpolations and multiple interpolations at the same time can be this way using the Table command:

```
x = {{1, 2, 12}, {2, 4, 24}, {3, 8, 38}, {4, 16, 416}, {5, 32, 532}};
y = {{3, 6, 36}, {5, 10, 510}, {7, 14, 714}, {9, 18, 918}, {11, 22, 
    1122}};
z = {{5, 10, 15}, {10, 15, 20}, {15, 20, 25}, {20, 25, 30}, {25, 30, 
    35}};

h1 = Table[{FromDigits[Take[FromDigits[Take[x, {m}]], {1}]], 
   FromDigits[Take[FromDigits[Take[y, {m}]], {1}]], 
   FromDigits[Take[FromDigits[Take[z, {m}]], {1}]]}, {m, 1, 
   Count[x, _]}]
(* get {x11,y11,z11},{x21,y21,z21}... *)

h2 = Table[{FromDigits[Take[FromDigits[Take[x, {m}]], {2}]], 
   FromDigits[Take[FromDigits[Take[y, {m}]], {2}]], 
   FromDigits[Take[FromDigits[Take[z, {m}]], {2}]]}, {m, 1, 
   Count[x, _]}]
(* get {x12,y12,z12},{x22,y22,z22}... *)

h3 = Table[{FromDigits[Take[FromDigits[Take[x, {m}]], {3}]], 
   FromDigits[Take[FromDigits[Take[y, {m}]], {3}]], 
   FromDigits[Take[FromDigits[Take[z, {m}]], {3}]]}, {m, 1, 
   Count[x, _]}]
(* get {x13,y13,z13},{x23,y23,z23}... *)

h123 = Table[{FromDigits[Take[FromDigits[Take[x, {m}]], {1}]], 
   FromDigits[Take[FromDigits[Take[y, {m}]], {2}]], 
   FromDigits[Take[FromDigits[Take[z, {m}]], {3}]]}, {m, 1, 
   Count[x, _]}]
(* get {x11,y12,z13},{x21,y22,z23}... *)

h321 = Table[{FromDigits[Take[FromDigits[Take[x, {m}]], {3}]], 
   FromDigits[Take[FromDigits[Take[y, {m}]], {2}]], 
   FromDigits[Take[FromDigits[Take[z, {m}]], {1}]]}, {m, 1, 
   Count[x, _]}]
(* get {x13,y12,z11},{x23,y22,z21}... *)

```

 ![interp1.png](https://global.discourse-cdn.com/wolfram/original/1X/a849dcb49848f3c59be79c016dce13dc21bc8be8.png)

Or we can change the order of x, y, z by swapping the letters within the code:

```
hzyx = Table[{FromDigits[Take[FromDigits[Take[z, {m}]], {1}]], 
   FromDigits[Take[FromDigits[Take[y, {m}]], {1}]], 
   FromDigits[Take[FromDigits[Take[x, {m}]], {1}]]}, {m, 1, 
   Count[x, _]}]
(* get {z11,y11,x11},{z21,y21,x21}... *)

hyzx = Table[{FromDigits[Take[FromDigits[Take[y, {m}]], {1}]], 
   FromDigits[Take[FromDigits[Take[z, {m}]], {1}]], 
   FromDigits[Take[FromDigits[Take[x, {m}]], {1}]]}, {m, 1, 
   Count[x, _]}]
(* get {y11,z11,x11},{y21,z21,x21}... *)

```

![interp2.png](https://global.discourse-cdn.com/wolfram/original/3X/0/8/081acbcf05d87ac35d2fccd2c1c2572ac8ee2b02.png)

Or even interpolate by doing both things, swapping x, y, z and positions simultaneously:

```
hy2z3x1 = 
 Table[{FromDigits[Take[FromDigits[Take[y, {m}]], {2}]], 
   FromDigits[Take[FromDigits[Take[z, {m}]], {3}]], 
   FromDigits[Take[FromDigits[Take[x, {m}]], {1}]]}, {m, 1, 
   Count[x, _]}]
(* get {y12,z13,x11},{y22,z23,x21}... *)

```

![interp3.png](https://global.discourse-cdn.com/wolfram/original/2X/f/f377d123b009049802b10b523c9a88830adf4eb6.png)

These are just a way to do multiple simultaneous interpolations, if anyone knows how to do this using faster or shorter codes can help in this topic? Thanks.

---

<div class="post-metadata">

**Author:** ![quimicalobo](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/quimicalobo/32/8777_2.png) [@quimicalobo](https://community.wolfram.com/u/quimicalobo)\
**Post date:** [May 8, 2019, 3:55pm UTC](https://community.wolfram.com/t/manipulating-linear-tables-with-multiple-external-intervals-and-quantities/14047/3 "2019-05-08T15:55:01Z")

</div>

Now doing the manipulations. First with an external range to the command and the quantity being controlled. Note: to change the result of random permutation just change the seed number.

```
intervalk = {11, 19}; 
quantityk = 3; 
seed = 124;

r = {SeedRandom[seed]; 
   BlockRandom[
    RandomSample[
     rx = Flatten[
       Table[Table[
         ii2, {ii2, FromDigits[Drop[intervalk, -1]], 
          FromDigits[Drop[intervalk, 1]]}], quantityk]]]]};
rx
r

```

![ii1.png](https://global.discourse-cdn.com/wolfram/original/3X/1/2/12e2a62e0e338e9d8230edde25d4c890a69559b6.png)

```
Manipulate[
 ListPlot[Flatten[
   Table[Table[
     ii2, {ii2, FromDigits[Drop[intervalk, -1]], 
      intervals}], {quantity}]]], {quantity, 1, 
  quantityk}, {intervals, FromDigits[Drop[intervalk, -1]], 
  FromDigits[Drop[intervalk, 1]]}]

```

 ![ii2.png](https://global.discourse-cdn.com/wolfram/original/3X/2/9/297ae2a1b32b364e1115d66c7f6df6b23dab1e90.png)

```
Manipulate[
 ListPlot[BlockRandom[
   RandomSample[
    Flatten[Table[
      Table[ii2, {ii2, FromDigits[Drop[intervalk, -1]], 
        FromDigits[
         Drop[intervalk, 1]]}], {quantity2}]]]]], {quantity2, 1, 
  quantityk}]
Do[Print[BlockRandom[
   RandomSample[
    Flatten[Table[
      Table[ii2, {ii2, FromDigits[Drop[intervalk, -1]], 
        FromDigits[Drop[intervalk, 1]]}], {g}]]]]], {g, 1, quantityk}]

```

 ![ii3.png](https://global.discourse-cdn.com/wolfram/original/3X/d/6/d6507065ee8a411810ed3889c60bc6a8e790d84f.png)

Then with multiple intervals outside the table and with the quantity of repetitions controlled. Again to have new random values in the permutation just change the number of the seed.

```
intervalsk = {{7, 9}, {2, 5}, {19, 20}, {15, 17}};    
quantitiesk = 2;   
seed = 124;

r2 = {SeedRandom[seed]; 
   BlockRandom[
    RandomSample[
     r1 = Flatten[
       Table[Table[
         Table[a2, {a2, 
           FromDigits[Drop[FromDigits[Take[intervalsk, {b}]], -1]], 
           FromDigits[
            Drop[FromDigits[Take[intervalsk, {b}]], 1]]}], {b, 1, 
          Count[intervalsk, _]}], quantitiesk]]]]};
r1
r2

```

![ii4.png](https://global.discourse-cdn.com/wolfram/original/3X/3/d/3dfa8fc3ad3bf918717d7708a4fca2e796e388e0.png)

```
Manipulate[
 ListPlot[Flatten[
   Table[Table[
     Table[a2, {a2, 
       FromDigits[
        Drop[FromDigits[Take[intervalsk, {intervals}]], -1]], 
       FromDigits[
        Drop[FromDigits[Take[intervalsk, {intervals}]], 
         1]]}], {intervals, 1, intervals}], quantities]]], {intervals,
   1, Count[intervalsk, _]}, {quantities, 1, quantitiesk}]

```

 ![ii5.png](https://global.discourse-cdn.com/wolfram/original/2X/c/ccc7eb7910706af12a0d5ddf4ce77079103d2277.png)

```
Manipulate[
 ListPlot[BlockRandom[
   RandomSample[
    Flatten[Table[
      Table[Table[
        a2, {a2, 
         FromDigits[
          Drop[FromDigits[Take[intervalsk, {intervals2}]], -1]], 
         FromDigits[
          Drop[FromDigits[Take[intervalsk, {intervals2}]], 
           1]]}], {intervals2, 1, intervals2}], 
      quantities2]]]]], {intervals2, 1, 
  Count[intervalsk, _]}, {quantities2, 1, quantitiesk}]
Do[Print[BlockRandom[
   RandomSample[
    r1 = Flatten[
      Table[Table[
        Table[a2, {a2, 
          FromDigits[Drop[FromDigits[Take[intervalsk, {b}]], -1]], 
          FromDigits[
           Drop[FromDigits[Take[intervalsk, {b}]], 1]]}], {b, 1, b}], 
       quantities2]]]]], {quantities2, 1, quantitiesk}, {b, 1, 
  Count[intervalsk, _]}]

```

 ![ii6.png](https://global.discourse-cdn.com/wolfram/original/2X/0/06b8f9d496d545e50dcb71e81053b4bd83725a94.png)

That’s it for now… Thank you.

---

<div class="post-metadata">

**Author:** ![quimicalobo](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/quimicalobo/32/8777_2.png) [@quimicalobo](https://community.wolfram.com/u/quimicalobo)\
**Post date:** [May 10, 2019, 4:33pm UTC](https://community.wolfram.com/t/manipulating-linear-tables-with-multiple-external-intervals-and-quantities/14047/4 "2019-05-10T16:33:24Z")

</div>

Finally, the manipulation can be done automatically with the number of intervals and doing with quantity control for each interval defined outside the command.

```
intervals = {{1, 3}, {5, 7}, {9, 11}, {13, 15}};
quantities = {1, 2, 3, 4};

Manipulate[
 ListPlot[Flatten[
   Table[Flatten[
     Table[j, {j, 
       FromDigits[
        Take[FromDigits[Take[intervals, {nintervals}]], {1}]], 
       FromDigits[
        Take[FromDigits[Take[intervals, {nintervals}]], {2}]]}, 
      FromDigits[Take[quantities, {nintervals}]]]], {nintervals, 1, 
     nintervals}]]], {nintervals, 1, Count[quantities, _]}]

```

 ![ima1.png](https://global.discourse-cdn.com/wolfram/original/3X/f/8/f8fba1e2ca1c82b24db8376529024373aa5017a6.png)

And we can also define which intervals can participate in the manipulation and control them independently.

```
inter = {{4, 6}, {8, 10}, {12, 14}};
na = 20; nb = 20; nc = 20;

Manipulate[
 ListPlot[Flatten[{Table[
     Table[i, {i, FromDigits[Take[FromDigits[Take[inter, {1}]], {1}]],
        FromDigits[Take[FromDigits[Take[inter, {1}]], {2}]]}, a], aa],
     Table[Table[
      j, {j, FromDigits[Take[FromDigits[Take[inter, {2}]], {1}]], 
       FromDigits[Take[FromDigits[Take[inter, {2}]], {2}]]}, b], bb], 
    Table[Table[
      k, {k, FromDigits[Take[FromDigits[Take[inter, {3}]], {1}]], 
       FromDigits[Take[FromDigits[Take[inter, {3}]], {2}]]}, c], 
     cc]}]], {a, 1, na}, {b, 1, nb}, {c, 1, 
  nc}, {aa, {0, 1}}, {bb, {0, 1}}, {cc, {0, 1}}]
Manipulate[
 ListPlot[RandomSample[
   Flatten[{Table[
      Table[i, {i, 
        FromDigits[Take[FromDigits[Take[inter, {1}]], {1}]], 
        FromDigits[Take[FromDigits[Take[inter, {1}]], {2}]]}, a], aa],
      Table[Table[
       j, {j, FromDigits[Take[FromDigits[Take[inter, {2}]], {1}]], 
        FromDigits[Take[FromDigits[Take[inter, {2}]], {2}]]}, b], bb],
      Table[Table[
       k, {k, FromDigits[Take[FromDigits[Take[inter, {3}]], {1}]], 
        FromDigits[Take[FromDigits[Take[inter, {3}]], {2}]]}, c], 
      cc]}]]], {a, 1, na}, {b, 1, nb}, {c, 1, 
  nc}, {aa, {0, 1}}, {bb, {0, 1}}, {cc, {0, 1}}]

```

 ![ima2.png](https://global.discourse-cdn.com/wolfram/original/2X/8/828927c186e4d32558aefe257cfd60ada39d038d.png)

For now these are my results from this work. Thanks.
