RESIZE-PTABLE

[GENERIC-FUNCTION]


OMTimePack
Function Reference
ARGUMENTS:
  - ptable 1- or 2-dim table (flat or nested list) [default = (1)]
  - resize-pairs list of pairs to control resizing [default = ((1 2))]

Description:


Tries to express the shape of 1- or 2-dim PTABLE in a new probability table
related to the original in a way expressed by RESIZE-PAIRS. The first pair
(X Y) means 'express the first X elements (or rows and columns) of PTABLE in
the first Y elements (rows/columns) of the result', and successive pairs
control the processing of successive elements (rows/columns). For example,
the RESIZE-PAIRS list ((7 8)) takes a length-7 or 7x7 PTABLE and returns a
length-8 or 8x8 result; the RESIZE-PAIRS list ((4 4) (3 4)) does likewise but
concentrates the change in the last three elements (rows/columns).


DETAILS: How 1-dim tables and the rows of 2-dim tables are processed

When the number of elements INCREASES, the new result
is scaled to have the same sum as the original:

(resize-ptable '(1) '((1 2))) ==> (1/2 1/2)
(resize-ptable '(3 6) '((2 3))) ==> (2 3 4)
(resize-ptable '(28 70 42) '((3 6))) ==> (16 19 26 29 26 24)

When the number of elements DECREASES, there are three cases.
[1] a decrease to length zero yields NIL; [2] a decrease from
length 2 to length 1 yields the average of the original two
elements; [3] a decrease from length N to length (N - 1) is
scaled to have the sum (A + B), where A is the average of the
first and last of the original elements, and B is the sum of
the remaining original elements.

(resize-ptable '(5) '((1 0))) ==> NIL ; [1]
(resize-ptable '(1 3) '((2 1))) ==> (2) ; [2]
(resize-ptable '(2 12 6) '((3 2))) ==> (7 9) ; [3]



Auto doc generation by OpenMusic 6.3 © 2010 IRCAM