[Numpy-discussion] Valid algorithm for generating a 3D Wiener Process?

David Goldsmith d.l.goldsmith at gmail.com
Wed Sep 25 02:59:40 EDT 2013


Is this a valid algorithm for generating a 3D Wiener process?  (When I
graph the results, they certainly look like potential Brownian motion
tracks.)

def Wiener3D(incr, N):
    r = incr*(R.randint(3, size=(N,))-1)
    r[0] = 0
    r = r.cumsum()
    t = 2*np.pi*incr*(R.randint(3, size=(N,))-1)
    t[0] = 0
    t = t.cumsum()
    p = np.pi*incr*(R.randint(3, size=(N,))-1)
    p[0] = 0
    p = p.cumsum()
    x = r*np.cos(t)*np.sin(p)
    y = r*np.sin(t)*np.sin(p)
    z = r*np.cos(p)
    return np.array((x,y,z)).T

Thanks!

DG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130924/53d587c6/attachment.html>


More information about the NumPy-Discussion mailing list