code: def generate_data(dim = 40, num_samples = 30000, num_bins = 10, sparse = False):
    
  
    positives, negatives = [], []
    positive, negative = generate_matrices(dim)
  
    for i in range(num_samples):
      phase_1 = generate_phase_1(dim)
      phase_2 = generate_phase_2(phase_1, dim)
  
  
      if i < num_samples/2:
        positives.append(numpy.dot(positive, phase_2))
      else:
        negatives.append(numpy.dot(negative, phase_2))
  
    binned_data = bin_data(positives + negatives, dim, num_bins)
    positives = binned_data[:len(binned_data)/2]
    negatives = binned_data[len(binned_data)/2:]
  
    if sparse:
      positives = SM32(positives)
      negatives = SM32(negatives)
  
    return positives, negatives
docs: Generates data following appendix V of (Poirazi & Mel, 2001).
    Positive and negative examples are drawn from the same distribution, but
    are multiplied by different square matrices, one of them uniform on [-1, 1
    and one the sum of a uniform matrix and a normal one.  It is assumed that half
    the samples are negative in this case.
  
    Initially samples of dimension dim are produced, with values in each
    dimension being floats, but they are binned into discrete categories, with
    num_bins bins per dimension.  This binning produces an SDR.