Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- n = 50;
- N = 10000;
- weights = 1;
- d=2;
- walk = zeros(n+1,d*N);
- meanWeights = zeros(10, n);
- weights_temp = zeros(1,N);
- for k=1:10
- j
- weights = 1;
- walk = zeros(n+1,d*N);
- weights_temp = zeros(1,N);
- for i=2:n+1
- i
- [walk(i,:), weights_temp(1, :)] = theLastDraw(walk, i, d);
- weights = weights_temp.*weights;
- CW=cumsum([0 weights]);
- [~,ind] = histc(rand(1,N),CW/CW(end));
- for j=1:length(ind)
- walk(1:i, d*j-(d-1):d*j) = walk(1:i, ind(j)*d-(d-1):ind(j)*d);
- end
- weights = mean(weights);
- meanWeights(k, i-1) = weights;
- end
- end
- meanWeights
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement