# Optimizing a simple random walk simulation

**URL:** <https://discourse.julialang.org/t/optimizing-a-simple-random-walk-simulation/124653>\
**Category:** Performance\
**Created:** [January 10, 2025, 6:23pm UTC](https://discourse.julialang.org/t/optimizing-a-simple-random-walk-simulation/124653 "2025-01-10T18:23:57Z")\
**Posts on this page:** 2\
**Page:** 3

<div class="post-metadata">

**Author:** ![aris](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@aris](https://discourse.julialang.org/u/aris)\
**Post date:** [January 13, 2025, 10:01am UTC](https://discourse.julialang.org/t/optimizing-a-simple-random-walk-simulation/124653/41 "2025-01-13T10:01:34Z")

</div>

Spot on, I’ve already been through all these papers 🙂

> [@foobar\_lv2](#):
>
> They probably goofed.

Happy to believe you here, but at the same time I’m not knowledgeable enough in the field (yet) to go ahead and do something different from them.

I’ve already used an even less efficient matlab version of the code above, which has given “okay” results, and I posted this thread mostly because I really want to get better at julia, and understand how to eliminate those pesky allocations.

I do appreciate your advice though, and I’ll definitely do some extra research on the topic at some point!

---

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [January 13, 2025, 10:49am UTC](https://discourse.julialang.org/t/optimizing-a-simple-random-walk-simulation/124653/42 "2025-01-13T10:49:45Z")

</div>

So, some more lit references: The thing with the sphere is called “random walk on spheres”. Allegedly reflection works across Robin boundaries, somehow, just as well as across Neumann boundaries (TIL).

There is also a large theory of “walk-on-boundary” algorithms. These are more complicated than I can grok in 5 minutes, so you’ll need to ask somebody else.

[Previous page](https://discourse.julialang.org/t/optimizing-a-simple-random-walk-simulation/124653.md?page=2)
