3
$\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. However, I keep getting x and y axes without a random walk graph.

$\endgroup$
1
  • 2
    $\begingroup$ RandomVariate[uniformm, {500, 2}] should read RandomVariate[uniformm, 500] $\endgroup$ Jan 26, 2021 at 21:20

1 Answer 1

3
$\begingroup$
c2 = Accumulate @ Prepend[RandomVariate[uniformm, 500], {0, 0}];


ListLinePlot[c2, AspectRatio -> Automatic]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ compare RandomVariate[uniformm, 3] versus RandomVariate[uniformm, {3, 2}] to see why you need RandomVariate[uniformm,500] not RandomVariate[uniformm, {500,2}] $\endgroup$
    – kglr
    Jan 26, 2021 at 21:20

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.