using Plots #plotlyjs() # Use the PyPlot interface pyplot(size=(800,500), leg=false) iters = 500 # play N = 500 rounds init_pot = 100 # starting pot num_runs = 1000 # Number of times to run the simulation if !isfile("1-lin-sim.png") gamb_run = Array{Float64}(undef,iters+1) x = 1:iters+1 model = 100:5:100+5*iters lin_gamb_plot = plot(x, model, linestyle=:dash, linecolor=:red, linewidth=3) for i = 1:num_runs gamb_run[1] = init_pot for j = 2:iters+1 if rand(Bool) gamb_run[j] = gamb_run[j-1] - 30 else gamb_run[j] = gamb_run[j-1] + 40 end end plot!(lin_gamb_plot, x, gamb_run, linecolor=:green, linealpha=0.03) if i % 80 ==0 plot!(lin_gamb_plot, x, gamb_run, linecolor=:green, linealpha=1) end end png( lin_gamb_plot, "1-lin-sim.png" ) end if !isfile("2-mul-sim.png") || !isfile("2-mul-sim-log.png") m_model = 100*sqrt(1.4*0.7).^x m_gamb_plot = plot(x, m_model, linestyle=:dash, linecolor=:red, linewidth=3, ylims=(0,100000)) m_gamb_plot_log = plot(x, m_model, linestyle=:dash, linecolor=:red, linewidth=3, yaxis=:log) for i = 1:num_runs gamb_run[1] = init_pot for j = 2:iters+1 if rand(Bool) gamb_run[j] = gamb_run[j-1] * 1.4 else gamb_run[j] = gamb_run[j-1] * 0.7 end end plot!(m_gamb_plot, x, gamb_run, linecolor=:green, linealpha=0.03) plot!(m_gamb_plot_log, x, gamb_run, linecolor=:green, linealpha=0.03) if i % 80 == 0 plot!(m_gamb_plot, x, gamb_run, linecolor=:green, linealpha=1) plot!(m_gamb_plot_log, x, gamb_run, linecolor=:green, linealpha=1) end end png( m_gamb_plot, "2-mul-sim.png") png( m_gamb_plot_log, "2-mul-sim-log.png") end