anchor.diff:          ! Out:
           !    ret: the index of the element chosen.
   
  -        ! [review] - JSS: I think the switch (multiple times) between k and N objects is confusing.
  -
  -        ! The 'alias method' allows one to select from a discrete probability distribution of k objects (with object j having probability p_j) in O(1) time. 
  -        ! There's an O(k) storage and O(k) setup cost - a list of k reals (P_j) and k integers (Y_j)  which requires O(k) setup.
  +        ! The 'alias method' allows one to select from a discrete probability distribution of N objects 
  +        ! (with object i having probability p_i) in O(1) time. There's an O(N) storage and O(N) setup cost 
  +        ! - a list of N reals (P_i) and N integers (Y_i) which requires O(N) setup.
   
           ! Pick a random real number x, 0<=x<k.
           ! Let K=floor(x) and V=x-K. (so K is an integer and V the remainder).
  
positive.code:         !    entry /U_j / < 1. (If one of these exists, the other must, as well.)
          ! 2. Allocate the unused space in entry j to outcome i, by setting /K_j /
          !    = /i/.
          ! 3. Remove the allocated space from entry i by changing /U_i / = /U_i /
          !    - (1 - /U_j /) = /U_i / + /U_j / - 1.
          ! 4. Entry j is now exactly full.
          ! 5. Assign entry i to the appropriate category based on the new value of
          !    U_i .  
  
negative.code:         integer :: overfull(N)
          integer :: i, nunder, nover, ov, un
  
          aliasU = weights * (N / totweight)
          nunder = 0
          nover = 0
          do i = 1, N
              if (aliasU(i) <= 1.0_p) then
                  nunder = nunder + 1
                  underfull(nunder) = i
              else ! account for aliasU(i)=1 as underfull
                  nover = nover +1
                  overfull(nover) = i
              end if
              ! [review] - JSS: in case of what?!
              ! [review] - VAN: Sensible to set it in case there is a tiny numerical error
              ! [review] - VAN: when matching up the last underfull and overfull Us. 
              aliasK(i) = i ! This is a sensible safe choice in case aliasK(i) is not set below.
          end do
          do while (nover > 0 .and. nunder > 0)
              ! match the last nover with the last nunder
  