Tag Info

New answers tagged

4

The documentation says that you can use the ProcessEstimator options ... but it does not say which one you can use I take exception to this statement. The documentation for FindProcessParameters clearly states two things. Option values Automatic, "MaximumLikelihood", and "MethodOfMoments" can be given generally as values for the option ...


11

Mathematica's estimation routines are able to recover the Hurst exponent from the sample: BlockRandom[SeedRandom["mathematica.SE/58539"]; tlow = 1; thigh = 1000; tinc = 1; hurst = 0.4; dataz = RandomFunction[FractionalBrownianMotionProcess[hurst], {tlow, thigh, tinc}, 1]]; FindProcessParameters[dataz, FractionalBrownianMotionProcess[h]] {h -> ...


4

Walking infinitely in a random and acceptable direction within a rectangle on button click, stepSize = 1. DynamicModule[{newDir, walk = {{0, 0}}, oldPos, newPos = {0, 0}, acceptQ = -20 <= #[[1]] <= +20 && -10 <= #[[2]] <= +10 &}, { Button["Next Step", oldPos = newPos; newPos = {\[Infinity], \[Infinity]}; ...


25

To answer your question: I don't think it's a bad or good idea to use If. It depends on how you do it. To demonstrate I'll use If combined very powerfully with Mathematica 10's ability to tell if a point is inside a specified region or not. step[position_, region_] := Module[{randomStep}, randomStep = RandomChoice[{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}]; ...


6

I chose the WienerProcess as the underlying random process, as this will simulate a Brownian motion. Until Boundary Hit Module[{rd = Transpose @ RandomFunction[WienerProcess[], {0, 1000, .01}, 2]["States"], length}, length = LengthWhile[rd, # ∈ Rectangle[{-2, -2}, {+2, +2}] &]; ListPlot[rd[[;; length]], Joined -> True, Mesh -> All, PlotRange ...


13

I suggest using Mod - a natural thing for looped boundary conditions on a torus. Finite torus surface area is your bounded region. 2D random walk generally is simple: walk = Accumulate[RandomReal[{-.1, .1}, {100, 2}]]; Graphics[Line[walk], Frame -> True] Confinement to square region {{0,1},{0,1}} would be simple in principle with Mod[walk,1] ...


7

Here's my implement of a random walk within a circle using If and FoldList. Please see @Pickett's answer for more thorough implementation for arbitrary regions. Code updated to flesh out behavior near edge of region (if a step becomes out of bound, the current position will randomly look for the other step types that would stay in the region). I also added ...


0

The easiest way is to define the vertices sequentially. x=RandomReal[{0,1/2},1000] y=RandomReal[{0,1/2-x},1000] z=RandomReal[{-1,-2(x+y)},1000]


4

Ray Koopman's answer to Uniformly distributed n-dimensional probability vectors applied to a simplex with given vertices leads to the following way to get (exactly) n uniformly distributed random points in the simplex (and do it quickly): pts = #.vertices/Total[#, {2}] &@ Log @ RandomReal[1, {n, 4}]; Here are 2000 points in the OP's simplex: vertices ...


5

The following seems to work: Cases[RandomReal[{-1, 1}, {1500000, 3}], {x_, y_, z_} /; 0 < x < 0.5 && 0 < y < 0.5 - x && -1 < z < -2 (x + y)] OR Select[RandomReal[{-1, 1}, {1500000, 3}], 0 < #[[1]] < 0.5 && 0 < #[[2]] < 0.5 - #[[1]] && -1 < #[[3]] < -2 (#[[1]] + #[[2]]) &] Here ...


4

Here is a quick (and dirty?) implementation of the Laplace distribution. Relationship to the uniform distribution as given on Wikipedia: randomLaplace = With[{$MachineEpsilon = $MachineEpsilon}, Compile[{{µ, _Real, 0}, {b, _Real, 0}, {n, _Integer, 0}}, With[{u = RandomReal[{-1/2, 1/2} (1 - $MachineEpsilon), n]}, µ - b Sign[u] Log[1 - 2 Abs[u]] ] ...


8

Another option to the answer posted by @Andy Ross cropped up in a recent question of mine about corrupting an image with Poisson noise. In my own answer, I made use of LibraryLink to utilise the distributions built into C++, which you can find here: http://www.cplusplus.com/reference/random/ This was especially useful in my case because Poisson noise in an ...


0

I tried several ways to save time and make it more effective: McVol1[num_] := Module[{hit, miss, index, x, y, z}, hit = 0; miss = 0; For[index = 1, index <= num, ++index, {x, y, z} = RandomReal[{-1, 1}, 3]; If[x^2 + y^2 + z^2 <= 1, ++hit]]; hit/num] Print["time and value...... :", Timing[N@McVol1[100000]]] Result is time and ...



Top 50 recent answers are included