Tag Info

New answers tagged

17

This is a 2D Gaussian random field with a $1/k^2$ spectrum and linear dispersion $\omega \propto k$. I clip the field to positive values and square root it to give an edge to the "clouds". n = 256; k2 = Outer[Plus, #, #] &[RotateRight[N@Range[-n, n - 1, 2]/n, n/2]^2]; spectrum = With[{d := RandomReal[NormalDistribution[], {n, n}]}, (1/n) (d + I ...


2

Using the definition of coprime, it is straightforward to construct a function that will do as you ask. Clear[randomCoprime]; randomCoprime[n_Integer, k_Integer : Automatic] := Block[{count, maxP, factors, allowedF}, maxP = PrimePi@Sqrt@n; factors = PrimePi@FactorInteger[n][[All,1]]; count = If[k===Automatic, RandomInteger[{2, maxP}], k]; allowedF = ...


4

This is a straightforward function generating a random coprime number less than given natural number x. cpr[x_Integer]/; x > 1 := RandomChoice @ Pick[ Range[x], CoprimeQ[ x, Range[x]]] e.g. cpr[341] 79 However if we are to deal with larger numbers the given definition is not very convenient therfore it is reasonable to provide another ...


0

myMatrix[i_, j_] := Table[Join[(a = RandomVariate[NormalDistribution[0, 1], i]), Drop[Reverse[a], 1]], {j}] ListPlot[myMatrix[10, 10], Joined -> True]


1

How about creating the left half and using its image for the right half. sigma = .25; L = 300; mu = 1; n = 1000; left = Table[{k,RandomVariate[NormalDistribution[mu, Exp[-(2*Pi*k*sigma/L)^2]]]}, {k, n/2}]; right = Reverse[left] /. {x_, y_} -> {n - x, y}; (*imaging*) full = Join[Most[left], right]; ListPlot[full, Frame -> True] Adding extra ...


0

ClearAll[kfR] kfR[mu_: 0, sigma_: 1, L_: 100] := With[{m = Array[ RandomVariate[NormalDistribution[mu, Exp[-(2 Pi # sigma/L)^2]]] &, Ceiling[#/2]]}, Prepend[m[[MapThread[Min, {Range[#], Reverse@Range[#]}]]], 0]] & MatrixPlot[{kfR[][10]}, AspectRatio -> 1/10, ImageSize -> 800, ColorFunction -> "TemperatureMap", FrameTicks -> ...


2

The fundametal problem is here: Pnt = Append[Pnt, {X, Y}] && Break[] The Break is evaluated and exits before the assignment. Just do this: Pnt = Append[Pnt, {X, Y}] ; Break[] That said Reap/Sow is a better way to go: Bleh[n0_] := Module[{iteration = 1000, error = 10^(-10), denominator = 10^(-10)}, Last@Reap[ Table[ X = ...


1

Here's my attempt to plot the Mandelbrot set with Monte Carlo randomization: mand = Compile[{{z0, _Complex}, {imax, _Integer}}, Module[{z = z0, i = 0}, While[i < imax && Abs[z] <= 2, z = z^3 - 2 z + 2; i++]; i], Parallelization -> True, RuntimeAttributes -> Listable(*, CompilationTarget->"C"*)]; n = 10^6; range = 2; ...


4

No need folding 1D graph to get a 2D Random walk in Mathematica. and the CCW easy in Mathematica. Here we go: Generate data set for the random sequence with 2000 steps. Alternatively, you may use your "own generated" data set. rdata = Accumulate[RandomChoice[{-1, 1}, {2000, 2}]] Now plot it with similar layout as your example ListLinePlot[rdata, ...


4

rw = Accumulate@RandomChoice[{-1, 1}, 400]; ListLinePlot[rw, AspectRatio -> 1] rw2 = Transpose[{rw[[ ;; 200]], rw[[201 ;; ]]}]; llp2 = ListLinePlot[rw2, AspectRatio -> 1] To rotate llp2: Show[MapAt[GeometricTransformation[#, RotationTransform[-45 Degree]] &, llp2, {1}], PlotRange -> All] Aside: Using InterpolationOrder->0 ...


4

ListLinePlot[Accumulate @ Prepend[RandomChoice[{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}, 1000], {1, 1}], AspectRatio -> Automatic] Starting with some random data rd = RandomChoice[{1, -1}, 2000]; ListLinePlot[Accumulate@rd] Creating a random walk similar to the one shown in your question rw = Accumulate@Transpose[{rd[[;; 1000]], rd[[1001 ...



Top 50 recent answers are included