hFunc.updateRunnerScores(results, meansAndStds, people, keepHistory)
                                
        scoreMeanAndStd = hFunc.getMeanAndStdOfScores(people, keepHistory, minRaceCount, dropIntermediateScores, run+1)
        m, s = scoreMeanAndStd
        means.append(m)
        stds.append(s)
        totalScore.append(sum([v[0] for k,v in people.iteritems()]))

        if dropIntermediateScores and run < totalRuns-1:
                hFunc.dropIntermediateScores (people, keepHistory, keepGeneratedScore)



#hFunc.rebaseScores(people, 1000, 200, minRaceCount)

temp = hFunc.getIndividualMeansAndStds(people, keepHistory, minRaceCount, dropIntermediateScores, totalRuns)
finalRanks, finalStds = temp
print "number of people that participated in " + str(minRaceCount) + " or more races:", len(finalRanks)
print "number of races with 10 or more runners: ", raceCounter

scoreMeanAndStd = hFunc.getMeanAndStdOfScores(people, keepHistory, minRaceCount, dropIntermediateScores, totalRuns)
mean, sdDiv = scoreMeanAndStd

plt.hist(finalRanks, bins=100, normed=False, histtype='stepfilled', color='r', label='final', alpha = 0.5)
plt.axvline(x=mean, color='black')
plt.title("Rank Histogram")
plt.xlabel("Rank")
plt.ylabel("Frequency")
plt.figtext(0.15, 0.85, str(round(mean, 3)) + '(' + str(round(sdDiv, 3)) + ')')
plt.legend()
plt.show()