0
$\begingroup$
uniformm = UniformDistribution[{{-1, 1}, {-1, 1}}]; dist = 
 PDF[uniformm, {x, y}]; Plot3D[dist, {x, -3, 3}, {y, -3, 3}, 
 Filling -> Axis]
c2 = Accumulate@Prepend[RandomVariate[uniformm, {500, 2}], {0, 0}];
ListLinePlot[c2, AspectRatio -> Automatic] 

I am trying to plot a random walk drawn from a flat distribution (x and y fall within [-1,1]).
However, I keep getting x and y axes without a random walk graph.

Thank you

$\endgroup$
1

1 Answer 1

1
$\begingroup$

Everything's basically right here! You simply have an extra dimension in your random walk.

uniformm = UniformDistribution[{{-1, 1}, {-1, 1}}] here is a uniform distribution in 2D, and produces lists of length 2. However, RandomVariate[uniformm, {500, 2}] produces a 500 by 2 array of samples from that distribution. Since each sample has length 2, RandomVariate[uniformm, {500, 2}] is an array with dimensions 500 x 2 x 2.

So, change RandomVariate[uniformm, {500, 2}] to RandomVariate[uniformm, 500] and you should be good. :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.