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
  • $\begingroup$ This seems to be the same question as here: mathematica.stackexchange.com/questions/238838/… Edit you question there or request clarification from the answerers if you have issues $\endgroup$ Commented Jan 26, 2021 at 23:40

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$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.