np
.
random
.
seed
(
19680801
)
def
random_walk
(
,
max_step
=
0.05
):
"""Return a 3D random walk as (num_steps, 3) array."""
start_pos
=
(
3
)
steps
=
(
-
max_step
,
max_step
,
size
=
(
,
3
))
walk
=
start_pos
+
(
steps
,
axis
=
0
)
return
walk
def
update_lines
(
num
,
,
):
for
line
,
walk
in
zip
(
,
):
line
.
set_data_3d
(
walk
[:
num
,
:]
.
T
)
return
=
30
=
[
random_walk
(
)
for
index
in
range
(
40
)]
=
()
=
(
projection
=
"3d"
)
=
[
([],
[],
[])[
0
]
for
_
in
]
(
xlim3d
=
(
0
,
1
),
xlabel
=
'X'
)
(
ylim3d
=
(
0
,
1
),
ylabel
=
'Y'
)
(
zlim3d
=
(
0
,
1
),
zlabel
=
'Z'
)
=
(
,
update_lines
,
,
fargs
=
(
,
),
interval
=
100
)
()
Total running time of the script: (0 minutes 12.972 seconds)