Tag Info

Hot answers tagged

10

ClearAll[dist] dist [rho_] := CopulaDistribution[{"Binormal", rho}, {UniformDistribution[{0, 1}], UniformDistribution[{0, 1}]}]; data1 = RandomVariate[dist[-.9], 5000]; ListPlot[data1, Frame -> True, AspectRatio -> 1] data2 = RandomVariate[dist[.6], 5000]; ListPlot[data2, Frame -> True, AspectRatio -> 1]


3

You can also use RandomVariate with DiscreteUniformDistribution: rW[a_, b_, n_] := Accumulate[Prepend[ RandomVariate[DiscreteUniformDistribution[{{-a, a}, {-b, b}}], n]], {0,0}] dt = rW[10, 20, 100]; Graphics[{PointSize[Large], Red, Point@#, Thick, Blue, Line@#} &@dt, Frame -> True, Axes->True, AspectRatio -> 1/GoldenRatio] We get the ...


2

f[r_?NumberQ,n_Integer]:={First[#],#.{r,Sqrt[1-r^2]}}&/@RandomReal[NormalDistribution[0,1],{n,2}]; Produces n pairs of numbers with the correlation r.


1

a = 3; b = 5; randomWalk = NestList[# + {RandomInteger[{-a, a}], RandomInteger[{-b, b}]} &, {0, 0}, 100] (* {{0, 0}, {2, 2}, {1, -3}, {-2, 2}, {1, 4}, {1, 3}, {1, 2}, {4, 0}, {4, 0}, {3, -4}, {4, -1}, {2, -5}, {0, 0}, {0, 0}, {2, -3}, {3, -6}, {2, -11}, {4, -10}, {4, -5}, {7, -3}, {9, \ -3}, {6, -8}, {9, -12}, {7, -16}, {5, -11}, {6, -16}, {4, ...


1

Brute Force: While[! ( .9 < Correlation[ a = RandomReal[{0, 1}, 10], b = RandomReal[{0, 1}, 10 ]] < .91 ) ] Correlation[ a, b] 0.900731 {a, b} // MatrixForm I expect this breaks down in a hurry for larger sets.



Only top voted, non community-wiki answers of a minimum length are eligible