# Generating a unit 3 vector in Python (Uniform Spherical Projection)

### Andrew Bolster

Data Scientist at Alert Logic, Founder/Director at Farset Labs

Quick one more as a reminder to me than anything else.

As part of my PhD work I’m building different behaviours for virtual submarines. I’ll be explaining some parts of my work in a separate post, but basically, I needed to random walk. Random walk in 2 dimensions is easy; pick two random numbers, go that way. Unfortunately doesn’t work that way on a spherical surface

So to make things easier, I stole this StackOverflow answer from dmckee and tidied it up a bit for my purposes. (Assuming everyone else is like me and does import numpy as np)

Published: April 09 2014

• tags: