def solve(positions, num_trials): """ For a given position list and number of trials, run the experiments and draw the plots. """ for position in positions: # create a new class investment = Investment(position) daily_ret = [] for trial in range(num_trials): # do a invest each time investment.invest() # calculate the corresponding daily_ret, using double daily_ret.append(investment.ret * 1.0 / 1000.0 - 1.0) print("The mean of position", position, "is", mean(daily_ret)) print("The standard deviation of position", position, "is", stdev(daily_ret)) plt.hist(daily_ret, 100, range=[-1, 1]) plt.show()