def uniform_walk ( n, d ):

#*****************************************************************************80
#
## uniform_walk() generates points on a uniform random walk.
#
#  Discussion:
#
#    The first point is at the origin.  Uniform random numbers are
#    generated to determine the direction of the next step, which
#    is always of length 1, and in coordinate direction.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license. 
#
#  Modified:
#
#    22 April 2022
#
#  Author:
#
#    John Burkardt
#
#  Input:
#
#    integer N, the number of points.
#
#    integer D, the dimension of the space.
#
#  Output:
#
#    real P(N,D), the points.
#
  import numpy as np

  p = np.zeros ( n, d )
#
#  Choose random directions of +1 and -1.
#
  dir = np.random.randint ( 0, high = d + 1, size = n - 1 )
  sgn = 2.0 * np.random.rand ( n - 1 ) - 0.5

  for i in range ( 1, n ):
#
#  Start at the previous point.
#
    p[i,j] = p[i-1,j]
#
#  Pick which direction to alter.
#
    j = dir[i-1]
#
#  Move +1 or -1 in that direction.
#
    if ( sgn[i-1] < 0.0 ):
      p[i,j] = p[i-1,j] - 1.0
    else:
      p[i,j] = p[i-1,j] + 1.0

  return p

