OK, thank you very much for the advice. And I’m still working on the same script. It is still far from what I need.

I'm taking Statistics class. A common calculation is that they give us a table of data of any size from 2x2 to 6x6 or even longer (more rows down). Usually it is 2-4 columns, however one time it was 16 columns.

First we had to calculate RF - relative frequencies of each row, each column.

So, I made a script to calculate it, using table with L1-L6 lists. In the calculation I first added a row with zeros to the bottom to separate data from results. I wish I could add dashes, or empty cells, but it's impossible. Next line is a sum of each column respectively, and next line is RF, which is calculated by dividing column sum by the total sum of the table.

Also I calculate sums of each row and store them in a new list "SUM", calculate RF of each row and store them into another list "RF"

Then our homework got harder and we needed to calculate marginal relative frequencies of each cell, where you divide the value of the cell by the value of the sum of that column. So, I created new lists F1-F6, where I store the results of RF of each cell.

Then with GENERAL probability calculations we had to divide cell value by the total sum of the table. So, I created another branch in my script (using "Menu(" function) to do general probability calculations as an option vs. RF calculations.

Then it got even more complicated with CONDITIONAL probability. Now we need three types of calculations for each cell at the same time

1) cell values divided by total sum

2) — by column sum

3) -—by row sum

I do not have a problem writing a script for calculations themselves. There are other problems. Although usually we have 2-4 columns of data, I want to write a script to be capable to calculate up to 6 columns (or lists). L1-L6 - are 6 lists, SUM and RF - another two, F1-F6 - that's 14 already. If I make 3 sets of "F" lists - that would be 26 lists, and that is over the limit of 20 lists our calculator allows. Also it is not convenient to scroll through anymore.

I was thinking to store everything in F1-6 columns, just posting them below each other, but it would be difficult to find needed cell in second and third set. Let’s say I need cel 4,5 (5th row) in third set with 7 rows in a set, so I need to go down 7, then another 7, then 5, counting as I go down. Also it is easy to make mistake by picking wrong cell and screw up the results. So, it is not convenient. Using the same lists F1-6 and just recalculating back and forth is not attractive either, so I was thinking of using matrixes to store the results. I would need 3 matrixes for those 3 different calculation modes. Probably I would still have to use F1-6 rows and then use List-to-Matrix command to send it to [A], then second calculation, using the same F1-6, storing to [B], and third – to [C].

The problem is that the script creates only as many “F” list as there “L” lists available. I use condition

If sum(L2)=0

…

If sum(L6)=0

To skip calculations and creating F lists that I do not need, but now if I write

List-to-Matrix(F1,F2,F3,F4,F5,F6,[A]

I will get an error if at least one of “F” is not filled.

One option I was thinking is to ask user how many “L” lists are there, but this is a bad idea, because it will make calculations longer time wise, and time sometimes is critical, when you are on the test.

I also could use old trick by checking sum of lists, starting with L2 and as soon as it returns zero, I would get the number of used lists. After this I would reroute the program to 5 different strings, starting with

List-to-Matrix(F1,F2,[A]

…

List-to-Matrix(F1,F2,F3,F4,F5,F6,[A]

And then repeat it two more times for [B] and[C].

Here I need to say that when you check sums of “L” lists you have to have them all pre-filled or you get an error, so what I do, I use “L1” as a reference point because it is always going to be filled and set “dim(“ size of all other “L” lists to that size. At the end of calculation I set “dim(“ of all “empty” lists to 0 if the sum of a list =0.

I was thinking of using the same trick with “F” lists while sending them to matrix, so I can only use one set of strings “List-to-Matrix “ instead of 5, but then I would have to deal with a lot of zeros in the matrix and I do not know how to chop them off.

What do you think?