Brownian Motion in Python

If you’ve studied continuous time stochastic processes, you know how pathological their sample paths can be. Each path of the Wiener process is continuous everywhere yet nowhere differentiable a.s. Explicit constructions of such functions in an analysis course may have given you headaches at some point in your mathematical education so it might come as a shock to hear that simulating a Brownian motion’s sample path is quite easy. We will only need to make some small simplifications.

The properties of Brownian motion are what allow for a simple approximation of something so complex. In particular, we rely on the fact that increments are normal and stationary and the process is Markov.

Fix a finite time interval starting at 0. We will assume standard Brownian motion, i.e. B(0)=0. We simply chop our time interval up into small subintervals. We can make them as small or large as we like, but for convenience here I will chose \Delta t=.01. I’m also choosing a value that will easily yield a square root because our simulations of the normal increments will require the standard deviation as an input, not the variance.

So, the value of the first increment, B(.01)-B(0), is found by simulating N(0, .01) using np.random.normal(0,.1). Clearly B(.01)= B(0)+ (B(.01)-B(0)), so we have a simulation of B(.01). We can simulate the next increment of length .01 in the exact same manner (because the increments are stationary). Since the process is Markov, at time t=.01, the future of the process is only determined by the value B(.01). We do not have to worry about the path the process has taken in the past. So, we estimate B(.02) as B(.01) plus a simulation of the increment, which is N(0, .01).

We continue this process, stitching together a path of our Brownian motion, increment by increment.

Notes: This is only a simulation, so some key properties of Brownian motion are missing. In theory, if we zoomed in appropriately, the path should look the same on this smaller scale, equally jagged as the wider view. It behaves like a fractal. However, this is clearly not the case in our simulation. When we zoom in it is clear our graph is just made up of line segments connecting the endpoints of the intervals.

My code is far from elegant, but I intend to update with a more general tool to simulate a general Ito Process. For now, here is what I used.

Renewed Effort and New Directions

Well, I’m almost finished with my PhD (I hope). I definitely need to buckle down and WRITE. I will continue to post here about probability theory/stochastic analysis topics.

But in the meantime, since I had so much free time, I decided to go out and get a full time job in the financial industry. I’m now a risk quant at a a large national bank. While I am fitting in well to my role, I will be exploring the wider world of my profession, and hopefully learning and sharing about multiple sectors of the quant industry.

Thus, I will be updating the blog to reflect its split Stochastic Analysis/ Quant roles.

Over the Great Firewall

With the COVID outbreak, a lot of meetings/seminars that would normally be face to face are taking place online (obviously). My friend’s advisor was invited to give a virtual talk on optimal control problems to Southern University of Science and Technology. In Shenzhen, I believe.

My friend slipped me an invite.

The entire talk was conducted in mandarin, a language I do not speak (though I am trying to learn by annoying my fellow grad students). It was a fun experience. And I made it into Shenzhen, virtually at least!

The talk was a narrated slide show. Slides were in English, thankfully. Still, didn’t understand much. I wish I could say it was all the language barrier but I don’t think that’s the case…

我去!

An Abridged History

I genuinely do enjoy talking about math and interacting with people at all levels of mathematics education. I also spend a lot of time stalking the internet. I join forums, discord servers, subreddits concerned with math and related fields. I talk with undergrads, graduate students, mathematicians and hobbyists.

Visitors often wander in to these spaces and ask a variation of one of these questions:

“Am I too old to start a math degree, grad school?”

“Am I good enough to be a math major?”

“Is it possible?”

On the whole, I’m a pretty boring person. But I feel like my personal history might be relevant to these people. If they ever manage to stumble upon this blog, that is.

First, I wasn’t someone who knew they wanted to be a mathematician from the day they were born. I did alright in math in school but was never a prodigy. When I got to college I went through a couple majors, none of them math.

I should say “When I got to college the first time”. College and I didn’t mix well at first. I could write a whole book about that but I’ll spare you. Eventually I dropped out and worked in the bar industry for several years.

I didn’t return to school until I was 27 or 28. And it still wasn’t with any particular field in mind. I was considering Chemistry of all things. But I basically had to start my bachelor’s from square one and had to take some math classes as pre-reqs for whatever degree I wanted.

Math hooked me, etc, etc. This isn’t about how great math is or why I was inspired to do math.

I just wanted to share the timeline. I was taking Calc 2 for the first time at 28. BS in math at 31. And managed to get accepted to a grad program after that. Now I’m 3 years into a PhD and feeling pretty solid about it all. Many of the others in the program are younger, but not by as much I would have thought. And there are people in the program significantly older than me as well.

Age doesn’t seem to be much of a factor, really.

I certainly wasn’t a child genius. I just plugged away at it and have gotten by so far.

I know there are more remarkable tales for inspiration. But if you’re a lost twenty-something wondering if you can hack it in math just follow me! You’ve got the time and you don’t need to be some wunderkind to hack it.

Screaming into the void

This blog came about for a number of reasons.

In undergrad I could be reasonably sure of finding supplementary lectures on YouTube for whatever math class I was enrolled in. Unsurprisingly, as I entered grad school this type of resource became increasingly scarce. I noticed this drought especially in the area of probability as well as the measure theory and real analysis needed for probability at the graduate level. I played with the idea of producing some content of my own in these areas.

For some time I had wanted to pursue probability as my field of choice and determined to take my candidacy exams in this subject. I thought making a blog might be a good way to study.

Finally, the Covid-19 pandemic began (and is in full swing at time of writing) and forced all education online. The courses I taught transition to the internet and I began producing content for these.

I figured since I was producing math content anyway I might as well produce some for fun and my own selfish gain. Thus, the blogging began.

I’ll try and make it somewhat enjoyable on the off chance someone ever stumbles across this. Maybe I will force my future students to visit the blog and get that view count up.