hist.ab                package:sjemea                R Documentation

_H_i_s_t_o_g_r_a_m _r_o_u_t_i_n_e_s _t_o _h_e_l_p _c_o_m_p_u_t_e _t_h_e _c_r_o_s_s-_c_o_r_r_e_l_a_t_i_o_n _b_e_t_w_e_e_n _a
_p_a_i_r _o_f _s_p_i_k_e _t_r_a_i_n_s.

_D_e_s_c_r_i_p_t_i_o_n:

     For a pair of spike trains, TA (train a) and TB, these related
     routines return the count of the number of spikes in B that occur
     within some time window [-tmax,tmax] of a spike in A.  For
     histbi.ab, we return a histogram of dt values from [-tmax,tmax]. 
     For hist.ab, we ignore the sign of each dt and just return a
     histogram in the range [0,tmax].  Finally, for count.nab, we just
     return the number of dt values found in the range [-tmax,tmax],
     rather than binning dt into a histogram.

_U_s_a_g_e:

     hist.ab(ta, tb, tmax, nbins)
     histbi.ab(ta, tb, tmax, nbins)
     count.nab(ta, tb, tmax)

_A_r_g_u_m_e_n_t_s:

      ta: Vector of spike times, sorted such that lowest is first.

      tb: Vector of spike times, sorted such that lowest is first.

    tmax: maximum time (in seconds) to bin

   nbins: Number of bins in the histogram.  For histbi.ab, each bin is
          of width (2*tmax)/nbins.  For hist.ab, each bin is
          (tmax)/nbins wide.

_V_a_l_u_e:

     'hist.ab' returns a histogram of counts ignoring sign. 'histbi.ab'
     returns a histogram of counts respecting sign. 'count.nab' returns
     the number of dt values.

_M_E_T_H_O_D:

     For the histogram routines, each bin is of the form [low, high),
     with the exception of the last bin (for +tmax), which is of the
     form [tmax-binwid, tmax].  By assuming the spikes are ordered
     lowest first, the number of spike comparisons is greatly reduced,
     rather than comparing each spike with A with each spike in B.

_R_e_f_e_r_e_n_c_e_s:

     No references here.

_S_e_e _A_l_s_o:

     Nothing else yet...

_E_x_a_m_p_l_e_s:

     stopifnot(isTRUE(all.equal.numeric(
       histbi.ab(c(0), c(-2, -2, 0, 0, 1, 1,1, 1.8,2), tmax=2, nbins=4),
       c(2,0,2,5),
       check.attributes=FALSE)))
     stopifnot(identical(TRUE, all.equal.numeric(
       hist.ab(c(0), c(-2, -2, 0, 0, 1, 1,1, 1.8,  2), tmax=2, nbins=4),
       c(2,0,3,4),
       check.attributes=FALSE)))
      
     test.hist.ab()

     ## Not run: 
     test.histograms.versus.r()
     test.count.hist.nab()
     test.count.hist.nab(s)
     test.count.hist2.nab(s)
     ## End(Not run)

