
    
        
        
        
            
{"version":"https:\/\/jsonfeed.org\/version\/1","title":"mathspp.com feed","home_page_url":"https:\/\/mathspp.com\/blog\/tags\/random-walks","feed_url":"https:\/\/mathspp.com\/blog\/tags\/random-walks.json","description":"Stay up-to-date with the articles on mathematics and programming that get published to mathspp.com.","author":{"name":"Rodrigo Gir\u00e3o Serr\u00e3o"},"items":[{"title":"Random walk simulations in 2D","date_published":"2017-10-26T00:00:00+02:00","id":"https:\/\/mathspp.com\/blog\/random-walk-simulations","url":"https:\/\/mathspp.com\/blog\/random-walk-simulations","content_html":"<p>Think of a drunk man that continuously tumbles left and right, back and forth, with no final destination.<\/p>\n\n<p><img alt=\"A blue 2D random walk on a green background\" src=\"\/images\/e\/f\/d\/f\/2\/efdf2de1162ef1c66911c2dba75dd7f9e81cc52a-2drandomwalk.webp\"><\/p>\n<p>This drunk man walking around can be thought of as a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Random_walk\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">random walk<\/a> on the plane... Now imagine that the drunk man has a shorter leg and tumbles more to one of the sides: that is a biased random walk. Now imagine the drunk man can teleport to a nearby location. That is (kind of) a <a href=\"https:\/\/en.wikipedia.org\/wiki\/L%C3%A9vy_flight\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">L\u00e8vy flight<\/a>! All those are quite interesting to observe in motion and I implemented them in Python. (the code can be found <a href=\"https:\/\/github.com\/RodrigoGiraoSerrao\/projects\/tree\/master\/randomWalks\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">here<\/a>). From those, only the tilted walks and the one with the trail are such that the particle's movement wraps around the borders (leaving the green area makes the particle appear in the opposite side, just like the snake from the game Snake).<\/p>\n<p>The image above is a screenshot of the execution of the random walk that leaves a coloured trail.<\/p>\n<p>I also implemented an animation where the screen gets progressively filled with circles of different colours, as if being splattered with paint. Not sure why... But it looks interesting:<\/p>\n<p><img alt=\"A black background with several randomly-coloured circles\" src=\"\/user\/pages\/02.blog\/random-walk-simulations\/splatter.webp\"><\/p>\n<p>The implementation is in the same directory as the walks.<\/p>\n<p>For all these, I got windows executables. <a href=\"https:\/\/drive.google.com\/open\" id=\"0ByBeLS6ciLYVX1k0M2Z2Z2RjYkU\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Here<\/a> you can find all the executables for the random walks and <a href=\"https:\/\/drive.google.com\/open\" id=\"0ByBeLS6ciLYVcDh0a051T3plRlk\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">here<\/a> for the paint splatter.<\/p>","summary":"Check what a 2D random walk really is and how it looks like.","date_modified":"2024-08-13T12:47:46+02:00","tags":["mathematics","programming","random walks","simulation","visualisation","pygame","python"],"image":"\/user\/pages\/02.blog\/random-walk-simulations\/2d_random_walk.webp"}]}
