def plotSuccessRate_varyNumColumns(noiseSigma, noiseEverywhere):
  """
  Run and plot the experiment, varying the number of cortical columns.
  """

  #
  # Run the experiment
  #
  noiseLevels = [x * 0.01 for x in xrange(0, 101, 5)]
  l2Overrides = {"sampleSizeDistal": 20}
  columnCounts = [1, 2, 3, 4]

  results = defaultdict(list)

  for trial in xrange(1):
    print "trial", trial
    objectDescriptions = createRandomObjectDescriptions(10, 10)

    for numColumns in columnCounts:
      print "numColumns", numColumns
      for noiseLevel in noiseLevels:
        r = doExperiment(numColumns, l2Overrides, objectDescriptions,
                         noiseLevel, noiseSigma, numInitialTraversals=6,
                         noiseEverywhere=noiseEverywhere)
        results[(numColumns, noiseLevel)].extend(r)

  #
  # Plot it
  #
  numCorrectActiveThreshold = 30
  numIncorrectActiveThreshold = 10

  plt.figure()
  colors = dict(zip(columnCounts,
                    ('r', 'k', 'g', 'b')))
  markers = dict(zip(columnCounts,
                     ('o', '*', 'D', 'x')))

  for numColumns in columnCounts:
    y = []
    for noiseLevel in noiseLevels:
      trials = results[(numColumns, noiseLevel)]
      numPassed = len([True for numCorrect, numIncorrect in trials
                       if numCorrect >= numCorrectActiveThreshold
                       and numIncorrect <= numIncorrectActiveThreshold])
      y.append(numPassed / float(len(trials)))

    plt.plot(noiseLevels, y,
             color=colors[numColumns],
             marker=markers[numColumns])

  lgnd = plt.legend(["%d columns" % numColumns
                     for numColumns in columnCounts],
                    bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.0)
  plt.xlabel("Mean feedforward noise level")
  plt.xticks([0.01 * n for n in xrange(0, 101, 10)])
  plt.ylabel("Success rate")
  plt.yticks([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
  plt.title("Inference with normally distributed noise (stdev=%.2f)" % noiseSigma)

  plotPath = os.path.join("plots",
                          "successRate_varyColumnCount_sigma%.2f_%s.pdf"
                          % (noiseSigma, time.strftime("%Y%m%d-%H%M%S")))
  plt.savefig(plotPath, bbox_extra_artists=(lgnd,), bbox_inches="tight")
  print "Saved file %s" % plotPath
def plotSuccessRate_varyNumColumns ( noiseSigma , noiseEverywhere ) : noiseLevels = [ x * 0.01 for x in xrange ( 0 , 101 , 5 ) ] l2Overrides = { "sampleSizeDistal" : 20 } columnCounts = [ 1 , 2 , 3 , 4 ] results = defaultdict ( list ) for trial in xrange ( 1 ) : print "trial" , trial objectDescriptions = createRandomObjectDescriptions ( 10 , 10 ) for numColumns in columnCounts : print "numColumns" , numColumns for noiseLevel in noiseLevels : r = doExperiment ( numColumns , l2Overrides , objectDescriptions , noiseLevel , noiseSigma , numInitialTraversals = 6 , noiseEverywhere = noiseEverywhere ) results [ ( numColumns , noiseLevel ) ] . extend ( r ) numCorrectActiveThreshold = 30 numIncorrectActiveThreshold = 10 plt . figure ( ) colors = dict ( zip ( columnCounts , ( 'r' , 'k' , 'g' , 'b' ) ) ) markers = dict ( zip ( columnCounts , ( 'o' , '*' , 'D' , 'x' ) ) ) for numColumns in columnCounts : y = [ ] for noiseLevel in noiseLevels : trials = results [ ( numColumns , noiseLevel ) ] numPassed = len ( [ True for numCorrect , numIncorrect in trials if numCorrect >= numCorrectActiveThreshold and numIncorrect <= numIncorrectActiveThreshold ] ) y . append ( numPassed / float ( len ( trials ) ) ) plt . plot ( noiseLevels , y , color = colors [ numColumns ] , marker = markers [ numColumns ] ) lgnd = plt . legend ( [ "%d columns" % numColumns for numColumns in columnCounts ] , bbox_to_anchor = ( 1.05 , 1 ) , loc = 2 , borderaxespad = 0.0 ) plt . xlabel ( "Mean feedforward noise level" ) plt . xticks ( [ 0.01 * n for n in xrange ( 0 , 101 , 10 ) ] ) plt . ylabel ( "Success rate" ) plt . yticks ( [ 0.0 , 0.2 , 0.4 , 0.6 , 0.8 , 1.0 ] ) plt . title ( "Inference with normally distributed noise (stdev=%.2f)" % noiseSigma ) plotPath = os . path . join ( "plots" , "successRate_varyColumnCount_sigma%.2f_%s.pdf" % ( noiseSigma , time . strftime ( "%Y%m%d-%H%M%S" ) ) ) plt . savefig ( plotPath , bbox_extra_artists = ( lgnd , ) , bbox_inches = "tight" ) print "Saved file %s" % plotPath
Run and plot the experiment, varying the number of cortical columns.