48
votes
How to sample points randomly below a curve?
There is no need in filtering out random points in a rectangle that don't fall in the prescribed region. The sampling within a region can be done directly with ...
26
votes
Accepted
Efficient way to simulate thousands of Markov chains
While the other answers focus on circumventing the simulations, I focus on how to speed up the simulations themselves. (Sometimes, simulations might be unavoidable.)
In this situation, when calling <...
26
votes
Accepted
Sisyphus Random Walk
We can iterate with FoldList:
data = {0, 1, 1, 0, 1, 0, 1, 1, 1, 1};
FoldList[#2 * (#1 + #2)&, data]
...
25
votes
Accepted
How to sample points randomly below a curve?
As noted in my comment, one approach is as follows. First, generate thousands of pairs of random numbers in the range {0, 2 π}, ...
25
votes
Accepted
Implementing a planetary terrain generation algorithm
Here my two cents. I observed that the major part of the computation is about multiplication. Hence I transformed to logarithms such that we can use summations which can be executed efficiently with <...
25
votes
New Compiler Technology in V12
I wanted to look into this for a long time, and it took only 2 months to come back to this question. To answer your main question: Yes, it appears that the new compiler only supports uniformly ...
24
votes
Implementing a planetary terrain generation algorithm
I have a basic implementation of this which I use with the output of DiscretizeGraphics:
...
20
votes
Accepted
Why do changing the limits of RandomInteger not affect the result?
I'm pretty sure this is expected. Consider the following implementation of RandomInteger:
...
20
votes
Accepted
Reproducing Heinrich Heidersberger's Rhythmograms
A starting point
We use two variables {u,v}: a parametric form of Mobius Strip f[u,v] and product with some factors to ...
19
votes
How to sample points randomly below a curve?
More of a first principles approach, use the function as a PDF to generate random x data, then for each ...
19
votes
Smarter Shuffle of a List
You may Flatten the list and then take a RandomSample before partitioning to the original dimensions with ...
19
votes
Is there a way to randomly distribute points within a circle on the surface of a sphere?
You can intersect the sphere and a cylinder, and then use RandomPoint. For example, here is a random point on the sphere:
...
19
votes
How to create a random zonogon?
We can using Minkowski Sum (RegionDilation) of any Line's from the fixed point ...
18
votes
Accepted
Is RandomGraph really random?
Indeed there are four graphs with 5 vertices and 7 edges, two of which have a Hamiltonian cycle:
...
18
votes
Accepted
Random points around the given curve
Using RandomPoint[] with TubeMesh[] (routines from here and here) does the job:
...
18
votes
Efficient way to simulate thousands of Markov chains
I essentially derive a second distribution - without a need for stochastic modelling - from DiscreteMarkovProcess timeslices according to your state to value ...
17
votes
RandomChoice output isn't packed
In order for RandomChoice to produce a packed array, the RHS of the rule needs to be packed:
...
16
votes
Efficient way to simulate thousands of Markov chains
In general, Mathematica is not always the best tool for this type of simulation. That said, you do not need to compute sample paths to compute the mean or variance.
For a Markov chain with ...
16
votes
Accepted
On random numbers extracted from NormalDistribution by two different methods under the same seed
I think this is due to the Box–Muller transform that is employed to generate pairs of normally distributed values. This method is much faster than using the inverse commulative probability function.
...
16
votes
Accepted
16
votes
How can I generate the same random number in Mathematica and MATLAB?
If it is solely for regression testing, the quality of the random numbers doesn't matter very much. You can substitute a better random number generator once you know the Mathematica version matches ...
16
votes
Generating random sequence of integers with ordering constraints
Perhaps have a look at DiscreteMarkovProcess using an appropriate transition matrix embedding your constraints?
Here's a simple example, implementing 1-5 above, to ...
15
votes
Generating animations of clouds with Mathematica
Nice cloud-like images can be generated by summing "octaves" of any of a number of continuous noise functions. Perlin noise is one possibility, as mentioned in the OP; here, I'll present a slightly ...
15
votes
Accepted
Probability a random triangle on a circle contains the origin
Some issues with your code are that the list of random data you generate is not a PackedArray; moreover creating random numbers is more efficient if you generate ...
15
votes
Better random (unique) file name
It might be best to use CreateUUID.
CreateUUID[]
"73ccc27c-687f-4eca-8214-ceeb8a8b7773"
...
15
votes
Accepted
14
votes
Generating random points on a Klein's bottle
There is a function for this since Mathematica 10.2.
...
14
votes
Generate a random number outside a range
You can use RandomPoint with Interval:
First @ RandomPoint[Interval[{1, 3}, {5, 7}]]
5....
14
votes
Accepted
How can CompiledCodeFunctions be optimized and parallelized?
In general, the weak spots of interpreted languages are loop constructs and function calls. So I'd suggest to push also the Table into the compiled code to generate ...
13
votes
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
random × 914probability-or-statistics × 145
distributions × 101
list-manipulation × 100
plotting × 70
matrix × 70
performance-tuning × 58
simulation × 51
graphics × 43
functions × 31
graphs-and-networks × 30
regions × 30
stochastic-calculus × 29
differential-equations × 27
generative-art × 27
graphics3d × 26
function-construction × 23
random-process × 22
programming × 21
sampling × 21
numerical-integration × 19
bugs × 19
version-7 × 19
manipulate × 18
geometry × 18