Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. clear
  2. n = 50;
  3. N = 10000;
  4. weights = 1;
  5. d=2;
  6. walk = zeros(n+1,d*N);
  7. meanWeights = zeros(10, n);
  8. weights_temp = zeros(1,N);
  9. for k=1:10
  10. j
  11. weights = 1;
  12. walk = zeros(n+1,d*N);
  13. weights_temp = zeros(1,N);
  14. for i=2:n+1
  15. i
  16. [walk(i,:), weights_temp(1, :)] = theLastDraw(walk, i, d);
  17. weights = weights_temp.*weights;
  18. CW=cumsum([0 weights]);
  19. [~,ind] = histc(rand(1,N),CW/CW(end));
  20. for j=1:length(ind)
  21. walk(1:i, d*j-(d-1):d*j) = walk(1:i, ind(j)*d-(d-1):ind(j)*d);
  22. end
  23. weights = mean(weights);
  24. meanWeights(k, i-1) = weights;
  25. end
  26. end
  27. meanWeights
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement