first.last            package:wavethresh            R Documentation

_B_u_i_l_d _a _f_i_r_s_t/_l_a_s_t _d_a_t_a_b_a_s_e _f_o_r _w_a_v_e_l_e_t _t_r_a_n_s_f_o_r_m_s.

_D_e_s_c_r_i_p_t_i_o_n:

     This function is not intended for user use, but is used by various
     functions involved in computing and displaying wavelet transforms.
     It basically constructs "bookeeping" vectors that 'WaveThresh'
     uses for working out where coefficient vectors begin and end.

_U_s_a_g_e:

     first.last(LengthH, DataLength, type, bc="periodic", current.scale)

_A_r_g_u_m_e_n_t_s:

 LengthH: Length of the filter used to produce a wavelet decomposition.

DataLength: Length of the data before transforming. This must be a
          power of 2, say 2^m.

    type: 

      bc: This character string argument determines how the boundaries
          of the the function are to be handled. The permitted values
          are 'periodic' or 'symmetric'. 

current.scale: 

_D_e_t_a_i_l_s:

     Suppose you begin with 2^m=2048 coefficients. At the next level
     you would expect 1024 smoothed data coefficients, and 1024 wavelet
     coefficients, and if 'bc="periodic"' this is indeed what happens.
     However, if 'bc="symmetric"' you actually need more than 1024 (as
     the wavelets extend over the edges). The first last database keeps
     track of where all these "extras" appear and also where they are
     located in the packed vectors C and D of pyramidal coefficients
     within wavelet structures. 

     For example, given a 'first.last.c row' of 

     -2 3 20

     The actual coefficients would be  c_{-2}, c_{-1}, c_{0}, c_{1},
     c_{2}, c_{3}

     (in LaTeX notation where _{x} denotes subscript x). In other
     words, there are 6 coefficients, starting at -2 and ending at 3,
     and the first of these (c_{-2}) appears at an offset of 20 from
     the beginning of the $C component vector of the wavelet structure. 

     You can ``do'' 'first.last' in your head for 'periodic' boundary
     handling but for more general boundary treatments (e.g.
     'symmetric') 'first.last' is indispensable.

_V_a_l_u_e:

     A first/last database structure, a list containing the following
     information: 

first.last.c: A (m+1)x3 matrix. The first column specifies the real
          index of the first coefficient of the smoothed data at a
          level, the 2nd column is the real index of the last
          coefficient, the last column specifies the offset of the
          first smoothed datum at that level. The offset is used by the
          C code to work out where the beginning of the sequence is
          within a packed vector of the pyramid structure. The first
          and 2nd columns can be used to work out how many numbers
          there are at a level. If 'bc="periodic"' then the pyramid is
          a true power of 2 pyramid, that is it starts with a power of
          2, and the next level is half of the previous. If
          'bc="symmetric"' then the pyramid is nearly exactly a power
          of 2, but not quite, see the Details section for why this is
          so. 

  ntotal: The total number of smoothed data/original data points.

first.last.d: A mx3 matrix. As for 'first.last.c' but for the wavelet
          coefficients packed as the D component of a wavelet
          structure.

ntotal.d: The total number of wavelet coefficients.

_R_E_L_E_A_S_E:

     Version 3.5.3 Copyright Guy Nason 1994

_R_e_f_e_r_e_n_c_e_s:

     Nason, G.P. and Silverman, B.W. (1994). The discrete wavelet
     transform in S.

_S_e_e _A_l_s_o:

     'wd', 'wr', 'wr.wd', 'accessC', 'accessD', 'filter.select'.
     'imwd'.

_E_x_a_m_p_l_e_s:

     #
     #If you're twisted then you may just want to look at one of these.
     #
     #first.last(length(filter.select(2)), 64)
     #$first.last.c:
     #First Last Offset
     #[1,]     0    0    126
     #[2,]     0    1    124
     #[3,]     0    3    120
     #[4,]     0    7    112
     #[5,]     0   15     96
     #[6,]     0   31     64
     #[7,]     0   63      0
     #
     #$ntotal:
     #[1] 127
     #
     #$first.last.d:
     #First Last Offset
     #[1,]     0    0     62
     #[2,]     0    1     60
     #[3,]     0    3     56
     #[4,]     0    7     48
     #[5,]     0   15     32
     #[6,]     0   31      0
     #
     #$ntotal.d:
     #[1] 63
     #
     #

