ent">% time horizon</span>
w_opt = []; w_unif = [];
<span class="keyword">for</span> i = 1:N
    events = ceil(rand(1,T)*m);
    P_event = P(events,:);
    w_opt = [w_opt [1; cumprod(P_event*x_opt)]];
    w_unif = [w_unif [1; cumprod(P_event*x_unif)]];
<span class="keyword">end</span>

<span class="comment">% Plot wealth versus time</span>
figure
semilogy(w_opt,<span class="string">'g'</span>)
hold <span class="string">on</span>
semilogy(w_unif,<span class="string">'r--'</span>)
grid
axis <span class="strin